From: Stephen Hemminger <shemminger@vyatta.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: [PATCH 9/9] ipgre: convert to netdevice_ops
Date: Thu, 20 Nov 2008 09:59:22 -0800 [thread overview]
Message-ID: <20081120175934.301212308@vyatta.com> (raw)
In-Reply-To: 20081120175913.943543638@vyatta.com
[-- Attachment #1: ipgre-netdev_ops.patch --]
[-- Type: text/plain, Size: 3340 bytes --]
Convert ipgre tunnel to netdevice ops.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/net/ipv4/ip_gre.c 2008-11-20 09:49:13.000000000 -0800
+++ b/net/ipv4/ip_gre.c 2008-11-20 09:56:39.000000000 -0800
@@ -126,8 +126,6 @@ static int ipgre_tunnel_bind_dev(struct
/* Fallback tunnel: no source, no destination, no key, no options */
-static int ipgre_fb_tunnel_init(struct net_device *dev);
-
#define HASH_SIZE 16
static int ipgre_net_id;
@@ -1142,6 +1140,7 @@ static int ipgre_open(struct net_device
static int ipgre_close(struct net_device *dev)
{
struct ip_tunnel *t = netdev_priv(dev);
+
if (ipv4_is_multicast(t->parms.iph.daddr) && t->mlink) {
struct in_device *in_dev;
in_dev = inetdev_by_index(dev_net(dev), t->mlink);
@@ -1155,14 +1154,22 @@ static int ipgre_close(struct net_device
#endif
+static const struct net_device_ops ipgre_netdev_ops = {
+ .ndo_init = ipgre_tunnel_init,
+ .ndo_uninit = ipgre_tunnel_uninit,
+#ifdef CONFIG_NET_IPGRE_BROADCAST
+ .ndo_open = ipgre_open,
+ .ndo_stop = ipgre_close,
+#endif
+ .ndo_start_xmit = ipgre_tunnel_xmit,
+ .ndo_do_ioctl = ipgre_tunnel_ioctl,
+ .ndo_change_mtu = ipgre_tunnel_change_mtu,
+};
+
static void ipgre_tunnel_setup(struct net_device *dev)
{
- dev->init = ipgre_tunnel_init;
- dev->uninit = ipgre_tunnel_uninit;
+ dev->netdev_ops = &ipgre_netdev_ops;
dev->destructor = free_netdev;
- dev->hard_start_xmit = ipgre_tunnel_xmit;
- dev->do_ioctl = ipgre_tunnel_ioctl;
- dev->change_mtu = ipgre_tunnel_change_mtu;
dev->type = ARPHRD_IPGRE;
dev->needed_headroom = LL_MAX_HEADER + sizeof(struct iphdr) + 4;
@@ -1194,8 +1201,6 @@ static int ipgre_tunnel_init(struct net_
return -EINVAL;
dev->flags = IFF_BROADCAST;
dev->header_ops = &ipgre_header_ops;
- dev->open = ipgre_open;
- dev->stop = ipgre_close;
}
#endif
} else
@@ -1204,7 +1209,7 @@ static int ipgre_tunnel_init(struct net_
return 0;
}
-static int ipgre_fb_tunnel_init(struct net_device *dev)
+static void ipgre_fb_tunnel_init(struct net_device *dev)
{
struct ip_tunnel *tunnel = netdev_priv(dev);
struct iphdr *iph = &tunnel->parms.iph;
@@ -1220,7 +1225,6 @@ static int ipgre_fb_tunnel_init(struct n
dev_hold(dev);
ign->tunnels_wc[0] = tunnel;
- return 0;
}
@@ -1265,7 +1269,7 @@ static int ipgre_init_net(struct net *ne
goto err_alloc_dev;
}
- ign->fb_tunnel_dev->init = ipgre_fb_tunnel_init;
+ ipgre_fb_tunnel_init(ign->fb_tunnel_dev);
dev_net_set(ign->fb_tunnel_dev, net);
ign->fb_tunnel_dev->rtnl_link_ops = &ipgre_link_ops;
@@ -1397,16 +1401,22 @@ static int ipgre_tap_init(struct net_dev
return 0;
}
+static const struct net_device_ops ipgre_tap_netdev_ops = {
+ .ndo_init = ipgre_tap_init,
+ .ndo_uninit = ipgre_tunnel_uninit,
+ .ndo_start_xmit = ipgre_tunnel_xmit,
+ .ndo_set_mac_address = eth_mac_addr,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_change_mtu = ipgre_tunnel_change_mtu,
+};
+
static void ipgre_tap_setup(struct net_device *dev)
{
ether_setup(dev);
- dev->init = ipgre_tap_init;
- dev->uninit = ipgre_tunnel_uninit;
+ dev->netdev_ops = &ipgre_netdev_ops;
dev->destructor = free_netdev;
- dev->hard_start_xmit = ipgre_tunnel_xmit;
- dev->change_mtu = ipgre_tunnel_change_mtu;
dev->iflink = 0;
dev->features |= NETIF_F_NETNS_LOCAL;
--
next prev parent reply other threads:[~2008-11-20 18:04 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-20 17:59 [PATCH 0/9] Netdevice ops second wave Stephen Hemminger
2008-11-20 17:59 ` [PATCH 1/9] netdev: add more functions to netdevice ops Stephen Hemminger
2008-11-21 4:27 ` David Miller
2008-11-20 17:59 ` [PATCH 2/9] dummy: convert to net_device_ops Stephen Hemminger
2008-11-21 4:28 ` David Miller
2008-11-20 17:59 ` [PATCH 3/9] ipmr: convert ipmr virtual interface " Stephen Hemminger
2008-11-21 4:29 ` David Miller
2008-11-20 17:59 ` [PATCH 4/9] fddi: convert to new network device ops Stephen Hemminger
2008-11-21 4:31 ` David Miller
2008-11-20 17:59 ` [PATCH 5/9] defxx: convert driver to net_device_ops Stephen Hemminger
2008-11-21 4:31 ` David Miller
2008-11-20 17:59 ` [PATCH 6/9] hippi: " Stephen Hemminger
2008-11-21 4:32 ` David Miller
2008-11-20 17:59 ` [PATCH 7/9] ipip: convert " Stephen Hemminger
2008-11-21 4:33 ` David Miller
2008-11-20 17:59 ` [PATCH 8/9] ipv6: convert tunnels " Stephen Hemminger
2008-11-21 4:34 ` David Miller
2008-11-20 17:59 ` Stephen Hemminger [this message]
2008-11-21 4:34 ` [PATCH 9/9] ipgre: convert to netdevice_ops David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081120175934.301212308@vyatta.com \
--to=shemminger@vyatta.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.