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

Commit b4b51029 authored by Eric W. Biederman's avatar Eric W. Biederman Committed by David S. Miller
Browse files

[NET]: Support multiple network namespaces with netlink



Each netlink socket will live in exactly one network namespace,
this includes the controlling kernel sockets.

This patch updates all of the existing netlink protocols
to only support the initial network namespace.  Request
by clients in other namespaces will get -ECONREFUSED.
As they would if the kernel did not have the support for
that netlink protocol compiled in.

As each netlink protocol is updated to be multiple network
namespace safe it can register multiple kernel sockets
to acquire a presence in the rest of the network namespaces.

The implementation in af_netlink is a simple filter implementation
at hash table insertion and hash table look up time.

Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e9dc8653
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -446,7 +446,7 @@ static int __devinit cn_init(void)
	dev->id.idx = cn_idx;
	dev->id.val = cn_val;

	dev->nls = netlink_kernel_create(NETLINK_CONNECTOR,
	dev->nls = netlink_kernel_create(&init_net, NETLINK_CONNECTOR,
					 CN_NETLINK_USERS + 0xf,
					 dev->input, NULL, THIS_MODULE);
	if (!dev->nls)
+1 −1
Original line number Diff line number Diff line
@@ -167,7 +167,7 @@ scsi_netlink_init(void)
		return;
	}

	scsi_nl_sock = netlink_kernel_create(NETLINK_SCSITRANSPORT,
	scsi_nl_sock = netlink_kernel_create(&init_net, NETLINK_SCSITRANSPORT,
				SCSI_NL_GRP_CNT, scsi_nl_rcv, NULL,
				THIS_MODULE);
	if (!scsi_nl_sock) {
+1 −1
Original line number Diff line number Diff line
@@ -1523,7 +1523,7 @@ static __init int iscsi_transport_init(void)
	if (err)
		goto unregister_conn_class;

	nls = netlink_kernel_create(NETLINK_ISCSI, 1, iscsi_if_rx, NULL,
	nls = netlink_kernel_create(&init_net, NETLINK_ISCSI, 1, iscsi_if_rx, NULL,
			THIS_MODULE);
	if (!nls) {
		err = -ENOBUFS;
+1 −1
Original line number Diff line number Diff line
@@ -227,7 +227,7 @@ int ecryptfs_init_netlink(void)
{
	int rc;

	ecryptfs_nl_sock = netlink_kernel_create(NETLINK_ECRYPTFS, 0,
	ecryptfs_nl_sock = netlink_kernel_create(&init_net, NETLINK_ECRYPTFS, 0,
						 ecryptfs_receive_nl_message,
						 NULL, THIS_MODULE);
	if (!ecryptfs_nl_sock) {
+5 −1
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@

#define MAX_LINKS 32		

struct net;

struct sockaddr_nl
{
	sa_family_t	nl_family;	/* AF_NETLINK	*/
@@ -157,7 +159,8 @@ struct netlink_skb_parms
#define NETLINK_CREDS(skb)	(&NETLINK_CB((skb)).creds)


extern struct sock *netlink_kernel_create(int unit, unsigned int groups,
extern struct sock *netlink_kernel_create(struct net *net,
					  int unit,unsigned int groups,
					  void (*input)(struct sock *sk, int len),
					  struct mutex *cb_mutex,
					  struct module *module);
@@ -206,6 +209,7 @@ struct netlink_callback

struct netlink_notify
{
	struct net *net;
	int pid;
	int protocol;
};
Loading