bridge, spoofcheck: only read the prerouting chain on CNI delete
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
This commit is contained in:
parent
83fe87c5b0
commit
7dcd738d34
@ -29,7 +29,7 @@ const (
|
|||||||
|
|
||||||
type NftConfigurer interface {
|
type NftConfigurer interface {
|
||||||
Apply(*nft.Config) error
|
Apply(*nft.Config) error
|
||||||
Read() (*nft.Config, error)
|
Read(filterCommands ...string) (*nft.Config, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type SpoofChecker struct {
|
type SpoofChecker struct {
|
||||||
@ -45,8 +45,8 @@ func (dnc defaultNftConfigurer) Apply(cfg *nft.Config) error {
|
|||||||
return nft.ApplyConfig(cfg)
|
return nft.ApplyConfig(cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dnc defaultNftConfigurer) Read() (*nft.Config, error) {
|
func (dnc defaultNftConfigurer) Read(filterCommands ...string) (*nft.Config, error) {
|
||||||
return nft.ReadConfig()
|
return nft.ReadConfig(filterCommands...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSpoofChecker(iface, macAddress, refID string) *SpoofChecker {
|
func NewSpoofChecker(iface, macAddress, refID string) *SpoofChecker {
|
||||||
@ -109,7 +109,7 @@ func (sc *SpoofChecker) Setup() error {
|
|||||||
// interface is removed.
|
// interface is removed.
|
||||||
func (sc *SpoofChecker) Teardown() error {
|
func (sc *SpoofChecker) Teardown() error {
|
||||||
ifaceChain := sc.ifaceChain()
|
ifaceChain := sc.ifaceChain()
|
||||||
currentConfig, ifaceMatchRuleErr := sc.configurer.Read()
|
currentConfig, ifaceMatchRuleErr := sc.configurer.Read(listChainBridgeNatPrerouting()...)
|
||||||
if ifaceMatchRuleErr == nil {
|
if ifaceMatchRuleErr == nil {
|
||||||
expectedRuleToFind := sc.matchIfaceJumpToChainRule(preRoutingBaseChainName, ifaceChain.Name)
|
expectedRuleToFind := sc.matchIfaceJumpToChainRule(preRoutingBaseChainName, ifaceChain.Name)
|
||||||
// It is safer to exclude the statement matching, avoiding cases where a current statement includes
|
// It is safer to exclude the statement matching, avoiding cases where a current statement includes
|
||||||
@ -241,3 +241,7 @@ func ruleComment(id string) string {
|
|||||||
const refIDPrefix = "macspoofchk-"
|
const refIDPrefix = "macspoofchk-"
|
||||||
return refIDPrefix + id
|
return refIDPrefix + id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func listChainBridgeNatPrerouting() []string {
|
||||||
|
return []string{"chain", "bridge", natTableName, preRoutingBaseChainName}
|
||||||
|
}
|
||||||
|
@ -288,7 +288,7 @@ func (a *configurerStub) Apply(c *nft.Config) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *configurerStub) Read() (*nft.Config, error) {
|
func (a *configurerStub) Read(_ ...string) (*nft.Config, error) {
|
||||||
if a.failReadConfig {
|
if a.failReadConfig {
|
||||||
return nil, fmt.Errorf(errorReadText)
|
return nil, fmt.Errorf(errorReadText)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user