mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
VXLAN port configuration - late review comments update
Some review comments came in very late after merging #2282. This PR addresses those review comments. Signed-off-by: selansen <elango.siva@docker.com>
This commit is contained in:
parent
077ccabc45
commit
56ca280b27
3 changed files with 11 additions and 9 deletions
|
@ -201,7 +201,7 @@ func removeEncryption(localIP, remoteIP net.IP, em *encrMap) error {
|
||||||
|
|
||||||
func programMangle(vni uint32, add bool) (err error) {
|
func programMangle(vni uint32, add bool) (err error) {
|
||||||
var (
|
var (
|
||||||
p = strconv.FormatUint(uint64(overlayutils.GetVxlanUDPPort()), 10)
|
p = strconv.FormatUint(uint64(overlayutils.VXLANUDPPort()), 10)
|
||||||
c = fmt.Sprintf("0>>22&0x3C@12&0xFFFFFF00=%d", int(vni)<<8)
|
c = fmt.Sprintf("0>>22&0x3C@12&0xFFFFFF00=%d", int(vni)<<8)
|
||||||
m = strconv.FormatUint(uint64(r), 10)
|
m = strconv.FormatUint(uint64(r), 10)
|
||||||
chain = "OUTPUT"
|
chain = "OUTPUT"
|
||||||
|
@ -228,7 +228,7 @@ func programMangle(vni uint32, add bool) (err error) {
|
||||||
|
|
||||||
func programInput(vni uint32, add bool) (err error) {
|
func programInput(vni uint32, add bool) (err error) {
|
||||||
var (
|
var (
|
||||||
port = strconv.FormatUint(uint64(overlayutils.GetVxlanUDPPort()), 10)
|
port = strconv.FormatUint(uint64(overlayutils.VXLANUDPPort()), 10)
|
||||||
vniMatch = fmt.Sprintf("0>>22&0x3C@12&0xFFFFFF00=%d", int(vni)<<8)
|
vniMatch = fmt.Sprintf("0>>22&0x3C@12&0xFFFFFF00=%d", int(vni)<<8)
|
||||||
plainVxlan = []string{"-p", "udp", "--dport", port, "-m", "u32", "--u32", vniMatch, "-j"}
|
plainVxlan = []string{"-p", "udp", "--dport", port, "-m", "u32", "--u32", vniMatch, "-j"}
|
||||||
ipsecVxlan = append([]string{"-m", "policy", "--dir", "in", "--pol", "ipsec"}, plainVxlan...)
|
ipsecVxlan = append([]string{"-m", "policy", "--dir", "in", "--pol", "ipsec"}, plainVxlan...)
|
||||||
|
|
|
@ -62,7 +62,7 @@ func createVxlan(name string, vni uint32, mtu int) error {
|
||||||
LinkAttrs: netlink.LinkAttrs{Name: name, MTU: mtu},
|
LinkAttrs: netlink.LinkAttrs{Name: name, MTU: mtu},
|
||||||
VxlanId: int(vni),
|
VxlanId: int(vni),
|
||||||
Learning: true,
|
Learning: true,
|
||||||
Port: int(overlayutils.GetVxlanUDPPort()),
|
Port: int(overlayutils.VXLANUDPPort()),
|
||||||
Proxy: true,
|
Proxy: true,
|
||||||
L3miss: true,
|
L3miss: true,
|
||||||
L2miss: true,
|
L2miss: true,
|
||||||
|
|
|
@ -11,17 +11,19 @@ var (
|
||||||
mutex sync.Mutex
|
mutex sync.Mutex
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const defaultVXLANUDPPort = 4789
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
vxlanUDPPort = 4789
|
vxlanUDPPort = defaultVXLANUDPPort
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConfigVxlanUDPPort configures vxlan udp port number.
|
// ConfigVXLANUDPPort configures vxlan udp port number.
|
||||||
func ConfigVxlanUDPPort(vxlanPort uint32) error {
|
func ConfigVXLANUDPPort(vxlanPort uint32) error {
|
||||||
mutex.Lock()
|
mutex.Lock()
|
||||||
defer mutex.Unlock()
|
defer mutex.Unlock()
|
||||||
// if the value comes as 0 by any reason we set it to default value 4789
|
// if the value comes as 0 by any reason we set it to default value 4789
|
||||||
if vxlanPort == 0 {
|
if vxlanPort == 0 {
|
||||||
vxlanPort = 4789
|
vxlanPort = defaultVXLANUDPPort
|
||||||
}
|
}
|
||||||
// IANA procedures for each range in detail
|
// IANA procedures for each range in detail
|
||||||
// The Well Known Ports, aka the System Ports, from 0-1023
|
// The Well Known Ports, aka the System Ports, from 0-1023
|
||||||
|
@ -36,8 +38,8 @@ func ConfigVxlanUDPPort(vxlanPort uint32) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetVxlanUDPPort returns Vxlan UDP port number
|
// VXLANUDPPort returns Vxlan UDP port number
|
||||||
func GetVxlanUDPPort() uint32 {
|
func VXLANUDPPort() uint32 {
|
||||||
mutex.Lock()
|
mutex.Lock()
|
||||||
defer mutex.Unlock()
|
defer mutex.Unlock()
|
||||||
return vxlanUDPPort
|
return vxlanUDPPort
|
||||||
|
|
Loading…
Add table
Reference in a new issue