Skip to content

Commit 0c867c9

Browse files
Jiri Bencdavem330
authored andcommitted
vxlan: move Ethernet initialization to a separate function
This will allow to initialize vxlan in ARPHRD_NONE mode based on the passed rtnl attributes. v2: renamed "l2mode" to "ether". Signed-off-by: Jiri Benc <jbenc@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8a21ec4 commit 0c867c9

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

drivers/net/vxlan.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2404,7 +2404,7 @@ static int vxlan_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)
24042404
return 0;
24052405
}
24062406

2407-
static const struct net_device_ops vxlan_netdev_ops = {
2407+
static const struct net_device_ops vxlan_netdev_ether_ops = {
24082408
.ndo_init = vxlan_init,
24092409
.ndo_uninit = vxlan_uninit,
24102410
.ndo_open = vxlan_open,
@@ -2458,10 +2458,6 @@ static void vxlan_setup(struct net_device *dev)
24582458
struct vxlan_dev *vxlan = netdev_priv(dev);
24592459
unsigned int h;
24602460

2461-
eth_hw_addr_random(dev);
2462-
ether_setup(dev);
2463-
2464-
dev->netdev_ops = &vxlan_netdev_ops;
24652461
dev->destructor = free_netdev;
24662462
SET_NETDEV_DEVTYPE(dev, &vxlan_type);
24672463

@@ -2476,8 +2472,7 @@ static void vxlan_setup(struct net_device *dev)
24762472
dev->hw_features |= NETIF_F_GSO_SOFTWARE;
24772473
dev->hw_features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX;
24782474
netif_keep_dst(dev);
2479-
dev->priv_flags &= ~IFF_TX_SKB_SHARING;
2480-
dev->priv_flags |= IFF_LIVE_ADDR_CHANGE | IFF_NO_QUEUE;
2475+
dev->priv_flags |= IFF_NO_QUEUE;
24812476

24822477
INIT_LIST_HEAD(&vxlan->next);
24832478
spin_lock_init(&vxlan->hash_lock);
@@ -2496,6 +2491,15 @@ static void vxlan_setup(struct net_device *dev)
24962491
INIT_HLIST_HEAD(&vxlan->fdb_head[h]);
24972492
}
24982493

2494+
static void vxlan_ether_setup(struct net_device *dev)
2495+
{
2496+
eth_hw_addr_random(dev);
2497+
ether_setup(dev);
2498+
dev->priv_flags &= ~IFF_TX_SKB_SHARING;
2499+
dev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
2500+
dev->netdev_ops = &vxlan_netdev_ether_ops;
2501+
}
2502+
24992503
static const struct nla_policy vxlan_policy[IFLA_VXLAN_MAX + 1] = {
25002504
[IFLA_VXLAN_ID] = { .type = NLA_U32 },
25012505
[IFLA_VXLAN_GROUP] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
@@ -2722,6 +2726,8 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev,
27222726
__be16 default_port = vxlan->cfg.dst_port;
27232727
struct net_device *lowerdev = NULL;
27242728

2729+
vxlan_ether_setup(dev);
2730+
27252731
vxlan->net = src_net;
27262732

27272733
dst->remote_vni = conf->vni;

0 commit comments

Comments
 (0)