Skip to content

Commit

Permalink
add the nodes local IP address to OVS rules
Browse files Browse the repository at this point in the history
this change adds the nodes local IP address to the ovs rules when using
egressnetworkpolicies to limit egress from the cluster. Adding the nodes
local IP allows for dns resolution when dns is accessable on the node.

bug 1458849

changelog:

 - changed the rules creation to SetupOVS()
 - made both udp and tcp rules the same priority
  • Loading branch information
JacobTanenbaum committed Jun 28, 2017
1 parent bbb9647 commit 74f0baf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion pkg/sdn/plugin/ovscontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (oc *ovsController) AlreadySetUp() bool {
return false
}

func (oc *ovsController) SetupOVS(clusterNetworkCIDR, serviceNetworkCIDR, localSubnetCIDR, localSubnetGateway string) error {
func (oc *ovsController) SetupOVS(clusterNetworkCIDR, serviceNetworkCIDR, localSubnetCIDR, localSubnetGateway, nodeIP string) error {
err := oc.ovs.AddBridge("fail-mode=secure", "protocols=OpenFlow13")
if err != nil {
return err
Expand Down Expand Up @@ -177,6 +177,8 @@ func (oc *ovsController) SetupOVS(clusterNetworkCIDR, serviceNetworkCIDR, localS
// Table 100: egress network policy dispatch; edited by UpdateEgressNetworkPolicy()
// eg, "table=100, reg0=${tenant_id}, priority=2, ip, nw_dst=${external_cidr}, actions=drop
otx.AddFlow("table=100, priority=0, actions=output:2")
otx.AddFlow("table=100, priority=%d,tcp,tcp_dst=53,nw_dst=%s,actions=output:2", osapi.EgressNetworkPolicyMaxRules+1, nodeIP)
otx.AddFlow("table=100, priority=%d,udp,udp_dst=53,nw_dst=%s,actions=output:2", osapi.EgressNetworkPolicyMaxRules+1, nodeIP)

// Table 110: outbound multicast filtering, updated by UpdateLocalMulticastFlows()
// eg, "table=110, priority=100, reg0=${tenant_id}, actions=goto_table:111
Expand Down
2 changes: 1 addition & 1 deletion pkg/sdn/plugin/ovscontroller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
func setup(t *testing.T) (ovs.Interface, *ovsController, []string) {
ovsif := ovs.NewFake(BR)
oc := NewOVSController(ovsif, 0, true)
err := oc.SetupOVS("10.128.0.0/14", "172.30.0.0/16", "10.128.0.0/23", "10.128.0.1")
err := oc.SetupOVS("10.128.0.0/14", "172.30.0.0/16", "10.128.0.0/23", "10.128.0.1", "172.17.0.4")
if err != nil {
t.Fatalf("Unexpected error setting up OVS: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/sdn/plugin/sdn_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (plugin *OsdnNode) SetupSDN() (bool, error) {
}
glog.V(5).Infof("[SDN setup] full SDN setup required")

err = plugin.oc.SetupOVS(clusterNetworkCIDR, serviceNetworkCIDR, localSubnetCIDR, localSubnetGateway)
err = plugin.oc.SetupOVS(clusterNetworkCIDR, serviceNetworkCIDR, localSubnetCIDR, localSubnetGateway, plugin.localIP)
if err != nil {
return false, err
}
Expand Down

0 comments on commit 74f0baf

Please sign in to comment.