aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/ip_gre.c
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@vyatta.com>2008-11-20 23:34:29 -0500
committerDavid S. Miller <davem@davemloft.net>2008-11-20 23:34:29 -0500
commitb8c26a33c8b6f0a150e9cb38ed80b890be55395c (patch)
treecc370525dab23ecbf131fa9a6a6b49fc8fa6af25 /net/ipv4/ip_gre.c
parent1326c3d5a4b792a2b15877feb7fb691f8945d203 (diff)
ipgre: convert to netdevice_ops
Convert ipgre tunnel to netdevice ops. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/ip_gre.c')
-rw-r--r--net/ipv4/ip_gre.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 191ef758813..bf5b338f134 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -126,8 +126,6 @@ static int ipgre_tunnel_bind_dev(struct net_device *dev);
126 126
127/* Fallback tunnel: no source, no destination, no key, no options */ 127/* Fallback tunnel: no source, no destination, no key, no options */
128 128
129static int ipgre_fb_tunnel_init(struct net_device *dev);
130
131#define HASH_SIZE 16 129#define HASH_SIZE 16
132 130
133static int ipgre_net_id; 131static int ipgre_net_id;
@@ -1142,6 +1140,7 @@ static int ipgre_open(struct net_device *dev)
1142static int ipgre_close(struct net_device *dev) 1140static int ipgre_close(struct net_device *dev)
1143{ 1141{
1144 struct ip_tunnel *t = netdev_priv(dev); 1142 struct ip_tunnel *t = netdev_priv(dev);
1143
1145 if (ipv4_is_multicast(t->parms.iph.daddr) && t->mlink) { 1144 if (ipv4_is_multicast(t->parms.iph.daddr) && t->mlink) {
1146 struct in_device *in_dev; 1145 struct in_device *in_dev;
1147 in_dev = inetdev_by_index(dev_net(dev), t->mlink); 1146 in_dev = inetdev_by_index(dev_net(dev), t->mlink);
@@ -1155,14 +1154,22 @@ static int ipgre_close(struct net_device *dev)
1155 1154
1156#endif 1155#endif
1157 1156
1157static 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
1158static void ipgre_tunnel_setup(struct net_device *dev) 1169static void ipgre_tunnel_setup(struct net_device *dev)
1159{ 1170{
1160 dev->init = ipgre_tunnel_init; 1171 dev->netdev_ops = &ipgre_netdev_ops;
1161 dev->uninit = ipgre_tunnel_uninit;
1162 dev->destructor = free_netdev; 1172 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;
1166 1173
1167 dev->type = ARPHRD_IPGRE; 1174 dev->type = ARPHRD_IPGRE;
1168 dev->needed_headroom = LL_MAX_HEADER + sizeof(struct iphdr) + 4; 1175 dev->needed_headroom = LL_MAX_HEADER + sizeof(struct iphdr) + 4;
@@ -1194,8 +1201,6 @@ static int ipgre_tunnel_init(struct net_device *dev)
1194 return -EINVAL; 1201 return -EINVAL;
1195 dev->flags = IFF_BROADCAST; 1202 dev->flags = IFF_BROADCAST;
1196 dev->header_ops = &ipgre_header_ops; 1203 dev->header_ops = &ipgre_header_ops;
1197 dev->open = ipgre_open;
1198 dev->stop = ipgre_close;
1199 } 1204 }
1200#endif 1205#endif
1201 } else 1206 } else
@@ -1204,7 +1209,7 @@ static int ipgre_tunnel_init(struct net_device *dev)
1204 return 0; 1209 return 0;
1205} 1210}
1206 1211
1207static int ipgre_fb_tunnel_init(struct net_device *dev) 1212static void ipgre_fb_tunnel_init(struct net_device *dev)
1208{ 1213{
1209 struct ip_tunnel *tunnel = netdev_priv(dev); 1214 struct ip_tunnel *tunnel = netdev_priv(dev);
1210 struct iphdr *iph = &tunnel->parms.iph; 1215 struct iphdr *iph = &tunnel->parms.iph;
@@ -1220,7 +1225,6 @@ static int ipgre_fb_tunnel_init(struct net_device *dev)
1220 1225
1221 dev_hold(dev); 1226 dev_hold(dev);
1222 ign->tunnels_wc[0] = tunnel; 1227 ign->tunnels_wc[0] = tunnel;
1223 return 0;
1224} 1228}
1225 1229
1226 1230
@@ -1265,7 +1269,7 @@ static int ipgre_init_net(struct net *net)
1265 goto err_alloc_dev; 1269 goto err_alloc_dev;
1266 } 1270 }
1267 1271
1268 ign->fb_tunnel_dev->init = ipgre_fb_tunnel_init; 1272 ipgre_fb_tunnel_init(ign->fb_tunnel_dev);
1269 dev_net_set(ign->fb_tunnel_dev, net); 1273 dev_net_set(ign->fb_tunnel_dev, net);
1270 ign->fb_tunnel_dev->rtnl_link_ops = &ipgre_link_ops; 1274 ign->fb_tunnel_dev->rtnl_link_ops = &ipgre_link_ops;
1271 1275
@@ -1397,16 +1401,22 @@ static int ipgre_tap_init(struct net_device *dev)
1397 return 0; 1401 return 0;
1398} 1402}
1399 1403
1404static 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
1400static void ipgre_tap_setup(struct net_device *dev) 1413static void ipgre_tap_setup(struct net_device *dev)
1401{ 1414{
1402 1415
1403 ether_setup(dev); 1416 ether_setup(dev);
1404 1417
1405 dev->init = ipgre_tap_init; 1418 dev->netdev_ops = &ipgre_netdev_ops;
1406 dev->uninit = ipgre_tunnel_uninit;
1407 dev->destructor = free_netdev; 1419 dev->destructor = free_netdev;
1408 dev->hard_start_xmit = ipgre_tunnel_xmit;
1409 dev->change_mtu = ipgre_tunnel_change_mtu;
1410 1420
1411 dev->iflink = 0; 1421 dev->iflink = 0;
1412 dev->features |= NETIF_F_NETNS_LOCAL; 1422 dev->features |= NETIF_F_NETNS_LOCAL;