Skip to content

Commit b8c26a3

Browse files
Stephen Hemmingerdavem330
authored andcommitted
ipgre: convert to netdevice_ops
Convert ipgre tunnel to netdevice ops. Signed-off-by: Stephen Hemminger <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1326c3d commit b8c26a3

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

net/ipv4/ip_gre.c

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@ static int ipgre_tunnel_bind_dev(struct net_device *dev);
126126

127127
/* Fallback tunnel: no source, no destination, no key, no options */
128128

129-
static int ipgre_fb_tunnel_init(struct net_device *dev);
130-
131129
#define HASH_SIZE 16
132130

133131
static int ipgre_net_id;
@@ -1142,6 +1140,7 @@ static int ipgre_open(struct net_device *dev)
11421140
static int ipgre_close(struct net_device *dev)
11431141
{
11441142
struct ip_tunnel *t = netdev_priv(dev);
1143+
11451144
if (ipv4_is_multicast(t->parms.iph.daddr) && t->mlink) {
11461145
struct in_device *in_dev;
11471146
in_dev = inetdev_by_index(dev_net(dev), t->mlink);
@@ -1155,14 +1154,22 @@ static int ipgre_close(struct net_device *dev)
11551154

11561155
#endif
11571156

1157+
static const struct net_device_ops ipgre_netdev_ops = {
1158+
.ndo_init = ipgre_tunnel_init,
1159+
.ndo_uninit = ipgre_tunnel_uninit,
1160+
#ifdef CONFIG_NET_IPGRE_BROADCAST
1161+
.ndo_open = ipgre_open,
1162+
.ndo_stop = ipgre_close,
1163+
#endif
1164+
.ndo_start_xmit = ipgre_tunnel_xmit,
1165+
.ndo_do_ioctl = ipgre_tunnel_ioctl,
1166+
.ndo_change_mtu = ipgre_tunnel_change_mtu,
1167+
};
1168+
11581169
static void ipgre_tunnel_setup(struct net_device *dev)
11591170
{
1160-
dev->init = ipgre_tunnel_init;
1161-
dev->uninit = ipgre_tunnel_uninit;
1171+
dev->netdev_ops = &ipgre_netdev_ops;
11621172
dev->destructor = free_netdev;
1163-
dev->hard_start_xmit = ipgre_tunnel_xmit;
1164-
dev->do_ioctl = ipgre_tunnel_ioctl;
1165-
dev->change_mtu = ipgre_tunnel_change_mtu;
11661173

11671174
dev->type = ARPHRD_IPGRE;
11681175
dev->needed_headroom = LL_MAX_HEADER + sizeof(struct iphdr) + 4;
@@ -1194,8 +1201,6 @@ static int ipgre_tunnel_init(struct net_device *dev)
11941201
return -EINVAL;
11951202
dev->flags = IFF_BROADCAST;
11961203
dev->header_ops = &ipgre_header_ops;
1197-
dev->open = ipgre_open;
1198-
dev->stop = ipgre_close;
11991204
}
12001205
#endif
12011206
} else
@@ -1204,7 +1209,7 @@ static int ipgre_tunnel_init(struct net_device *dev)
12041209
return 0;
12051210
}
12061211

1207-
static int ipgre_fb_tunnel_init(struct net_device *dev)
1212+
static void ipgre_fb_tunnel_init(struct net_device *dev)
12081213
{
12091214
struct ip_tunnel *tunnel = netdev_priv(dev);
12101215
struct iphdr *iph = &tunnel->parms.iph;
@@ -1220,7 +1225,6 @@ static int ipgre_fb_tunnel_init(struct net_device *dev)
12201225

12211226
dev_hold(dev);
12221227
ign->tunnels_wc[0] = tunnel;
1223-
return 0;
12241228
}
12251229

12261230

@@ -1265,7 +1269,7 @@ static int ipgre_init_net(struct net *net)
12651269
goto err_alloc_dev;
12661270
}
12671271

1268-
ign->fb_tunnel_dev->init = ipgre_fb_tunnel_init;
1272+
ipgre_fb_tunnel_init(ign->fb_tunnel_dev);
12691273
dev_net_set(ign->fb_tunnel_dev, net);
12701274
ign->fb_tunnel_dev->rtnl_link_ops = &ipgre_link_ops;
12711275

@@ -1397,16 +1401,22 @@ static int ipgre_tap_init(struct net_device *dev)
13971401
return 0;
13981402
}
13991403

1404+
static const struct net_device_ops ipgre_tap_netdev_ops = {
1405+
.ndo_init = ipgre_tap_init,
1406+
.ndo_uninit = ipgre_tunnel_uninit,
1407+
.ndo_start_xmit = ipgre_tunnel_xmit,
1408+
.ndo_set_mac_address = eth_mac_addr,
1409+
.ndo_validate_addr = eth_validate_addr,
1410+
.ndo_change_mtu = ipgre_tunnel_change_mtu,
1411+
};
1412+
14001413
static void ipgre_tap_setup(struct net_device *dev)
14011414
{
14021415

14031416
ether_setup(dev);
14041417

1405-
dev->init = ipgre_tap_init;
1406-
dev->uninit = ipgre_tunnel_uninit;
1418+
dev->netdev_ops = &ipgre_netdev_ops;
14071419
dev->destructor = free_netdev;
1408-
dev->hard_start_xmit = ipgre_tunnel_xmit;
1409-
dev->change_mtu = ipgre_tunnel_change_mtu;
14101420

14111421
dev->iflink = 0;
14121422
dev->features |= NETIF_F_NETNS_LOCAL;

0 commit comments

Comments
 (0)