Skip to content

Commit

Permalink
ASGs are applied to all interfaces but silk-vtep
Browse files Browse the repository at this point in the history
[#155197426]

Signed-off-by: Joachim Valdez <[email protected]>
  • Loading branch information
angelachin authored and joachimvaldez committed Feb 28, 2018
1 parent 9c9e6e8 commit e3b50ff
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ var _ = Describe("CniWrapperPlugin", func() {
Eventually(session).Should(gexec.Exit(0))

By("checking that the jump rules are created for that container's netout chain")
Expect(AllIPTablesRules("filter")).To(ContainElement("-A FORWARD -s 1.2.3.4/32 -o " + defaultIface.Name + " -j " + netoutChainName))
Expect(AllIPTablesRules("filter")).To(ContainElement("-A FORWARD -s 1.2.3.4/32 ! -o some-device -j " + netoutChainName))

By("checking that the default forwarding rules are created for that container")
Expect(AllIPTablesRules("filter")).To(gomegamatchers.ContainSequence([]string{
Expand Down
5 changes: 2 additions & 3 deletions src/cni-wrapper-plugin/legacynet/netout.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ type NetOut struct {
C2CLogging bool
IngressTag string
VTEPName string
HostInterfaceName string
DeniedLogsPerSec int
AcceptedUDPLogsPerSec int
}
Expand Down Expand Up @@ -75,7 +74,7 @@ func (m *NetOut) Initialize(containerHandle string, containerIP net.IP, dnsServe
Chain: forwardChain,
JumpConditions: rules.IPTablesRule{
"-s", containerIP.String(),
"-o", m.HostInterfaceName,
"!", "-o", m.VTEPName,
},
Rules: []rules.IPTablesRule{
rules.NewNetOutRelatedEstablishedRule(),
Expand Down Expand Up @@ -162,7 +161,7 @@ func (m *NetOut) Cleanup(containerHandle, containerIP string) error {
Chain: forwardChain,
JumpConditions: rules.IPTablesRule{
"-s", containerIP,
"-o", m.HostInterfaceName,
"!", "-o", m.VTEPName,
},
},
{
Expand Down
5 changes: 2 additions & 3 deletions src/cni-wrapper-plugin/legacynet/netout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ var _ = Describe("Netout", func() {
Converter: converter,
IngressTag: "FEEDBEEF",
VTEPName: "vtep-name",
HostInterfaceName: "some-device",
DeniedLogsPerSec: 3,
AcceptedUDPLogsPerSec: 6,
}
Expand Down Expand Up @@ -89,7 +88,7 @@ var _ = Describe("Netout", func() {
Expect(table).To(Equal("filter"))
Expect(chain).To(Equal("FORWARD"))
Expect(position).To(Equal(1))
Expect(rulespec).To(Equal([]rules.IPTablesRule{{"-s", "5.6.7.8", "-o", "some-device", "--jump", "netout-some-container-handle"}}))
Expect(rulespec).To(Equal([]rules.IPTablesRule{{"-s", "5.6.7.8", "!", "-o", "vtep-name", "--jump", "netout-some-container-handle"}}))

table, chain, position, rulespec = ipTables.BulkInsertArgsForCall(1)
Expect(table).To(Equal("filter"))
Expand Down Expand Up @@ -337,7 +336,7 @@ var _ = Describe("Netout", func() {
table, chain, extraArgs = ipTables.DeleteArgsForCall(1)
Expect(table).To(Equal("filter"))
Expect(chain).To(Equal("FORWARD"))
Expect(extraArgs).To(Equal(rules.IPTablesRule{"-s", "5.6.7.8", "-o", "some-device", "--jump", "netout-some-container-handle"}))
Expect(extraArgs).To(Equal(rules.IPTablesRule{"-s", "5.6.7.8", "!", "-o", "vtep-name", "--jump", "netout-some-container-handle"}))

table, chain, extraArgs = ipTables.DeleteArgsForCall(2)
Expect(table).To(Equal("filter"))
Expand Down
16 changes: 3 additions & 13 deletions src/cni-wrapper-plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ func cmdAdd(args *skel.CmdArgs) error {
AcceptedUDPLogsPerSec: n.IPTablesAcceptedUDPLogsPerSec,
IngressTag: n.IngressTag,
VTEPName: n.VTEPName,
HostInterfaceName: defaultIfaceName,
}
if err := netOutProvider.Initialize(args.ContainerID, containerIP, localDNSServers); err != nil {
return fmt.Errorf("initialize net out: %s", err)
Expand Down Expand Up @@ -194,22 +193,13 @@ func cmdDel(args *skel.CmdArgs) error {
fmt.Fprintf(os.Stderr, "net in cleanup: %s", err)
}

defaultInterface := discover.DefaultInterface{
NetlinkAdapter: &adapter.NetlinkAdapter{},
NetAdapter: &adapter.NetAdapter{},
}
defaultIfaceName, err := defaultInterface.Name()
if err != nil {
return fmt.Errorf("discover default interface name: %s", err) // not tested
}

netOutProvider := legacynet.NetOut{
ChainNamer: &legacynet.ChainNamer{
MaxLength: 28,
},
IPTables: pluginController.IPTables,
Converter: &legacynet.NetOutRuleConverter{Logger: os.Stderr},
HostInterfaceName: defaultIfaceName,
IPTables: pluginController.IPTables,
Converter: &legacynet.NetOutRuleConverter{Logger: os.Stderr},
VTEPName: n.VTEPName,
}

if err = netOutProvider.Cleanup(args.ContainerID, container.IP); err != nil {
Expand Down

0 comments on commit e3b50ff

Please sign in to comment.