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

Commit 97c53cac authored by Denis V. Lunev's avatar Denis V. Lunev Committed by David S. Miller
Browse files

[NET]: Make rtnetlink infrastructure network namespace aware (v3)



After this patch none of the netlink callback support anything
except the initial network namespace but the rtnetlink infrastructure
now handles multiple network namespaces.

Changes from v2:
- IPv6 addrlabel processing

Changes from v1:
- no need for special rtnl_unlock handling
- fixed IPv6 ndisc

Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b854272b
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -620,11 +620,11 @@ extern int __rtattr_parse_nested_compat(struct rtattr *tb[], int maxattr,
({	data = RTA_PAYLOAD(rta) >= len ? RTA_DATA(rta) : NULL; \
({	data = RTA_PAYLOAD(rta) >= len ? RTA_DATA(rta) : NULL; \
	__rtattr_parse_nested_compat(tb, max, rta, len); })
	__rtattr_parse_nested_compat(tb, max, rta, len); })


extern int rtnetlink_send(struct sk_buff *skb, u32 pid, u32 group, int echo);
extern int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, u32 group, int echo);
extern int rtnl_unicast(struct sk_buff *skb, u32 pid);
extern int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid);
extern int rtnl_notify(struct sk_buff *skb, u32 pid, u32 group,
extern int rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid, u32 group,
		       struct nlmsghdr *nlh, gfp_t flags);
		       struct nlmsghdr *nlh, gfp_t flags);
extern void rtnl_set_sk_err(u32 group, int error);
extern void rtnl_set_sk_err(struct net *net, u32 group, int error);
extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics);
extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics);
extern int rtnl_put_cacheinfo(struct sk_buff *skb, struct dst_entry *dst,
extern int rtnl_put_cacheinfo(struct sk_buff *skb, struct dst_entry *dst,
			      u32 id, u32 ts, u32 tsage, long expires,
			      u32 id, u32 ts, u32 tsage, long expires,
+3 −0
Original line number Original line Diff line number Diff line
@@ -10,6 +10,7 @@


struct proc_dir_entry;
struct proc_dir_entry;
struct net_device;
struct net_device;
struct sock;
struct net {
struct net {
	atomic_t		count;		/* To decided when the network
	atomic_t		count;		/* To decided when the network
						 *  namespace should be freed.
						 *  namespace should be freed.
@@ -29,6 +30,8 @@ struct net {
	struct list_head 	dev_base_head;
	struct list_head 	dev_base_head;
	struct hlist_head 	*dev_name_head;
	struct hlist_head 	*dev_name_head;
	struct hlist_head	*dev_index_head;
	struct hlist_head	*dev_index_head;

	struct sock 		*rtnl;			/* rtnetlink socket */
};
};


#ifdef CONFIG_NET
#ifdef CONFIG_NET
+2 −2
Original line number Original line Diff line number Diff line
@@ -97,10 +97,10 @@ void br_ifinfo_notify(int event, struct net_bridge_port *port)
		kfree_skb(skb);
		kfree_skb(skb);
		goto errout;
		goto errout;
	}
	}
	err = rtnl_notify(skb, 0, RTNLGRP_LINK, NULL, GFP_ATOMIC);
	err = rtnl_notify(skb, &init_net,0, RTNLGRP_LINK, NULL, GFP_ATOMIC);
errout:
errout:
	if (err < 0)
	if (err < 0)
		rtnl_set_sk_err(RTNLGRP_LINK, err);
		rtnl_set_sk_err(&init_net, RTNLGRP_LINK, err);
}
}


/*
/*
+2 −2
Original line number Original line Diff line number Diff line
@@ -599,10 +599,10 @@ static void notify_rule_change(int event, struct fib_rule *rule,
		kfree_skb(skb);
		kfree_skb(skb);
		goto errout;
		goto errout;
	}
	}
	err = rtnl_notify(skb, pid, ops->nlgroup, nlh, GFP_KERNEL);
	err = rtnl_notify(skb, &init_net, pid, ops->nlgroup, nlh, GFP_KERNEL);
errout:
errout:
	if (err < 0)
	if (err < 0)
		rtnl_set_sk_err(ops->nlgroup, err);
		rtnl_set_sk_err(&init_net, ops->nlgroup, err);
}
}


static void attach_rules(struct list_head *rules, struct net_device *dev)
static void attach_rules(struct list_head *rules, struct net_device *dev)
+2 −2
Original line number Original line Diff line number Diff line
@@ -2467,10 +2467,10 @@ static void __neigh_notify(struct neighbour *n, int type, int flags)
		kfree_skb(skb);
		kfree_skb(skb);
		goto errout;
		goto errout;
	}
	}
	err = rtnl_notify(skb, 0, RTNLGRP_NEIGH, NULL, GFP_ATOMIC);
	err = rtnl_notify(skb, &init_net, 0, RTNLGRP_NEIGH, NULL, GFP_ATOMIC);
errout:
errout:
	if (err < 0)
	if (err < 0)
		rtnl_set_sk_err(RTNLGRP_NEIGH, err);
		rtnl_set_sk_err(&init_net, RTNLGRP_NEIGH, err);
}
}


#ifdef CONFIG_ARPD
#ifdef CONFIG_ARPD
Loading