Skip to content

Commit 1326c3d

Browse files
Stephen Hemmingerdavem330
authored andcommitted
ipv6: convert tunnels to net_device_ops
Like IPV4, convert the tunnel virtual devices to use net_device_ops. Signed-off-by: Stephen Hemminger <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 23a12b1 commit 1326c3d

File tree

2 files changed

+32
-30
lines changed

2 files changed

+32
-30
lines changed

net/ipv6/ip6_tunnel.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ MODULE_LICENSE("GPL");
7474
(addr)->s6_addr32[2] ^ (addr)->s6_addr32[3]) & \
7575
(HASH_SIZE - 1))
7676

77-
static int ip6_fb_tnl_dev_init(struct net_device *dev);
78-
static int ip6_tnl_dev_init(struct net_device *dev);
77+
static void ip6_fb_tnl_dev_init(struct net_device *dev);
78+
static void ip6_tnl_dev_init(struct net_device *dev);
7979
static void ip6_tnl_dev_setup(struct net_device *dev);
8080

8181
static int ip6_tnl_net_id;
@@ -249,7 +249,7 @@ static struct ip6_tnl *ip6_tnl_create(struct net *net, struct ip6_tnl_parm *p)
249249
}
250250

251251
t = netdev_priv(dev);
252-
dev->init = ip6_tnl_dev_init;
252+
ip6_tnl_dev_init(dev);
253253
t->parms = *p;
254254

255255
if ((err = register_netdevice(dev)) < 0)
@@ -1306,6 +1306,14 @@ ip6_tnl_change_mtu(struct net_device *dev, int new_mtu)
13061306
return 0;
13071307
}
13081308

1309+
1310+
static const struct net_device_ops ip6_tnl_netdev_ops = {
1311+
.ndo_uninit = ip6_tnl_dev_uninit,
1312+
.ndo_start_xmit = ip6_tnl_xmit,
1313+
.ndo_do_ioctl = ip6_tnl_ioctl,
1314+
.ndo_change_mtu = ip6_tnl_change_mtu,
1315+
};
1316+
13091317
/**
13101318
* ip6_tnl_dev_setup - setup virtual tunnel device
13111319
* @dev: virtual device associated with tunnel
@@ -1316,11 +1324,8 @@ ip6_tnl_change_mtu(struct net_device *dev, int new_mtu)
13161324

13171325
static void ip6_tnl_dev_setup(struct net_device *dev)
13181326
{
1319-
dev->uninit = ip6_tnl_dev_uninit;
1327+
dev->netdev_ops = &ip6_tnl_netdev_ops;
13201328
dev->destructor = free_netdev;
1321-
dev->hard_start_xmit = ip6_tnl_xmit;
1322-
dev->do_ioctl = ip6_tnl_ioctl;
1323-
dev->change_mtu = ip6_tnl_change_mtu;
13241329

13251330
dev->type = ARPHRD_TUNNEL6;
13261331
dev->hard_header_len = LL_MAX_HEADER + sizeof (struct ipv6hdr);
@@ -1349,13 +1354,11 @@ ip6_tnl_dev_init_gen(struct net_device *dev)
13491354
* @dev: virtual device associated with tunnel
13501355
**/
13511356

1352-
static int
1353-
ip6_tnl_dev_init(struct net_device *dev)
1357+
static void ip6_tnl_dev_init(struct net_device *dev)
13541358
{
13551359
struct ip6_tnl *t = netdev_priv(dev);
13561360
ip6_tnl_dev_init_gen(dev);
13571361
ip6_tnl_link_config(t);
1358-
return 0;
13591362
}
13601363

13611364
/**
@@ -1365,8 +1368,7 @@ ip6_tnl_dev_init(struct net_device *dev)
13651368
* Return: 0
13661369
**/
13671370

1368-
static int
1369-
ip6_fb_tnl_dev_init(struct net_device *dev)
1371+
static void ip6_fb_tnl_dev_init(struct net_device *dev)
13701372
{
13711373
struct ip6_tnl *t = netdev_priv(dev);
13721374
struct net *net = dev_net(dev);
@@ -1376,7 +1378,6 @@ ip6_fb_tnl_dev_init(struct net_device *dev)
13761378
t->parms.proto = IPPROTO_IPV6;
13771379
dev_hold(dev);
13781380
ip6n->tnls_wc[0] = t;
1379-
return 0;
13801381
}
13811382

