@@ -110,6 +110,7 @@ struct vxlan_dev {
110
110
struct net_device * dev ;
111
111
struct vxlan_rdst default_dst ; /* default destination */
112
112
__be32 saddr ; /* source address */
113
+ __be16 dst_port ;
113
114
__u16 port_min ; /* source port range */
114
115
__u16 port_max ;
115
116
__u8 tos ; /* TOS override */
@@ -192,7 +193,7 @@ static int vxlan_fdb_info(struct sk_buff *skb, struct vxlan_dev *vxlan,
192
193
if (send_ip && nla_put_be32 (skb , NDA_DST , rdst -> remote_ip ))
193
194
goto nla_put_failure ;
194
195
195
- if (rdst -> remote_port && rdst -> remote_port != htons ( vxlan_port ) &&
196
+ if (rdst -> remote_port && rdst -> remote_port != vxlan -> dst_port &&
196
197
nla_put_be16 (skb , NDA_PORT , rdst -> remote_port ))
197
198
goto nla_put_failure ;
198
199
if (rdst -> remote_vni != vxlan -> default_dst .remote_vni &&
@@ -467,7 +468,7 @@ static int vxlan_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
467
468
return - EINVAL ;
468
469
port = nla_get_be16 (tb [NDA_PORT ]);
469
470
} else
470
- port = htons ( vxlan_port ) ;
471
+ port = vxlan -> dst_port ;
471
472
472
473
if (tb [NDA_VNI ]) {
473
474
if (nla_len (tb [NDA_VNI ]) != sizeof (u32 ))
@@ -579,7 +580,7 @@ static void vxlan_snoop(struct net_device *dev,
579
580
err = vxlan_fdb_create (vxlan , src_mac , src_ip ,
580
581
NUD_REACHABLE ,
581
582
NLM_F_EXCL |NLM_F_CREATE ,
582
- vxlan_port ,
583
+ vxlan -> dst_port ,
583
584
vxlan -> default_dst .remote_vni ,
584
585
0 , NTF_SELF );
585
586
spin_unlock (& vxlan -> hash_lock );
@@ -970,7 +971,7 @@ static netdev_tx_t vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
970
971
__be16 df = 0 ;
971
972
__u8 tos , ttl ;
972
973
973
- dst_port = rdst -> remote_port ? rdst -> remote_port : htons ( vxlan_port ) ;
974
+ dst_port = rdst -> remote_port ? rdst -> remote_port : vxlan -> dst_port ;
974
975
vni = rdst -> remote_vni ;
975
976
dst = rdst -> remote_ip ;
976
977
@@ -1314,6 +1315,7 @@ static void vxlan_setup(struct net_device *dev)
1314
1315
inet_get_local_port_range (& low , & high );
1315
1316
vxlan -> port_min = low ;
1316
1317
vxlan -> port_max = high ;
1318
+ vxlan -> dst_port = htons (vxlan_port );
1317
1319
1318
1320
vxlan -> dev = dev ;
1319
1321
@@ -1336,6 +1338,7 @@ static const struct nla_policy vxlan_policy[IFLA_VXLAN_MAX + 1] = {
1336
1338
[IFLA_VXLAN_RSC ] = { .type = NLA_U8 },
1337
1339
[IFLA_VXLAN_L2MISS ] = { .type = NLA_U8 },
1338
1340
[IFLA_VXLAN_L3MISS ] = { .type = NLA_U8 },
1341
+ [IFLA_VXLAN_PORT ] = { .type = NLA_U16 },
1339
1342
};
1340
1343
1341
1344
static int vxlan_validate (struct nlattr * tb [], struct nlattr * data [])
@@ -1465,6 +1468,9 @@ static int vxlan_newlink(struct net *net, struct net_device *dev,
1465
1468
vxlan -> port_max = ntohs (p -> high );
1466
1469
}
1467
1470
1471
+ if (data [IFLA_VXLAN_PORT ])
1472
+ vxlan -> dst_port = nla_get_be16 (data [IFLA_VXLAN_PORT ]);
1473
+
1468
1474
SET_ETHTOOL_OPS (dev , & vxlan_ethtool_ops );
1469
1475
1470
1476
err = register_netdevice (dev );
@@ -1500,6 +1506,7 @@ static size_t vxlan_get_size(const struct net_device *dev)
1500
1506
nla_total_size (sizeof (__u32 )) + /* IFLA_VXLAN_AGEING */
1501
1507
nla_total_size (sizeof (__u32 )) + /* IFLA_VXLAN_LIMIT */
1502
1508
nla_total_size (sizeof (struct ifla_vxlan_port_range )) +
1509
+ nla_total_size (sizeof (__be16 ))+ /* IFLA_VXLAN_PORT */
1503
1510
0 ;
1504
1511
}
1505
1512
@@ -1536,7 +1543,8 @@ static int vxlan_fill_info(struct sk_buff *skb, const struct net_device *dev)
1536
1543
nla_put_u8 (skb , IFLA_VXLAN_L3MISS ,
1537
1544
!!(vxlan -> flags & VXLAN_F_L3MISS )) ||
1538
1545
nla_put_u32 (skb , IFLA_VXLAN_AGEING , vxlan -> age_interval ) ||
1539
- nla_put_u32 (skb , IFLA_VXLAN_LIMIT , vxlan -> addrmax ))
1546
+ nla_put_u32 (skb , IFLA_VXLAN_LIMIT , vxlan -> addrmax ) ||
1547
+ nla_put_be16 (skb , IFLA_VXLAN_PORT , vxlan -> dst_port ))
1540
1548
goto nla_put_failure ;
1541
1549
1542
1550
if (nla_put (skb , IFLA_VXLAN_PORT_RANGE , sizeof (ports ), & ports ))
0 commit comments