@@ -9,8 +9,23 @@ import (
99 "github.com/Azure/azure-container-networking/platform"
1010)
1111
12+ /*RFC For Private Address Space: https://tools.ietf.org/html/rfc1918
13+ The Internet Assigned Numbers Authority (IANA) has reserved the
14+ following three blocks of the IP address space for private internets:
15+
16+ 10.0.0.0 - 10.255.255.255 (10/8 prefix)
17+ 172.16.0.0 - 172.31.255.255 (172.16/12 prefix)
18+ 192.168.0.0 - 192.168.255.255 (192.168/16 prefix)
19+
20+ RFC for Link Local Addresses: https://tools.ietf.org/html/rfc3927
21+ This document describes how a host may
22+ automatically configure an interface with an IPv4 address within the
23+ 169.254/16 prefix that is valid for communication with other devices
24+ connected to the same physical (or logical) link.
25+ */
26+
1227func getPrivateIPSpace () []string {
13- privateIPAddresses := []string {"10.0.0.0/8" , "172.16.0.0/12" , "192.168.0.0/16" }
28+ privateIPAddresses := []string {"10.0.0.0/8" , "172.16.0.0/12" , "192.168.0.0/16" , "169.254.0.0/16" }
1429 return privateIPAddresses
1530}
1631
@@ -82,22 +97,29 @@ func AssignIPToInterface(interfaceName string, ipAddresses []net.IPNet) error {
8297}
8398
8499func addOrDeleteFilterRule (bridgeName string , action string , ipAddress string , chainName string , target string ) error {
100+ var cmd string
85101 option := "i"
86102
87103 if chainName == "OUTPUT" {
88104 option = "o"
89105 }
90106
91107 if action != "D" {
92- cmd : = fmt .Sprintf ("iptables -t filter -C %v -%v %v -d %v -j %v" , chainName , option , bridgeName , ipAddress , target )
108+ cmd = fmt .Sprintf ("iptables -t filter -C %v -%v %v -d %v -j %v" , chainName , option , bridgeName , ipAddress , target )
93109 _ , err := platform .ExecuteCommand (cmd )
94110 if err == nil {
95111 log .Printf ("Iptable filter for private ipaddr %v on %v chain %v target rule already exists" , ipAddress , chainName , target )
96112 return nil
97113 }
98114 }
99115
100- cmd := fmt .Sprintf ("iptables -t filter -%v %v -%v %v -d %v -j %v" , action , chainName , option , bridgeName , ipAddress , target )
116+ if target != "ACCEPT" {
117+ cmd = fmt .Sprintf ("iptables -t filter -%v %v -%v %v -d %v -j %v" , action , chainName , option , bridgeName , ipAddress , target )
118+ } else {
119+ action = "I"
120+ cmd = fmt .Sprintf ("iptables -t filter -%v %v 1 -%v %v -d %v -j %v" , action , chainName , option , bridgeName , ipAddress , target )
121+ }
122+
101123 _ , err := platform .ExecuteCommand (cmd )
102124 if err != nil {
103125 log .Printf ("Iptable filter %v action for private ipaddr %v on %v chain %v target failed with %v" , action , ipAddress , chainName , target , err )
0 commit comments