netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: [PATCH 7/9] ipip: convert to net_device_ops
Date: Thu, 20 Nov 2008 09:59:20 -0800	[thread overview]
Message-ID: <20081120175934.092348986@vyatta.com> (raw)
In-Reply-To: 20081120175913.943543638@vyatta.com

[-- Attachment #1: ipip-netdev_ops.patch --]
[-- Type: text/plain, Size: 2849 bytes --]

Convert to network device ops. Needed to change to directly call
the init routine since two sides share same ops.  In the process
found by inspection a device ref count leak if register_netdevice failed.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>


--- a/net/ipv4/ipip.c	2008-11-20 09:41:54.000000000 -0800
+++ b/net/ipv4/ipip.c	2008-11-20 09:47:10.000000000 -0800
@@ -130,8 +130,8 @@ struct ipip_net {
 	struct net_device *fb_tunnel_dev;
 };
 
-static int ipip_fb_tunnel_init(struct net_device *dev);
-static int ipip_tunnel_init(struct net_device *dev);
+static void ipip_fb_tunnel_init(struct net_device *dev);
+static void ipip_tunnel_init(struct net_device *dev);
 static void ipip_tunnel_setup(struct net_device *dev);
 
 static DEFINE_RWLOCK(ipip_lock);
@@ -245,9 +245,10 @@ static struct ip_tunnel * ipip_tunnel_lo
 	}
 
 	nt = netdev_priv(dev);
-	dev->init = ipip_tunnel_init;
 	nt->parms = *parms;
 
+	ipip_tunnel_init(dev);
+
 	if (register_netdevice(dev) < 0)
 		goto failed_free;
 
@@ -691,12 +692,17 @@ static int ipip_tunnel_change_mtu(struct
 	return 0;
 }
 
+static const struct net_device_ops ipip_netdev_ops = {
+	.ndo_uninit	= ipip_tunnel_uninit,
+	.ndo_start_xmit	= ipip_tunnel_xmit,
+	.ndo_do_ioctl	= ipip_tunnel_ioctl,
+	.ndo_change_mtu	= ipip_tunnel_change_mtu,
+
+};
+
 static void ipip_tunnel_setup(struct net_device *dev)
 {
-	dev->uninit		= ipip_tunnel_uninit;
-	dev->hard_start_xmit	= ipip_tunnel_xmit;
-	dev->do_ioctl		= ipip_tunnel_ioctl;
-	dev->change_mtu		= ipip_tunnel_change_mtu;
+	dev->netdev_ops		= &ipip_netdev_ops;
 	dev->destructor		= free_netdev;
 
 	dev->type		= ARPHRD_TUNNEL;
@@ -708,11 +714,9 @@ static void ipip_tunnel_setup(struct net
 	dev->features		|= NETIF_F_NETNS_LOCAL;
 }
 
-static int ipip_tunnel_init(struct net_device *dev)
+static void ipip_tunnel_init(struct net_device *dev)
 {
-	struct ip_tunnel *tunnel;
-
-	tunnel = netdev_priv(dev);
+	struct ip_tunnel *tunnel = netdev_priv(dev);
 
 	tunnel->dev = dev;
 	strcpy(tunnel->parms.name, dev->name);
@@ -721,11 +725,9 @@ static int ipip_tunnel_init(struct net_d
 	memcpy(dev->broadcast, &tunnel->parms.iph.daddr, 4);
 
 	ipip_tunnel_bind_dev(dev);
-
-	return 0;
 }
 
-static int ipip_fb_tunnel_init(struct net_device *dev)
+static void ipip_fb_tunnel_init(struct net_device *dev)
 {
 	struct ip_tunnel *tunnel = netdev_priv(dev);
 	struct iphdr *iph = &tunnel->parms.iph;
@@ -740,7 +742,6 @@ static int ipip_fb_tunnel_init(struct ne
 
 	dev_hold(dev);
 	ipn->tunnels_wc[0]	= tunnel;
-	return 0;
 }
 
 static struct xfrm_tunnel ipip_handler = {
@@ -793,7 +794,7 @@ static int ipip_init_net(struct net *net
 		goto err_alloc_dev;
 	}
 
-	ipn->fb_tunnel_dev->init = ipip_fb_tunnel_init;
+	ipip_fb_tunnel_init(ipn->fb_tunnel_dev);
 	dev_net_set(ipn->fb_tunnel_dev, net);
 
 	if ((err = register_netdev(ipn->fb_tunnel_dev)))

-- 


  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 ` Stephen Hemminger [this message]
2008-11-21  4:33   ` [PATCH 7/9] ipip: convert " 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 ` [PATCH 9/9] ipgre: convert to netdevice_ops Stephen Hemminger
2008-11-21  4:34   ` 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.092348986@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).