13821383
static struct xfrm6_tunnel ip4ip6_handler = {
@@ -1429,7 +1430,7 @@ static int ip6_tnl_init_net(struct net *net)
14291430
if (!ip6n->fb_tnl_dev)
14301431
goto err_alloc_dev;
14311432

1432-
ip6n->fb_tnl_dev->init = ip6_fb_tnl_dev_init;
1433+
ip6_fb_tnl_dev_init(ip6n->fb_tnl_dev);
14331434
dev_net_set(ip6n->fb_tnl_dev, net);
14341435

14351436
err = register_netdev(ip6n->fb_tnl_dev);

net/ipv6/sit.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@
6262
#define HASH_SIZE 16
6363
#define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&0xF)
6464

65-
static int ipip6_fb_tunnel_init(struct net_device *dev);
66-
static int ipip6_tunnel_init(struct net_device *dev);
65+
static void ipip6_fb_tunnel_init(struct net_device *dev);
66+
static void ipip6_tunnel_init(struct net_device *dev);
6767
static void ipip6_tunnel_setup(struct net_device *dev);
6868

6969
static int sit_net_id;
@@ -188,7 +188,8 @@ static struct ip_tunnel * ipip6_tunnel_locate(struct net *net,
188188
}
189189

190190
nt = netdev_priv(dev);
191-
dev->init = ipip6_tunnel_init;
191+
ipip6_tunnel_init(dev);
192+
192193
nt->parms = *parms;
193194

194195
if (parms->i_flags & SIT_ISATAP)
@@ -926,13 +927,17 @@ static int ipip6_tunnel_change_mtu(struct net_device *dev, int new_mtu)
926927
return 0;
927928
}
928929

930+
static const struct net_device_ops ipip6_netdev_ops = {
931+
.ndo_uninit = ipip6_tunnel_uninit,
932+
.ndo_start_xmit = ipip6_tunnel_xmit,
933+
.ndo_do_ioctl = ipip6_tunnel_ioctl,
934+
.ndo_change_mtu = ipip6_tunnel_change_mtu,
935+
};
936+
929937
static void ipip6_tunnel_setup(struct net_device *dev)
930938
{
931-
dev->uninit = ipip6_tunnel_uninit;
939+
dev->netdev_ops = &ipip6_netdev_ops;
932940
dev->destructor = free_netdev;
933-
dev->hard_start_xmit = ipip6_tunnel_xmit;
934-
dev->do_ioctl = ipip6_tunnel_ioctl;
935-
dev->change_mtu = ipip6_tunnel_change_mtu;
936941

937942
dev->type = ARPHRD_SIT;
938943
dev->hard_header_len = LL_MAX_HEADER + sizeof(struct iphdr);
@@ -943,11 +948,9 @@ static void ipip6_tunnel_setup(struct net_device *dev)
943948
dev->features |= NETIF_F_NETNS_LOCAL;
944949
}
945950

946-
static int ipip6_tunnel_init(struct net_device *dev)
951+
static void ipip6_tunnel_init(struct net_device *dev)
947952
{
948-
struct ip_tunnel *tunnel;
949-
950-
tunnel = netdev_priv(dev);
953+
struct ip_tunnel *tunnel = netdev_priv(dev);
951954

952955
tunnel->dev = dev;
953956
strcpy(tunnel->parms.name, dev->name);
@@ -956,11 +959,9 @@ static int ipip6_tunnel_init(struct net_device *dev)
956959
memcpy(dev->broadcast, &tunnel->parms.iph.daddr, 4);
957960

958961
ipip6_tunnel_bind_dev(dev);
959-
960-
return 0;
961962
}
962963

963-
static int ipip6_fb_tunnel_init(struct net_device *dev)
964+
static void ipip6_fb_tunnel_init(struct net_device *dev)
964965
{
965966
struct ip_tunnel *tunnel = netdev_priv(dev);
966967
struct iphdr *iph = &tunnel->parms.iph;
@@ -977,7 +978,6 @@ static int ipip6_fb_tunnel_init(struct net_device *dev)
977978

978979
dev_hold(dev);
979980
sitn->tunnels_wc[0] = tunnel;
980-
return 0;
981981
}
982982

983983
static struct xfrm_tunnel sit_handler = {
@@ -1026,7 +1026,7 @@ static int sit_init_net(struct net *net)
10261026
goto err_alloc_dev;
10271027
}
10281028

1029-
sitn->fb_tunnel_dev->init = ipip6_fb_tunnel_init;
1029+
ipip6_fb_tunnel_init(sitn->fb_tunnel_dev);
10301030
dev_net_set(sitn->fb_tunnel_dev, net);
10311031

10321032
if ((err = register_netdev(sitn->fb_tunnel_dev)))
@@ -1035,6 +1035,7 @@ static int sit_init_net(struct net *net)
10351035
return 0;
10361036

10371037
err_reg_dev:
1038+
dev_put(sitn->fb_tunnel_dev);
10381039
free_netdev(sitn->fb_tunnel_dev);
10391040
err_alloc_dev:
10401041
/* nothing */

0 commit comments

Comments
 (0)