History

netns: add rtnl cmd to add and get peer netns ids

With this patch, a user can define an id for a peer netns by providing a FD or a PID. These ids are local to the netns where it is added (ie valid only into this netns). The main function (ie the one exported to other module), peernet2id(), allows to get the id of a peer netns. If no id has been assigned by the user, this function allocates one. These ids will be used in netlink messages to point to a peer netns, for example in case of a x-netns interface.

Nicolas Dichtel committed 11 years ago

Commit 0c7aecd1 parent 4de8b416 files · +245 −0Browse files

Showing the changes to include/uapi/linux (3 of 6 files). Show all

Unified · Split

3 files
  1. include/uapi/linux/Kbuild +1 −0
  2. include/uapi/linux/net_namespace.h +23 −0
  3. include/uapi/linux/rtnetlink.h +5 −0
include/uapi/linux/Kbuild+1−0
@@ -283,6 +283,7 @@ header-y += net.h · 282 unmodified lines
283header-y += netlink_diag.h283header-y += netlink_diag.h
284header-y += netlink.h284header-y += netlink.h
285header-y += netrom.h285header-y += netrom.h
286header-y += net_namespace.h
286header-y += net_tstamp.h287header-y += net_tstamp.h
287header-y += nfc.h288header-y += nfc.h
288header-y += nfs2.h289header-y += nfs2.h
include/uapi/linux/net_namespace.h+23−0
@@ -0,0 +1,23 @@
1/* Copyright (c) 2015 6WIND S.A.
2 * Author: Nicolas Dichtel <nicolas.dichtel@6wind.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 */
8#ifndef _UAPI_LINUX_NET_NAMESPACE_H_
9#define _UAPI_LINUX_NET_NAMESPACE_H_
10
11/* Attributes of RTM_NEWNSID/RTM_GETNSID messages */
12enum {
13 NETNSA_NONE,
14#define NETNSA_NSID_NOT_ASSIGNED -1
15 NETNSA_NSID,
16 NETNSA_PID,
17 NETNSA_FD,
18 __NETNSA_MAX,
19};
20
21#define NETNSA_MAX (__NETNSA_MAX - 1)
22
23#endif /* _UAPI_LINUX_NET_NAMESPACE_H_ */
include/uapi/linux/rtnetlink.h+5−0
@@ -132,6 +132,11 @@ enum { · 131 unmodified lines
132 RTM_GETMDB = 86,132 RTM_GETMDB = 86,
133#define RTM_GETMDB RTM_GETMDB133#define RTM_GETMDB RTM_GETMDB
134 134
135 RTM_NEWNSID = 88,
136#define RTM_NEWNSID RTM_NEWNSID
137 RTM_GETNSID = 90,
138#define RTM_GETNSID RTM_GETNSID
139
135 __RTM_MAX,140 __RTM_MAX,
136#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1)141#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1)
137};142};