Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 51602b2a authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by David S. Miller
Browse files

[IPV4]: Cleanup sysctl manipulations in devinet.c



This includes:

 * moving neigh_sysctl_(un)register calls inside
   devinet_sysctl_(un)register ones, as they are always
   called in pairs;
 * making __devinet_sysctl_unregister() to unregister
   the ipv4_devconf struct, while original devinet_sysctl_unregister()
   works with the in_device to handle both - devconf and
   neigh sysctls;
 * make stubs for CONFIG_SYSCTL=n case to get rid of
   in-code ifdefs.

Signed-off-by: default avatarPavel Emelyanov <xemul@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 01ecfe9b
Loading
Loading
Loading
Loading
+29 −30
Original line number Original line Diff line number Diff line
@@ -99,7 +99,14 @@ static void inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap,
			 int destroy);
			 int destroy);
#ifdef CONFIG_SYSCTL
#ifdef CONFIG_SYSCTL
static void devinet_sysctl_register(struct in_device *idev);
static void devinet_sysctl_register(struct in_device *idev);
static void devinet_sysctl_unregister(struct ipv4_devconf *p);
static void devinet_sysctl_unregister(struct in_device *idev);
#else
static inline void devinet_sysctl_register(struct in_device *idev)
{
}
static inline void devinet_sysctl_unregister(struct in_device *idev)
{
}
#endif
#endif


/* Locks all the inet devices. */
/* Locks all the inet devices. */
@@ -163,17 +170,10 @@ static struct in_device *inetdev_init(struct net_device *dev)
		goto out_kfree;
		goto out_kfree;
	/* Reference in_dev->dev */
	/* Reference in_dev->dev */
	dev_hold(dev);
	dev_hold(dev);
#ifdef CONFIG_SYSCTL
	neigh_sysctl_register(dev, in_dev->arp_parms, NET_IPV4,
			      NET_IPV4_NEIGH, "ipv4", NULL, NULL);
#endif

	/* Account for reference dev->ip_ptr (below) */
	/* Account for reference dev->ip_ptr (below) */
	in_dev_hold(in_dev);
	in_dev_hold(in_dev);


#ifdef CONFIG_SYSCTL
	devinet_sysctl_register(in_dev);
	devinet_sysctl_register(in_dev);
#endif
	ip_mc_init_dev(in_dev);
	ip_mc_init_dev(in_dev);
	if (dev->flags & IFF_UP)
	if (dev->flags & IFF_UP)
		ip_mc_up(in_dev);
		ip_mc_up(in_dev);
@@ -212,15 +212,9 @@ static void inetdev_destroy(struct in_device *in_dev)
		inet_free_ifa(ifa);
		inet_free_ifa(ifa);
	}
	}


#ifdef CONFIG_SYSCTL
	devinet_sysctl_unregister(&in_dev->cnf);
#endif

	dev->ip_ptr = NULL;
	dev->ip_ptr = NULL;


#ifdef CONFIG_SYSCTL
	devinet_sysctl_unregister(in_dev);
	neigh_sysctl_unregister(in_dev->arp_parms);
#endif
	neigh_parms_release(&arp_tbl, in_dev->arp_parms);
	neigh_parms_release(&arp_tbl, in_dev->arp_parms);
	arp_ifdown(dev);
	arp_ifdown(dev);


@@ -1113,13 +1107,8 @@ static int inetdev_event(struct notifier_block *this, unsigned long event,
		 */
		 */
		inetdev_changename(dev, in_dev);
		inetdev_changename(dev, in_dev);


#ifdef CONFIG_SYSCTL
		devinet_sysctl_unregister(in_dev);
		devinet_sysctl_unregister(&in_dev->cnf);
		neigh_sysctl_unregister(in_dev->arp_parms);
		neigh_sysctl_register(dev, in_dev->arp_parms, NET_IPV4,
				      NET_IPV4_NEIGH, "ipv4", NULL, NULL);
		devinet_sysctl_register(in_dev);
		devinet_sysctl_register(in_dev);
#endif
		break;
		break;
	}
	}
out:
out:
@@ -1518,21 +1507,31 @@ out:
	return;
	return;
}
}


static void devinet_sysctl_register(struct in_device *idev)
static void __devinet_sysctl_unregister(struct ipv4_devconf *cnf)
{
{
	return __devinet_sysctl_register(idev->dev->name, idev->dev->ifindex,
	struct devinet_sysctl_table *t = cnf->sysctl;
			&idev->cnf);
}


static void devinet_sysctl_unregister(struct ipv4_devconf *p)
	if (t == NULL)
{
		return;
	if (p->sysctl) {

		struct devinet_sysctl_table *t = p->sysctl;
	cnf->sysctl = NULL;
		p->sysctl = NULL;
	unregister_sysctl_table(t->sysctl_header);
	unregister_sysctl_table(t->sysctl_header);
	kfree(t->dev_name);
	kfree(t->dev_name);
	kfree(t);
	kfree(t);
}
}

static void devinet_sysctl_register(struct in_device *idev)
{
	neigh_sysctl_register(idev->dev, idev->arp_parms, NET_IPV4,
			NET_IPV4_NEIGH, "ipv4", NULL, NULL);
	__devinet_sysctl_register(idev->dev->name, idev->dev->ifindex,
			&idev->cnf);
}

static void devinet_sysctl_unregister(struct in_device *idev)
{
	__devinet_sysctl_unregister(&idev->cnf);
	neigh_sysctl_unregister(idev->arp_parms);
}
}
#endif
#endif