| 1 | // Copyright 2021 CNI authors |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package linkscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/ |
| 16 | |
| 17 | import ( |
| 18 | "contextscip-go gomod github.com/golang/go/src go1.24.2 context/" |
| 19 | "fmtscip-go gomod github.com/golang/go/src go1.24.2 fmt/" |
| 20 | "osscip-go gomod github.com/golang/go/src go1.24.2 os/" |
| 21 | "timescip-go gomod github.com/golang/go/src go1.24.2 time/" |
| 22 | |
| 23 | "github.com/networkplumbing/go-nft/nftscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/" |
| 24 | "github.com/networkplumbing/go-nft/nft/schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/" |
| 25 | ) |
| 26 | |
| 27 | const ( |
| 28 | natTableNamescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/natTableName. = "nat" |
| 29 | preRoutingBaseChainNamescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/preRoutingBaseChainName. = "PREROUTING" |
| 30 | ) |
| 31 | |
| 32 | type NftConfigurerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/NftConfigurer# interface { |
| 33 | Applyscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/NftConfigurer#Apply.(*nftscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/.Configscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/Config#) (*nftscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/.Configscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/Config#, error) |
| 34 | Readscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/NftConfigurer#Read.(filterCommands ...string) (*nftscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/.Configscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/Config#, error) |
| 35 | } |
| 36 | |
| 37 | type SpoofCheckerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker# struct { |
| 38 | ifacescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#iface. string |
| 39 | macAddressscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#macAddress. string |
| 40 | refIDscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#refID. string |
| 41 | configurerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#configurer. NftConfigurerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/NftConfigurer# |
| 42 | rulestorescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#rulestore. *nftscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/.Configscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/Config# |
| 43 | } |
| 44 | |
| 45 | type defaultNftConfigurerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/defaultNftConfigurer# struct{} |
| 46 | |
| 47 | func (dnc defaultNftConfigurerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/defaultNftConfigurer#) Applyscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/defaultNftConfigurer#Apply().(cfg *nftscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/.Configscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/Config#) (*nftscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/.Configscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/Config#, error) { |
| 48 | const timeout = 55 * timescip-go gomod github.com/golang/go/src go1.24.2 time/.Secondscip-go gomod github.com/golang/go/src go1.24.2 time/Second. |
| 49 | ctxWithTimeout, cancelFunc := contextscip-go gomod github.com/golang/go/src go1.24.2 context/.WithTimeoutscip-go gomod github.com/golang/go/src go1.24.2 context/WithTimeout().(contextscip-go gomod github.com/golang/go/src go1.24.2 context/.Backgroundscip-go gomod github.com/golang/go/src go1.24.2 context/Background().(), timeout) |
| 50 | defer cancelFunc() |
| 51 | return nftscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/.ApplyConfigEchoscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/ApplyConfigEcho().(ctxWithTimeout, cfg) |
| 52 | } |
| 53 | |
| 54 | func (dnc defaultNftConfigurerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/defaultNftConfigurer#) Readscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/defaultNftConfigurer#Read().(filterCommands ...string) (*nftscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/.Configscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/Config#, error) { |
| 55 | const timeout = 55 * timescip-go gomod github.com/golang/go/src go1.24.2 time/.Secondscip-go gomod github.com/golang/go/src go1.24.2 time/Second. |
| 56 | ctxWithTimeout, cancelFunc := contextscip-go gomod github.com/golang/go/src go1.24.2 context/.WithTimeoutscip-go gomod github.com/golang/go/src go1.24.2 context/WithTimeout().(contextscip-go gomod github.com/golang/go/src go1.24.2 context/.Backgroundscip-go gomod github.com/golang/go/src go1.24.2 context/Background().(), timeout) |
| 57 | defer cancelFunc() |
| 58 | return nftscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/.ReadConfigContextscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/ReadConfigContext().(ctxWithTimeout, filterCommands...) |
| 59 | } |
| 60 | |
| 61 | func NewSpoofCheckerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/NewSpoofChecker().(iface, macAddress, refID string) *SpoofCheckerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker# { |
| 62 | return NewSpoofCheckerWithConfigurerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/NewSpoofCheckerWithConfigurer().(iface, macAddress, refID, defaultNftConfigurerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/defaultNftConfigurer#{}) |
| 63 | } |
| 64 | |
| 65 | func NewSpoofCheckerWithConfigurerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/NewSpoofCheckerWithConfigurer().(iface, macAddress, refID string, configurer NftConfigurerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/NftConfigurer#) *SpoofCheckerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker# { |
| 66 | return &SpoofCheckerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#{iface, macAddress, refID, configurer, nil} |
| 67 | } |
| 68 | |
| 69 | // Setup applies nftables configuration to restrict traffic |
| 70 | // from the provided interface. Only traffic with the mentioned mac address |
| 71 | // is allowed to pass, all others are blocked. |
| 72 | // The configuration follows the format libvirt and ebtables implemented, allowing |
| 73 | // extensions to the rules in the future. |
| 74 | // refID is used to label the rules with a unique comment, identifying the rule-set. |
| 75 | // |
| 76 | // In order to take advantage of the nftables configuration change atomicity, the |
| 77 | // following steps are taken to apply the configuration: |
| 78 | // - Declare the table and chains (they will be created in case not present). |
| 79 | // - Apply the rules, while first flushing the iface/mac specific regular chain rules. |
| 80 | // Two transactions are used because the flush succeeds only if the table/chain it targets |
| 81 | // exists. This avoids the need to query the existing state and acting upon it (a raceful pattern). |
| 82 | // Although two transactions are taken place, only the 2nd one where the rules |
| 83 | // are added has a real impact on the system. |
| 84 | func (sc *SpoofCheckerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#) Setupscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#Setup().() error { |
| 85 | baseConfig := nftscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/.NewConfigscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/NewConfig().() |
| 86 | |
| 87 | baseConfig.AddTablescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/config`/Config#AddTable().(&schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Tablescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Table#{Familyscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Table#Family.: schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.FamilyBridgescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/FamilyBridge., Namescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Table#Name.: natTableNamescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/natTableName.}) |
| 88 | |
| 89 | baseConfig.AddChainscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/config`/Config#AddChain().(sc.baseChainscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#baseChain().()) |
| 90 | ifaceChain := sc.ifaceChainscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#ifaceChain().() |
| 91 | baseConfig.AddChainscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/config`/Config#AddChain().(ifaceChain) |
| 92 | macChain := sc.macChainscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#macChain().(ifaceChain.Namescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain#Name.) |
| 93 | baseConfig.AddChainscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/config`/Config#AddChain().(macChain) |
| 94 | |
| 95 | if _, err := sc.configurerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#configurer..Applyscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/NftConfigurer#Apply.(baseConfig); err != nil { |
| 96 | return fmtscip-go gomod github.com/golang/go/src go1.24.2 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.2 fmt/Errorf().("failed to setup spoof-check: %v", err) |
| 97 | } |
| 98 | |
| 99 | rulesConfig := nftscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/.NewConfigscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/NewConfig().() |
| 100 | |
| 101 | rulesConfig.FlushChainscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/config`/Config#FlushChain().(ifaceChain) |
| 102 | rulesConfig.FlushChainscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/config`/Config#FlushChain().(macChain) |
| 103 | |
| 104 | rulesConfig.AddRulescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/config`/Config#AddRule().(sc.matchIfaceJumpToChainRulescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#matchIfaceJumpToChainRule().(preRoutingBaseChainNamescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/preRoutingBaseChainName., ifaceChain.Namescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain#Name.)) |
| 105 | rulesConfig.AddRulescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/config`/Config#AddRule().(sc.jumpToChainRulescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#jumpToChainRule().(ifaceChain.Namescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain#Name., macChain.Namescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain#Name.)) |
| 106 | rulesConfig.AddRulescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/config`/Config#AddRule().(sc.matchMacRulescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#matchMacRule().(macChain.Namescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain#Name.)) |
| 107 | rulesConfig.AddRulescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/config`/Config#AddRule().(sc.dropRulescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#dropRule().(macChain.Namescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain#Name.)) |
| 108 | |
| 109 | rulestore, err := sc.configurerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#configurer..Applyscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/NftConfigurer#Apply.(rulesConfig) |
| 110 | if err != nil { |
| 111 | return fmtscip-go gomod github.com/golang/go/src go1.24.2 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.2 fmt/Errorf().("failed to setup spoof-check: %v", err) |
| 112 | } |
| 113 | sc.rulestorescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#rulestore. = rulestore |
| 114 | |
| 115 | return nil |
| 116 | } |
| 117 | |
| 118 | func (sc *SpoofCheckerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#) findPreroutingRulescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#findPreroutingRule().(ruleToFind *schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Rulescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#) ([]*schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Rulescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#, error) { |
| 119 | ruleset := sc.rulestorescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#rulestore. |
| 120 | if ruleset == nil { |
| 121 | chain, err := sc.configurerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#configurer..Readscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/NftConfigurer#Read.(listChainBridgeNatPreroutingscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/listChainBridgeNatPrerouting().()...) |
| 122 | if err != nil { |
| 123 | return nil, err |
| 124 | } |
| 125 | ruleset = chain |
| 126 | } |
| 127 | return ruleset.LookupRulescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/config`/Config#LookupRule().(ruleToFind), nil |
| 128 | } |
| 129 | |
| 130 | // Teardown removes the interface and mac-address specific chains and their rules. |
| 131 | // The table and base-chain are expected to survive while the base-chain rule that matches the |
| 132 | // interface is removed. |
| 133 | func (sc *SpoofCheckerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#) Teardownscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#Teardown().() error { |
| 134 | ifaceChain := sc.ifaceChainscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#ifaceChain().() |
| 135 | expectedRuleToFind := sc.matchIfaceJumpToChainRulescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#matchIfaceJumpToChainRule().(preRoutingBaseChainNamescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/preRoutingBaseChainName., ifaceChain.Namescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain#Name.) |
| 136 | // It is safer to exclude the statement matching, avoiding cases where a current statement includes |
| 137 | // additional default entries (e.g. counters). |
| 138 | ruleToFindExcludingStatements := *expectedRuleToFind |
| 139 | ruleToFindExcludingStatements.Exprscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#Expr. = nil |
| 140 | |
| 141 | rules, ifaceMatchRuleErr := sc.findPreroutingRulescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#findPreroutingRule().(&ruleToFindExcludingStatements) |
| 142 | if ifaceMatchRuleErr == nil && len(rules) > 0 { |
| 143 | c := nftscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/.NewConfigscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/NewConfig().() |
| 144 | for _, rule := range rules { |
| 145 | c.DeleteRulescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/config`/Config#DeleteRule().(rule) |
| 146 | } |
| 147 | if _, err := sc.configurerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#configurer..Applyscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/NftConfigurer#Apply.(c); err != nil { |
| 148 | ifaceMatchRuleErr = fmtscip-go gomod github.com/golang/go/src go1.24.2 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.2 fmt/Errorf().("failed to delete iface match rule: %v", err) |
| 149 | } |
| 150 | // Drop the cache, it should contain deleted rule(s) now |
| 151 | sc.rulestorescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#rulestore. = nil |
| 152 | } else { |
| 153 | fmtscip-go gomod github.com/golang/go/src go1.24.2 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.2 fmt/Fprintf().(osscip-go gomod github.com/golang/go/src go1.24.2 os/.Stderrscip-go gomod github.com/golang/go/src go1.24.2 os/Stderr., "spoofcheck/teardown: unable to detect iface match rule for deletion: %+v", expectedRuleToFind) |
| 154 | } |
| 155 | |
| 156 | regularChainsConfig := nftscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/.NewConfigscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft`/NewConfig().() |
| 157 | regularChainsConfig.DeleteChainscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/config`/Config#DeleteChain().(ifaceChain) |
| 158 | regularChainsConfig.DeleteChainscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/config`/Config#DeleteChain().(sc.macChainscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#macChain().(ifaceChain.Namescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain#Name.)) |
| 159 | |
| 160 | var regularChainsErr error |
| 161 | if _, err := sc.configurerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#configurer..Applyscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/NftConfigurer#Apply.(regularChainsConfig); err != nil { |
| 162 | regularChainsErr = fmtscip-go gomod github.com/golang/go/src go1.24.2 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.2 fmt/Errorf().("failed to delete regular chains: %v", err) |
| 163 | } |
| 164 | |
| 165 | if ifaceMatchRuleErr != nil || regularChainsErr != nil { |
| 166 | return fmtscip-go gomod github.com/golang/go/src go1.24.2 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.2 fmt/Errorf().("failed to teardown spoof-check: %v, %v", ifaceMatchRuleErr, regularChainsErr) |
| 167 | } |
| 168 | return nil |
| 169 | } |
| 170 | |
| 171 | func (sc *SpoofCheckerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#) matchIfaceJumpToChainRulescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#matchIfaceJumpToChainRule().(chain, toChain string) *schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Rulescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule# { |
| 172 | return &schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Rulescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#{ |
| 173 | Familyscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#Family.: schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.FamilyBridgescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/FamilyBridge., |
| 174 | Tablescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#Table.: natTableNamescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/natTableName., |
| 175 | Chainscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#Chain.: chain, |
| 176 | Exprscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#Expr.: []schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Statementscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Statement#{ |
| 177 | {Matchscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Statement#Match.: &schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Matchscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Match#{ |
| 178 | Opscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Match#Op.: schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.OperEQscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/OperEQ., |
| 179 | Leftscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Match#Left.: schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Expressionscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Expression#{RowDatascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Expression#RowData.: []byte(`{"meta":{"key":"iifname"}}`)}, |
| 180 | Rightscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Match#Right.: schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Expressionscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Expression#{Stringscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Expression#String.: &sc.ifacescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#iface.}, |
| 181 | }}, |
| 182 | {Verdictscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Statement#Verdict.: schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Verdictscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Verdict#{Jumpscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Verdict#Jump.: &schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.ToTargetscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/ToTarget#{Targetscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/ToTarget#Target.: toChain}}}, |
| 183 | }, |
| 184 | Commentscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#Comment.: ruleCommentscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/ruleComment().(sc.refIDscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#refID.), |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | func (sc *SpoofCheckerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#) jumpToChainRulescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#jumpToChainRule().(chain, toChain string) *schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Rulescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule# { |
| 189 | return &schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Rulescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#{ |
| 190 | Familyscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#Family.: schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.FamilyBridgescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/FamilyBridge., |
| 191 | Tablescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#Table.: natTableNamescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/natTableName., |
| 192 | Chainscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#Chain.: chain, |
| 193 | Exprscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#Expr.: []schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Statementscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Statement#{ |
| 194 | {Verdictscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Statement#Verdict.: schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Verdictscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Verdict#{Jumpscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Verdict#Jump.: &schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.ToTargetscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/ToTarget#{Targetscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/ToTarget#Target.: toChain}}}, |
| 195 | }, |
| 196 | Commentscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#Comment.: ruleCommentscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/ruleComment().(sc.refIDscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#refID.), |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | func (sc *SpoofCheckerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#) matchMacRulescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#matchMacRule().(chain string) *schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Rulescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule# { |
| 201 | return &schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Rulescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#{ |
| 202 | Familyscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#Family.: schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.FamilyBridgescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/FamilyBridge., |
| 203 | Tablescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#Table.: natTableNamescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/natTableName., |
| 204 | Chainscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#Chain.: chain, |
| 205 | Exprscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#Expr.: []schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Statementscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Statement#{ |
| 206 | {Matchscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Statement#Match.: &schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Matchscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Match#{ |
| 207 | Opscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Match#Op.: schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.OperEQscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/OperEQ., |
| 208 | Leftscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Match#Left.: schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Expressionscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Expression#{Payloadscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Expression#Payload.: &schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Payloadscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Payload#{ |
| 209 | Protocolscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Payload#Protocol.: schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.PayloadProtocolEtherscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/PayloadProtocolEther., |
| 210 | Fieldscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Payload#Field.: schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.PayloadFieldEtherSAddrscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/PayloadFieldEtherSAddr., |
| 211 | }}, |
| 212 | Rightscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Match#Right.: schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Expressionscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Expression#{Stringscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Expression#String.: &sc.macAddressscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#macAddress.}, |
| 213 | }}, |
| 214 | {Verdictscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Statement#Verdict.: schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Verdictscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Verdict#{SimpleVerdictscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Verdict#SimpleVerdict.: schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.SimpleVerdictscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/SimpleVerdict#{Returnscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/SimpleVerdict#Return.: true}}}, |
| 215 | }, |
| 216 | Commentscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#Comment.: ruleCommentscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/ruleComment().(sc.refIDscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#refID.), |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | func (sc *SpoofCheckerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#) dropRulescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#dropRule().(chain string) *schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Rulescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule# { |
| 221 | return &schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Rulescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#{ |
| 222 | Familyscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#Family.: schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.FamilyBridgescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/FamilyBridge., |
| 223 | Tablescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#Table.: natTableNamescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/natTableName., |
| 224 | Chainscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#Chain.: chain, |
| 225 | Exprscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#Expr.: []schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Statementscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Statement#{ |
| 226 | {Verdictscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Statement#Verdict.: schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Verdictscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Verdict#{SimpleVerdictscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Verdict#SimpleVerdict.: schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.SimpleVerdictscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/SimpleVerdict#{Dropscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/SimpleVerdict#Drop.: true}}}, |
| 227 | }, |
| 228 | Commentscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Rule#Comment.: ruleCommentscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/ruleComment().(sc.refIDscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#refID.), |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | func (sc *SpoofCheckerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#) baseChainscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#baseChain().() *schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Chainscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain# { |
| 233 | chainPriority := -300 |
| 234 | return &schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Chainscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain#{ |
| 235 | Familyscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain#Family.: schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.FamilyBridgescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/FamilyBridge., |
| 236 | Tablescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain#Table.: natTableNamescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/natTableName., |
| 237 | Namescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain#Name.: preRoutingBaseChainNamescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/preRoutingBaseChainName., |
| 238 | Typescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain#Type.: schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.TypeFilterscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/TypeFilter., |
| 239 | Hookscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain#Hook.: schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.HookPreRoutingscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/HookPreRouting., |
| 240 | Prioscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain#Prio.: &chainPriority, |
| 241 | Policyscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain#Policy.: schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.PolicyAcceptscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/PolicyAccept., |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | func (sc *SpoofCheckerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#) ifaceChainscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#ifaceChain().() *schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Chainscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain# { |
| 246 | ifaceChainName := "cni-br-iface-" + sc.refIDscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#refID. |
| 247 | return &schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Chainscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain#{ |
| 248 | Familyscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain#Family.: schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.FamilyBridgescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/FamilyBridge., |
| 249 | Tablescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain#Table.: natTableNamescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/natTableName., |
| 250 | Namescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain#Name.: ifaceChainName, |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | func (sc *SpoofCheckerscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#) macChainscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/SpoofChecker#macChain().(ifaceChainName string) *schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Chainscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain# { |
| 255 | macChainName := ifaceChainName + "-mac" |
| 256 | return &schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.Chainscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain#{ |
| 257 | Familyscip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain#Family.: schemascip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/.FamilyBridgescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/FamilyBridge., |
| 258 | Tablescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain#Table.: natTableNamescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/natTableName., |
| 259 | Namescip-go gomod github.com/networkplumbing/go-nft v0.4.0 `github.com/networkplumbing/go-nft/nft/schema`/Chain#Name.: macChainName, |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | func ruleCommentscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/ruleComment().(id string) string { |
| 264 | const refIDPrefix = "macspoofchk-" |
| 265 | return refIDPrefix + id |
| 266 | } |
| 267 | |
| 268 | func listChainBridgeNatPreroutingscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/listChainBridgeNatPrerouting().() []string { |
| 269 | return []string{"chain", "bridge", natTableNamescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/natTableName., preRoutingBaseChainNamescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/link`/preRoutingBaseChainName.} |
| 270 | } |