[lxc-devel] [lxc/lxc] cc6119: network: add netns_getifaddrs() implementation

GitHub noreply at github.com
Sun Sep 23 22:35:22 UTC 2018


  Branch: refs/heads/master
  Home:   https://github.com/lxc/lxc
  Commit: cc6119a0334a0debf43c4d2dffc9f549a67e315d
      https://github.com/lxc/lxc/commit/cc6119a0334a0debf43c4d2dffc9f549a67e315d
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2018-09-23 (Sun, 23 Sep 2018)

  Changed paths:
    R src/include/ifaddrs.c
    R src/include/ifaddrs.h
    A src/include/netns_ifaddrs.c
    A src/include/netns_ifaddrs.h
    M src/lxc/Makefile.am
    M src/lxc/macro.h
    M src/lxc/network.c
    M src/lxc/nl.c
    M src/lxc/nl.h

  Log Message:
  -----------
  network: add netns_getifaddrs() implementation

This commit introduces my concept of a network namespace aware
getifaddrs(), i.e. netns_getifaddrs(). This presupposes a kernel that
carries my IF{L}A_TARGET_NETNSID patches:

struct netns_ifaddrs {
  struct netns_ifaddrs *ifa_next;
   /* Can - but shouldn't be - NULL. */
  char *ifa_name;
   /* This field is not present struct ifaddrs. */
  int ifa_ifindex;
   unsigned ifa_flags;
   /* This field is not present struct ifaddrs. */
  int ifa_mtu;
   /* This field is not present struct ifaddrs. */
  int ifa_prefixlen;
   struct sockaddr *ifa_addr;
  struct sockaddr *ifa_netmask;
  union {
          struct sockaddr *ifu_broadaddr;
          struct sockaddr *ifu_dstaddr;
  } ifa_ifu;
   /* If you don't know what this is for don't touch it. */
  void *ifa_data;
};

which is a superset of struct ifaddrs. It contains additional
information such as the mtu, ifindex of the interface and the prefix
length of the address.
Note that the field ordering is different. So don't get any ideas of
using memcpy() to copy from an old struct ifaddrs into a struct
netns_ifaddrs.

int netns_getifaddrs(struct netns_ifaddrs **ifap, __s32 netns_id, bool *netnsid_aware)

takes a network namespace identifier as argument which identifies the
target network namespace.
If successfull, i.e. netns_getifaddrs() returns 0, callers should check
the bool *netnsid_aware return argument. If it is true then
RTM_GET{ADDR,LINK} requests are fully netnsid aware. If it is false then
they are not and the information returned in struct netns_ifaddrs does
*not* contain correct information about the target network namespace
identified by netnsid.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>


  Commit: b1e44ed1254de2ba1b46c34162688bf2a7fad6d8
      https://github.com/lxc/lxc/commit/b1e44ed1254de2ba1b46c34162688bf2a7fad6d8
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2018-09-23 (Sun, 23 Sep 2018)

  Changed paths:
    M src/lxc/confile.c
    M src/lxc/lxccontainer.c
    M src/lxc/network.c
    M src/lxc/tools/lxc_device.c

  Log Message:
  -----------
  tree_wide: switch to netns_getifaddrs()

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>


  Commit: d3d5554a972b9cc337a01445e2aeb722aecfdba9
      https://github.com/lxc/lxc/commit/d3d5554a972b9cc337a01445e2aeb722aecfdba9
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2018-09-23 (Sun, 23 Sep 2018)

  Changed paths:
    M src/include/netns_ifaddrs.c

  Log Message:
  -----------
  netns_ifaddrs: mark casts as safe

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>


  Commit: 61204b93dd37c8b3df5026e0534d41397986b403
      https://github.com/lxc/lxc/commit/61204b93dd37c8b3df5026e0534d41397986b403
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2018-09-23 (Sun, 23 Sep 2018)

  Changed paths:
    M src/lxc/Makefile.am

  Log Message:
  -----------
  autotools: fix lxc_user_nic build

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>


  Commit: 36be8e6c4a0618c6ffe83f63aae855b1d6e86138
      https://github.com/lxc/lxc/commit/36be8e6c4a0618c6ffe83f63aae855b1d6e86138
  Author: Stéphane Graber <stgraber at stgraber.org>
  Date:   2018-09-24 (Mon, 24 Sep 2018)

  Changed paths:
    R src/include/ifaddrs.c
    R src/include/ifaddrs.h
    A src/include/netns_ifaddrs.c
    A src/include/netns_ifaddrs.h
    M src/lxc/Makefile.am
    M src/lxc/confile.c
    M src/lxc/lxccontainer.c
    M src/lxc/macro.h
    M src/lxc/network.c
    M src/lxc/nl.c
    M src/lxc/nl.h
    M src/lxc/tools/lxc_device.c

  Log Message:
  -----------
  Merge pull request #2640 from brauner/2018-09-23/netns_getifaddrs

network: add netns_getifaddrs() implementation


Compare: https://github.com/lxc/lxc/compare/7e270c97f1e0...36be8e6c4a06
      **NOTE:** This service has been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/

      Functionality will be removed from GitHub.com on January 31st, 2019.


More information about the lxc-devel mailing list