1. 19 Jan, 2015 7 commits
    • David S. Miller's avatar
      Merge branch 'link_netns' · 7f9091f0
      David S. Miller authored
      Merge branch 'link_netns'
      
      Nicolas Dichtel says:
      
      ====================
      netns: allow to identify peer netns
      
      The goal of this serie is to be able to multicast netlink messages with an
      attribute that identify a peer netns.
      This is needed by the userland to interpret some information contained in
      netlink messages (like IFLA_LINK value, but also some other attributes in case
      of x-netns netdevice (see also
      http://thread.gmane.org/gmane.linux.network/315933/focus=316064 and
      http://thread.gmane.org/gmane.linux.kernel.containers/28301/focus=4239)).
      
      Ids of peer netns can be set by userland via a new rtnl cmd RTM_NEWNSID. When
      the kernel needs an id for a peer (for example when advertising a new x-netns
      interface via netlink), if the user didn't allocate an id, one will be
      automatically allocated.
      These ids are stored per netns and are local (ie only valid in the netns where
      they are set). To avoid allocating an int for each peer netns, I use
      idr_for_each() to retrieve the id of a peer netns. Note that it will be possible
      to add a table (struct net -> id) later to optimize this lookup if needed.
      
      Patch 1/4 introduces the rtnetlink API mechanism to set and get these ids.
      Patch 2/4 and 3/4 implements an example of how to use these ids when advertising
      information about a x-netns interface.
      And patch 4/4 shows that the netlink messages can be symetric between a GET and
      a SET.
      
      iproute2 patches are available, I can send them on demand.
      
      Here is a small screenshot to show how it can be used by userland.
      
      $ ip netns add foo
      $ ip netns del foo
      $ ip netns
      $ touch /var/run/netns/init_net
      $ mount --bind /proc/1/ns/net /var/run/netns/init_net
      $ ip netns add foo
      $ ip -n foo netns
      foo
      init_net
      $ ip -n foo netns set init_net 0
      $ ip -n foo netns set foo 1
      
      $ ip netns
      foo
      init_net
      $ ip -n foo netns
      foo (id: 1)
      init_net (id: 0)
      
      $ ip -n foo link add ipip1 link-netnsid 0 type ipip remote 10.16.0.121 local 10.16.0.249
      $ ip -n foo link ls ipip1
      6: ipip1@NONE: <POINTOPOINT,NOARP> mtu 1480 qdisc noop state DOWN mode DEFAULT group default
          link/ipip 10.16.0.249 peer 10.16.0.121 link-netnsid 0
      
      $ ip netns
      foo
      init_net
      $ ip -n foo link add ipip2 type ipip remote 10.16.0.121 local 10.16.0.249
      $ ip -n foo link set ipip2 netns init_net
      $ ip link ls ipip2
      7: ipip2@NONE: <POINTOPOINT,NOARP> mtu 1480 qdisc noop state DOWN mode DEFAULT group default
          link/ipip 10.16.0.249 peer 10.16.0.121 link-netnsid 0
      $ ip netns
      foo (id: 0)
      init_net
      
      v4 -> v5:
        use rtnetlink instead of genetlink
        allocate automatically an id if user didn't assign one
        rename include/uapi/linux/netns.h to include/uapi/linux/net_namespace.h
        add vxlan in patch #3
      
      RFCv3 -> v4:
        rebase on net-next
        add copyright text in the new netns.h file
      
      RFCv2 -> RFCv3:
        ids are now defined by userland (via netlink). Ids are stored in each netns
        (and they are local to this netns).
        add get_link_net support for ip6 tunnels
        netnsid is now a s32 instead of a u32
      
      RFCv1 -> RFCv2:
        remove useless ()
        ids are now stored in the user ns. It's possible to get an id for a peer netns
        only if the current netns and the peer netns have the same user ns parent.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7f9091f0
    • Nicolas Dichtel's avatar
      rtnl: allow to create device with IFLA_LINK_NETNSID set · 317f4810
      Nicolas Dichtel authored
      This patch adds the ability to create a netdevice in a specified netns and
      then move it into the final netns. In fact, it allows to have a symetry between
      get and set rtnl messages.
      Signed-off-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      317f4810
    • Nicolas Dichtel's avatar
      tunnels: advertise link netns via netlink · 1728d4fa
      Nicolas Dichtel authored
      Implement rtnl_link_ops->get_link_net() callback so that IFLA_LINK_NETNSID is
      added to rtnetlink messages.
      Signed-off-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      1728d4fa
    • Nicolas Dichtel's avatar
      rtnl: add link netns id to interface messages · d37512a2
      Nicolas Dichtel authored
      This patch adds a new attribute (IFLA_LINK_NETNSID) which contains the 'link'
      netns id when this netns is different from the netns where the interface
      stands (for example for x-net interfaces like ip tunnels).
      With this attribute, it's possible to interpret correctly all advertised
      information (like IFLA_LINK, etc.).
      Signed-off-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d37512a2
    • Nicolas Dichtel's avatar
      netns: add rtnl cmd to add and get peer netns ids · 0c7aecd4
      Nicolas Dichtel authored
      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.
      Signed-off-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0c7aecd4
    • Rosen, Rami's avatar
      bridge: remove oflags from setlink/dellink. · 4de8b413
      Rosen, Rami authored
      Commit 02dba438 ("bridge: fix setlink/dellink notifications") removed usage of oflags in
      both rtnl_bridge_setlink() and rtnl_bridge_dellink() methods. This patch removes this variable as it is no
      longer needed.
      Signed-off-by: default avatarRami Rosen <rami.rosen@intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4de8b413
    • David S. Miller's avatar
      netlink: Fix bugs in nlmsg_end() conversions. · 7b46a644
      David S. Miller authored
      Commit 053c095a ("netlink: make nlmsg_end() and genlmsg_end()
      void") didn't catch all of the cases where callers were breaking out
      on the return value being equal to zero, which they no longer should
      when zero means success.
      
      Fix all such cases.
      Reported-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Reported-by: default avatarScott Feldman <sfeldma@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7b46a644
  2. 18 Jan, 2015 24 commits
  3. 17 Jan, 2015 9 commits