1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #2300 from selansen/master

VXLAN port configuration - late review comments update
This commit is contained in:
Flavio Crisciani 2018-11-15 08:25:45 -07:00 committed by GitHub
commit 7667c0a4b2
3 changed files with 11 additions and 9 deletions

View file

@ -201,7 +201,7 @@ func removeEncryption(localIP, remoteIP net.IP, em *encrMap) error {
func programMangle(vni uint32, add bool) (err error) {
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)
m = strconv.FormatUint(uint64(r), 10)
chain = "OUTPUT"
@ -228,7 +228,7 @@ func programMangle(vni uint32, add bool) (err error) {
func programInput(vni uint32, add bool) (err error) {
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)
plainVxlan = []string{"-p", "udp", "--dport", port, "-m", "u32", "--u32", vniMatch, "-j"}
ipsecVxlan = append([]string{"-m", "policy", "--dir", "in", "--pol", "ipsec"}, plainVxlan...)

View file

@ -62,7 +62,7 @@ func createVxlan(name string, vni uint32, mtu int) error {
LinkAttrs: netlink.LinkAttrs{Name: name, MTU: mtu},
VxlanId: int(vni),
Learning: true,
Port: int(overlayutils.GetVxlanUDPPort()),
Port: int(overlayutils.VXLANUDPPort()),
Proxy: true,
L3miss: true,
L2miss: true,

View file

@ -11,17 +11,19 @@ var (
mutex sync.Mutex
)
const defaultVXLANUDPPort = 4789
func init() {
vxlanUDPPort = 4789
vxlanUDPPort = defaultVXLANUDPPort
}
// ConfigVxlanUDPPort configures vxlan udp port number.
func ConfigVxlanUDPPort(vxlanPort uint32) error {
// ConfigVXLANUDPPort configures vxlan udp port number.
func ConfigVXLANUDPPort(vxlanPort uint32) error {
mutex.Lock()
defer mutex.Unlock()
// if the value comes as 0 by any reason we set it to default value 4789
if vxlanPort == 0 {
vxlanPort = 4789
vxlanPort = defaultVXLANUDPPort
}
// IANA procedures for each range in detail
// The Well Known Ports, aka the System Ports, from 0-1023
@ -36,8 +38,8 @@ func ConfigVxlanUDPPort(vxlanPort uint32) error {
return nil
}
// GetVxlanUDPPort returns Vxlan UDP port number
func GetVxlanUDPPort() uint32 {
// VXLANUDPPort returns Vxlan UDP port number
func VXLANUDPPort() uint32 {
mutex.Lock()
defer mutex.Unlock()
return vxlanUDPPort