![](https://seccdn.libravatar.org/avatar/e2145bc5cf53dda95c308a3c75e8fef3.jpg?s=120&d=mm&r=g)
Hello community, here is the log from the commit of package netcontrol for openSUSE:Factory checked in at 2016-05-23 16:39:24 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/netcontrol (Old) and /work/SRC/openSUSE:Factory/.netcontrol.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "netcontrol" Changes: -------- --- /work/SRC/openSUSE:Factory/netcontrol/netcontrol.changes 2014-09-06 12:18:18.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.netcontrol.new/netcontrol.changes 2016-05-23 16:39:26.000000000 +0200 @@ -2 +2,8 @@ -Wed Sep 3 01:48:48 CEST 2014 - ro@suse.de +Fri May 20 15:30:41 UTC 2016 - mt@suse.de + +- version 0.3.1 +- filter devices not supported by libvirt API (fate#320557) + [- 0001-blacklist-ifcfg-files-ending-in-.orig-or-tilde-bnc-8.patch] + +------------------------------------------------------------------- +Wed Sep 3 01:41:37 CEST 2014 - ro@suse.de Old: ---- 0001-blacklist-ifcfg-files-ending-in-.orig-or-tilde-bnc-8.patch netcontrol-0.3.0.tar.bz2 New: ---- netcontrol-0.3.1.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ netcontrol.spec ++++++ --- /var/tmp/diff_new_pack.fGkd7m/_old 2016-05-23 16:39:27.000000000 +0200 +++ /var/tmp/diff_new_pack.fGkd7m/_new 2016-05-23 16:39:27.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package netcontrol # -# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: netcontrol -Version: 0.3.0 +Version: 0.3.1 Release: 0 Summary: A network configuration library License: LGPL-2.1+ @@ -50,7 +50,6 @@ %else Requires: sysconfig >= 0.71.0 %endif -Patch1: 0001-blacklist-ifcfg-files-ending-in-.orig-or-tilde-bnc-8.patch %description A interim network configuration library, currently implementing the @@ -103,7 +102,6 @@ %prep %setup -q -%patch1 -p1 %build export CFLAGS="-W -Wall $RPM_OPT_FLAGS" ++++++ netcontrol-0.3.0.tar.bz2 -> netcontrol-0.3.1.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/netcontrol-0.3.0/ChangeLog.git new/netcontrol-0.3.1/ChangeLog.git --- old/netcontrol-0.3.0/ChangeLog.git 2014-01-10 12:07:30.000000000 +0100 +++ new/netcontrol-0.3.1/ChangeLog.git 2016-05-20 17:45:11.000000000 +0200 @@ -1,3 +1,75 @@ +commit 1ded16e0444eff886634c159633b55a9593445be +Author: Marius Tomaschewski <mt@suse.de> +Date: Fri May 20 17:43:35 2016 +0200 + + version 0.3.1 + +commit 3592f0154433ddddf776f37caac82a910deda770 +Author: Marius Tomaschewski <mt@suse.de> +Date: Fri May 20 09:21:59 2016 +0200 + + Retrieve arp type and check if it is ethernet + +commit aa4ce0be9a13fae4cd38bff3d8f6e1af57313f0d +Author: Marius Tomaschewski <mt@suse.de> +Date: Fri May 20 09:03:32 2016 +0200 + + adjusted test tool to get count in list if needed + +commit 395bc6e209d05e6d545c499e8f86f4b9c4a5eb76 +Author: Marius Tomaschewski <mt@suse.de> +Date: Wed May 18 11:18:08 2016 +0200 + + Bind team and ovs bridge parent for topology tree + +commit d44f2ccd4024c3cbd66a81e88e5922b68a23dd7e +Author: Marius Tomaschewski <mt@suse.de> +Date: Wed May 18 11:14:32 2016 +0200 + + Parse ovs,team,macvlan,macvtap ifcfg config + +commit 699f76e0c437b05c4953684c9a9b1ff0afdcb6c8 +Author: Marius Tomaschewski <mt@suse.de> +Date: Wed May 18 10:54:01 2016 +0200 + + Improve type detection via ethtool driver info ioctl + +commit 2274ab3c849e92863015cf6dacf10bb869aa7384 +Author: Marius Tomaschewski <mt@suse.de> +Date: Wed May 18 10:48:12 2016 +0200 + + Add ovs, team and macvlan interface types + +commit 9e844ba86dc17fc9efae23b3cbc929b6ee889451 +Author: Marius Tomaschewski <mt@suse.de> +Date: Wed May 18 10:44:11 2016 +0200 + + Use common sysfs utility to read a master link + +commit f4b6c450fbb3a66a67a57e739e615d33009544c4 +Author: Marius Tomaschewski <mt@suse.de> +Date: Wed May 18 10:18:54 2016 +0200 + + Fixed to not map ctc and iucv to ethernet but slip + +commit c3258d770515c70e63f527d14ec98a6875082591 +Author: Marius Tomaschewski <mt@suse.de> +Date: Wed May 18 10:13:16 2016 +0200 + + Add common utilities to read a sysfs netif link + +commit 79006d143f3702218ac5ea729b0bce03845dec48 +Author: Marius Tomaschewski <mt@suse.de> +Date: Tue May 10 13:16:20 2016 +0200 + + Added TAGS file to .gitignore + +commit 292d93f5f3cbb9d343b75fb4fc570140004d93f5 +Author: Marius Tomaschewski <mt@suse.de> +Date: Tue May 6 14:13:21 2014 +0200 + + blacklist ifcfg files ending in .orig or tilde (bnc#871600) + commit 328980d93891f10525cd17ad592380f92040740b Author: Marius Tomaschewski <mt@suse.de> Date: Fri Jan 10 12:06:10 2014 +0100 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/netcontrol-0.3.0/aclocal.m4 new/netcontrol-0.3.1/aclocal.m4 --- old/netcontrol-0.3.0/aclocal.m4 2014-01-10 12:07:05.000000000 +0100 +++ new/netcontrol-0.3.1/aclocal.m4 2016-05-20 17:44:59.000000000 +0200 @@ -1326,7 +1326,7 @@ rm -rf conftest* ;; -x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ +x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext @@ -1340,7 +1340,10 @@ x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; - ppc64-*linux*|powerpc64-*linux*) + powerpc64le-*linux*) + LD="${LD-ld} -m elf32lppclinux" + ;; + powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) @@ -1359,7 +1362,10 @@ x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; - ppc*-*linux*|powerpc*-*linux*) + powerpcle-*linux*) + LD="${LD-ld} -m elf64lppc" + ;; + powerpc-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/netcontrol-0.3.0/configure new/netcontrol-0.3.1/configure --- old/netcontrol-0.3.0/configure 2014-01-10 12:07:05.000000000 +0100 +++ new/netcontrol-0.3.1/configure 2016-05-20 17:45:00.000000000 +0200 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for netcontrol 0.3.0. +# Generated by GNU Autoconf 2.69 for netcontrol 0.3.1. # # Report bugs to <feedback@suse.de>. # @@ -590,8 +590,8 @@ # Identity of this package. PACKAGE_NAME='netcontrol' PACKAGE_TARNAME='netcontrol' -PACKAGE_VERSION='0.3.0' -PACKAGE_STRING='netcontrol 0.3.0' +PACKAGE_VERSION='0.3.1' +PACKAGE_STRING='netcontrol 0.3.1' PACKAGE_BUGREPORT='feedback@suse.de' PACKAGE_URL='http://www.suse.de/~mt/git/netcontrol.git/' @@ -1331,7 +1331,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures netcontrol 0.3.0 to adapt to many kinds of systems. +\`configure' configures netcontrol 0.3.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1401,7 +1401,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of netcontrol 0.3.0:";; + short | recursive ) echo "Configuration of netcontrol 0.3.1:";; esac cat <<\_ACEOF @@ -1519,7 +1519,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -netcontrol configure 0.3.0 +netcontrol configure 0.3.1 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1942,7 +1942,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by netcontrol $as_me 0.3.0, which was +It was created by netcontrol $as_me 0.3.1, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2805,7 +2805,7 @@ # Define the identity of the package. PACKAGE='netcontrol' - VERSION='0.3.0' + VERSION='0.3.1' cat >>confdefs.h <<_ACEOF @@ -7260,7 +7260,7 @@ rm -rf conftest* ;; -x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ +x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext @@ -7278,7 +7278,10 @@ x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; - ppc64-*linux*|powerpc64-*linux*) + powerpc64le-*linux*) + LD="${LD-ld} -m elf32lppclinux" + ;; + powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) @@ -7297,7 +7300,10 @@ x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; - ppc*-*linux*|powerpc*-*linux*) + powerpcle-*linux*) + LD="${LD-ld} -m elf64lppc" + ;; + powerpc-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) @@ -13927,7 +13933,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by netcontrol $as_me 0.3.0, which was +This file was extended by netcontrol $as_me 0.3.1, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -13994,7 +14000,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -netcontrol config.status 0.3.0 +netcontrol config.status 0.3.1 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/netcontrol-0.3.0/configure.ac new/netcontrol-0.3.1/configure.ac --- old/netcontrol-0.3.0/configure.ac 2014-01-10 12:06:05.000000000 +0100 +++ new/netcontrol-0.3.1/configure.ac 2016-05-20 17:40:15.000000000 +0200 @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.63]) -AC_INIT([netcontrol], [0.3.0], [feedback@suse.de], [], +AC_INIT([netcontrol], [0.3.1], [feedback@suse.de], [], [http://www.suse.de/~mt/git/netcontrol.git/]) AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip]) AC_CONFIG_SRCDIR([src/nctest.c]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/netcontrol-0.3.0/netcontrol.changes new/netcontrol-0.3.1/netcontrol.changes --- old/netcontrol-0.3.0/netcontrol.changes 2014-01-10 12:06:05.000000000 +0100 +++ new/netcontrol-0.3.1/netcontrol.changes 2016-05-20 17:41:12.000000000 +0200 @@ -1,4 +1,22 @@ ------------------------------------------------------------------- +Fri May 20 15:30:41 UTC 2016 - mt@suse.de + +- version 0.3.1 +- filter devices not supported by libvirt API (fate#320557) + [- 0001-blacklist-ifcfg-files-ending-in-.orig-or-tilde-bnc-8.patch] + +------------------------------------------------------------------- +Wed Sep 3 01:41:37 CEST 2014 - ro@suse.de + +- sanitize release line in specfile + +------------------------------------------------------------------- +Tue May 6 11:58:04 UTC 2014 - mt@suse.de + +- blacklist ifcfg files ending in .orig or tilde (bnc#871600) + [+ 0001-blacklist-ifcfg-files-ending-in-.orig-or-tilde-bnc-8.patch] + +------------------------------------------------------------------- Fri Jan 10 10:55:26 UTC 2014 - mt@suse.de - version 0.3.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/netcontrol-0.3.0/netcontrol.spec new/netcontrol-0.3.1/netcontrol.spec --- old/netcontrol-0.3.0/netcontrol.spec 2014-01-10 12:07:09.000000000 +0100 +++ new/netcontrol-0.3.1/netcontrol.spec 2016-05-20 17:45:05.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package netcontrol # -# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,7 +16,7 @@ # Name: netcontrol -Version: 0.3.0 +Version: 0.3.1 Release: 0 Summary: A network configuration library License: LGPL-2.1+ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/netcontrol-0.3.0/netcontrol.spec.in new/netcontrol-0.3.1/netcontrol.spec.in --- old/netcontrol-0.3.0/netcontrol.spec.in 2014-01-10 12:03:02.000000000 +0100 +++ new/netcontrol-0.3.1/netcontrol.spec.in 2016-05-20 17:40:15.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package netcontrol # -# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/netcontrol-0.3.0/src/backend-suse.c new/netcontrol-0.3.1/src/backend-suse.c --- old/netcontrol-0.3.0/src/backend-suse.c 2014-01-10 12:01:13.000000000 +0100 +++ new/netcontrol-0.3.1/src/backend-suse.c 2016-05-20 17:40:06.000000000 +0200 @@ -40,6 +40,11 @@ #include <unistd.h> #include <assert.h> #include <net/if_arp.h> +#include <sys/ioctl.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <linux/sockios.h> +#include <linux/ethtool.h> #include <sutils.h> #include <futils.h> @@ -118,6 +123,10 @@ static int try_ppp(nc_handle_t *nh, nc_interface_t *ifp, nc_sysconfig_t *sc); static int try_tunnel(nc_handle_t *nh, nc_interface_t *ifp, nc_sysconfig_t *sc); static int try_infiniband(nc_handle_t *nh, nc_interface_t *ifp, nc_sysconfig_t *sc); +static int try_ovs(nc_handle_t *nh, nc_interface_t *ifp, nc_sysconfig_t *sc); +static int try_team(nc_handle_t *nh, nc_interface_t *ifp, nc_sysconfig_t *sc); +static int try_macvlan(nc_handle_t *nh, nc_interface_t *ifp, nc_sysconfig_t *sc); +static int try_macvtap(nc_handle_t *nh, nc_interface_t *ifp, nc_sysconfig_t *sc); static int nc_discover_iface_type(const char *name, unsigned int *ifp_type, unsigned int *arp_type); @@ -162,8 +171,12 @@ { "qeth", NC_IFTYPE_ETHERNET }, { "hsi", NC_IFTYPE_ETHERNET }, { "lcs", NC_IFTYPE_ETHERNET }, - { "ctc", NC_IFTYPE_ETHERNET }, - { "iucv", NC_IFTYPE_ETHERNET }, + { "ctc", NC_IFTYPE_SLIP }, + { "iucv", NC_IFTYPE_SLIP }, + { "ovs", NC_IFTYPE_OVS }, + { "team", NC_IFTYPE_TEAM }, + { "macvlan", NC_IFTYPE_MACVLAN }, + { "macvtap", NC_IFTYPE_MACVLAN }, { NULL, NC_IFTYPE_UNKNOWN } }; @@ -803,7 +816,7 @@ __suse_ifcfg_valid_name(const char *name) { const char *bl_suffix[] = { - ".old", ".bak", ".scpmbackup", + "~", ".old", ".bak", ".orig", ".scpmbackup", ".rpmnew", ".rpmsave", ".rpmorig" }; size_t nlen, slen, n; @@ -1457,6 +1470,179 @@ return -1; } +static int +try_add_ovs_port(nc_interface_t *ifp, nc_sysconfig_t *sc, const char *suffix) +{ + nc_var_t *v; + + v = __find_indexed_variable(sc, "OVS_BRIDGE_PORT_DEVICE", suffix); + if (!v || !nc_string_len(v->value)) + return 1; + + if (nc_string_eq(ifp->name, v->value)) + return -1; + + if (!ifp->bridge && !(ifp->bridge = nc_bridge_new())) + return -1; + + return nc_bridge_add_port(ifp->bridge, v->value); +} + +static int +try_ovs(nc_handle_t *nh, nc_interface_t *ifp, nc_sysconfig_t *sc) +{ + nc_var_t *v; + + v = nc_sysconfig_get(sc, "OVS_BRIDGE"); + if (!nc_string_eq(ifp->name, "ovs-system") && + (!v || !nc_string_eq(v->value, "yes"))) + return 1; + + if(ifp->type != NC_IFTYPE_OVS && ifp->type != NC_IFTYPE_UNKNOWN) { + if(nc_error_once_check(nh, "/%s/%s/type", __func__, ifp->name)) { + nc_error("Interface config %s: matches an ovs and another interface type", + ifp->name); + } + goto failure; + } + nc_error_once_clear(nh, "/%s/%s/type", __func__, ifp->name); + + ifp->type = NC_IFTYPE_OVS; + if (nc_string_eq(ifp->name, "ovs-system")) + return 0; + + v = nc_sysconfig_get(sc, "OVS_BRIDGE_VLAN_PARENT"); + if(v && nc_string_len(v->value)) { + unsigned int tag = 0; + + if(nc_sysconfig_get_uint(sc, "OVS_BRIDGE_VLAN_TAG", &tag) != 0 || + !(ifp->vlan = nc_vlan_new(v->value, tag))) { + if(nc_error_once_check(nh, "/%s/%s/vlan", __func__, ifp->name)) { + nc_error("Interface config %s: cannot process ovs vlan bridge", + ifp->name); + } + goto failure; + } + nc_error_once_clear(nh, "/%s/%s/vlan", __func__, ifp->name); + } + if(__process_indexed_variables(ifp, sc, "OVS_BRIDGE_PORT_DEVICE", try_add_ovs_port) < 0) { + if(nc_error_once_check(nh, "/%s/%s/port", __func__, ifp->name)) { + nc_error("Interface config %s: cannot process ovs bridge ports", + ifp->name); + } + goto failure; + } else { + nc_error_once_clear(nh, "/%s/%s/port", __func__, ifp->name); + } + + return 0; +failure: + ifp->invalid = 1; + return -1; +} + +static int +try_add_team_port(nc_interface_t *ifp, nc_sysconfig_t *sc, const char *suffix) +{ + nc_var_t *v; + + v = __find_indexed_variable(sc, "TEAM_PORT_DEVICE", suffix); + if (!v || !nc_string_len(v->value)) + return 1; + + if (!ifp->bonding) + return -1; + + if (nc_string_eq(ifp->name, v->value)) + return -1; + + ifp->bonding->slave_type = NC_IFTYPE_ETHERNET; + return nc_bonding_add_slave(ifp->bonding, v->value); +} + +static int +try_team(nc_handle_t *nh, nc_interface_t *ifp, nc_sysconfig_t *sc) +{ + nc_var_t *v; + + v = nc_sysconfig_get(sc, "TEAM_RUNNER"); + if(!v || !nc_string_len(v->value)) + return 1; + + if(ifp->type != NC_IFTYPE_TEAM && ifp->type != NC_IFTYPE_UNKNOWN) { + if(nc_error_once_check(nh, "/%s/%s/type", __func__, ifp->name)) { + nc_error("Interface config %s: matches team and another interface type", + ifp->name); + } + goto failure; + } + nc_error_once_clear(nh, "/%s/%s/type", __func__, ifp->name); + + ifp->type = NC_IFTYPE_TEAM; + ifp->bonding = nc_bonding_new(); + if(__process_indexed_variables(ifp, sc, "TEAM_PORT_DEVICE", try_add_team_port) < 0) { + if(nc_error_once_check(nh, "/%s/%s/port", __func__, ifp->name)) { + nc_error("Interface config %s: cannot process team ports", + ifp->name); + } + goto failure; + } else { + nc_error_once_clear(nh, "/%s/%s/port", __func__, ifp->name); + } + + return 0; +failure: + ifp->invalid = 1; + return -1; +} + +static int +try_macvlan(nc_handle_t *nh, nc_interface_t *ifp, nc_sysconfig_t *sc) +{ + nc_var_t *v; + + v = nc_sysconfig_get(sc, "MACVLAN_DEVICE"); + if(!v || !nc_string_eq(v->value, "yes")) + return 1; + + if(ifp->type != NC_IFTYPE_MACVLAN && ifp->type != NC_IFTYPE_UNKNOWN) { + if(nc_error_once_check(nh, "/%s/%s/type", __func__, ifp->name)) { + nc_error("Interface config %s: matches macvlan and another interface type", + ifp->name); + } + ifp->invalid = 1; + return -1; + } + nc_error_once_clear(nh, "/%s/%s/type", __func__, ifp->name); + + ifp->type = NC_IFTYPE_MACVLAN; + return 0; +} + +static int +try_macvtap(nc_handle_t *nh, nc_interface_t *ifp, nc_sysconfig_t *sc) +{ + nc_var_t *v; + + v = nc_sysconfig_get(sc, "MACVTAP_DEVICE"); + if(!v || !nc_string_eq(v->value, "yes")) + return 1; + + if(ifp->type != NC_IFTYPE_MACVTAP && ifp->type != NC_IFTYPE_UNKNOWN) { + if(nc_error_once_check(nh, "/%s/%s/type", __func__, ifp->name)) { + nc_error("Interface config %s: matches macvtap and another interface type", + ifp->name); + } + ifp->invalid = 1; + return -1; + } + nc_error_once_clear(nh, "/%s/%s/type", __func__, ifp->name); + + /* cannot differentiate them, but a macvtap is derived from macvlan */ + ifp->type = NC_IFTYPE_MACVLAN; + return 0; +} + int nc_interface_guess_type(nc_interface_t *ifp) { @@ -1804,7 +1990,6 @@ /* nc_var_array_t sysctl = NC_VAR_ARRAY_INIT; */ - unsigned int arp_type; typedef int (*try_func_t)(nc_handle_t *nh, nc_interface_t *ifp, nc_sysconfig_t *sc); try_func_t *try_func, try_funcs[] = { try_vlan, @@ -1814,6 +1999,10 @@ try_ppp, try_tunnel, try_infiniband, + try_ovs, + try_team, + try_macvlan, + try_macvtap, NULL }; nc_var_t *v; @@ -1821,7 +2010,7 @@ (void)nh; ifp->type = NC_IFTYPE_UNKNOWN; - if(nc_discover_iface_type(ifp->name, &ifp->type, &arp_type) == 0) { + if(nc_discover_iface_type(ifp->name, &ifp->type, &ifp->arp_type) == 0) { switch(ifp->type) { case NC_IFTYPE_VLAN: if(__nc_discover_vlan(ifp) != 0) { @@ -1846,6 +2035,20 @@ return -1; } break; + case NC_IFTYPE_TEAM: + if(try_team(nh, ifp, sc) < 0) { + ifp->invalid = 1; + return -1; + } + case NC_IFTYPE_OVS: + if(try_ovs(nh, ifp, sc) < 0) { + ifp->invalid = 1; + return -1; + } + break; + case NC_IFTYPE_MACVLAN: + case NC_IFTYPE_MACVTAP: + break; default: /* Hmm... just check sc vars ? */ @@ -1932,8 +2135,97 @@ } static int +nc_ethtool(const char *ifname, struct ethtool_cmd *cmd) +{ + struct ifreq ifr; + int sock, ret; + + if (!nc_string_len(ifname) || !cmd) + return -1; + + memset(&ifr, 0, sizeof(ifr)); + strncpy(ifr.ifr_name, ifname, IFNAMSIZ); + ifr.ifr_data = (void *)cmd; + + sock = socket(PF_INET, SOCK_DGRAM, 0); + if (sock < 0) + return -1; + + ret = ioctl(sock, SIOCETHTOOL, &ifr); + close(sock); + return ret; +} + +static int +nc_ethtool_driver_info(const char *ifname, struct ethtool_drvinfo *drv_info) +{ + if (!drv_info) + return -1; + + memset(drv_info, 0, sizeof(struct ethtool_drvinfo)); + drv_info->cmd = ETHTOOL_GDRVINFO; + + return nc_ethtool(ifname, (struct ethtool_cmd *)drv_info); +} + +static int +ni_discover_iface_type_ethtool(const char *name, unsigned int *ifp_type) +{ + struct ethtool_drvinfo drv_info; + + if (!ifp_type || nc_ethtool_driver_info(name, &drv_info) < 0) + return -1; + + /* just return unknown for types not supported by netcf; + * not needed to made them known, except when this are + * master container devices / parent types ... + */ + if (nc_string_eq(drv_info.driver, "bridge")) + *ifp_type = NC_IFTYPE_BRIDGE; + else + if (nc_string_eq(drv_info.driver, "bonding")) + *ifp_type = NC_IFTYPE_BOND; + else + if (nc_string_eq(drv_info.driver, "802.1Q VLAN Support")) + *ifp_type = NC_IFTYPE_VLAN; + else + if (nc_string_eq(drv_info.driver, "dummy")) + *ifp_type = NC_IFTYPE_DUMMY; + else + if (nc_string_eq(drv_info.driver, "team")) + *ifp_type = NC_IFTYPE_DUMMY; + else + if (nc_string_eq(drv_info.driver, "openvswitch")) + *ifp_type = NC_IFTYPE_OVS; + else + if (nc_string_eq(drv_info.driver, "macvlan")) + /* macvtap is not visible here */ + *ifp_type = NC_IFTYPE_MACVLAN; + else + if (nc_string_eq(drv_info.driver, "vxlan")) + *ifp_type = NC_IFTYPE_UNKNOWN; + else + if (nc_string_eq(drv_info.driver, "veth")) + *ifp_type = NC_IFTYPE_UNKNOWN; + else + if (nc_string_eq(drv_info.driver, "tun")) { + if (nc_string_eq(drv_info.bus_info, "tap")) + *ifp_type = NC_IFTYPE_TAP; + else + if (nc_string_eq(drv_info.bus_info, "tun")) + *ifp_type = NC_IFTYPE_TUN; + else + return 1; + } else + return 1; + + return 0; +} + +static int nc_discover_iface_type(const char *name, unsigned int *ifp_type, unsigned int *arp_type) { + assert(name && *name && ifp_type && arp_type); *ifp_type = NC_IFTYPE_UNKNOWN; @@ -1943,6 +2235,9 @@ return -1; } + if (ni_discover_iface_type_ethtool(name, ifp_type) == 0) + return 0; + switch(*arp_type) { case ARPHRD_NONE: if(nc_sysfs_netif_exists(name, "tun_flags")) { @@ -1952,6 +2247,10 @@ case ARPHRD_ETHER: *ifp_type = NC_IFTYPE_ETHERNET; + if(nc_sysfs_netif_exists(name, "wireless") || + nc_sysfs_netif_exists(name, "phy80211")) { + *ifp_type = NC_IFTYPE_WIRELESS; + } else if(nc_sysfs_netif_exists(name, "bonding/mode")) { *ifp_type = NC_IFTYPE_BOND; } else @@ -1961,10 +2260,6 @@ if(nc_file_exists_fmt("/proc/net/vlan/%s", name)) { *ifp_type = NC_IFTYPE_VLAN; } else - if(nc_sysfs_netif_exists(name, "wireless") || - nc_sysfs_netif_exists(name, "phy80211")) { - *ifp_type = NC_IFTYPE_WIRELESS; - } else if(nc_file_exists_fmt("/sys/devices/virtual/net/%s", name)) { if(nc_string_prefix_eq("dummy", name)) { *ifp_type = NC_IFTYPE_DUMMY; @@ -2119,11 +2414,14 @@ if(!ifp || !ifp->name) return -1; - if(nc_sysfs_get_bonding_parent(ifp->name, &parent) == 0) { + /* seems that all slave types link to their master under newer kernels */ + if(nc_sysfs_netif_get_linkbase(ifp->name, "master", &parent) == 0) { nc_string_free(&ifp->parent); ifp->parent = parent; return 0; } + + /* bridge ports do not link the bridge via master under older kernels */ if(nc_sysfs_get_bridge_parent(ifp->name, &parent) == 0) { nc_string_free(&ifp->parent); ifp->parent = parent; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/netcontrol-0.3.0/src/handle.c new/netcontrol-0.3.1/src/handle.c --- old/netcontrol-0.3.0/src/handle.c 2013-03-26 13:44:08.000000000 +0100 +++ new/netcontrol-0.3.1/src/handle.c 2016-05-20 17:40:06.000000000 +0200 @@ -475,10 +475,51 @@ return -1; } +static inline void +nc_ovs_bridge_bind(nc_interface_t *ifp, nc_handle_t *nh) +{ + unsigned int i; + + for (i = 0; i < ifp->bridge->ports.count; ++i) { + nc_bridge_port_t *port = ifp->bridge->ports.data[i]; + const char *ifname = port->name; + nc_interface_t *iface; + + + if (!(iface = nc_interface_by_name(nh, ifname))) + continue; + + if (iface->invalid) + iface->invalid = 1; + else + /* in fact, it is always ovs-system */ + nc_string_dup(&iface->parent, ifp->name); + } +} + +static inline void +nc_team_bind(nc_interface_t *ifp, nc_handle_t *nh) +{ + unsigned int i; + + for (i = 0; i < ifp->bonding->slave_names.count; ++i) { + const char *ifname = ifp->bonding->slave_names.data[i]; + nc_interface_t *iface; + + if (!(iface = nc_interface_by_name(nh, ifname))) + continue; + + if (iface->invalid) + iface->invalid = 1; + else + nc_string_dup(&iface->parent, ifp->name); + } +} + int nc_interfaces_create_topology(nc_handle_t *nh, nc_var_array_t *errs) { - unsigned int i; + unsigned int i; if(!nh || !errs) return -1; @@ -507,6 +548,14 @@ if (ifp->type == NC_IFTYPE_VLAN && ifp->vlan) { if(nc_vlan_bind(ifp, nh, errs) < 0) return -1; + } else + if (ifp->type == NC_IFTYPE_TEAM) { + if (ifp->bonding) + nc_team_bind(ifp, nh); + } else + if (ifp->type == NC_IFTYPE_OVS) { + if (ifp->bridge) + nc_ovs_bridge_bind(ifp, nh); } } return 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/netcontrol-0.3.0/src/nctest.c new/netcontrol-0.3.1/src/nctest.c --- old/netcontrol-0.3.0/src/nctest.c 2013-03-26 13:44:08.000000000 +0100 +++ new/netcontrol-0.3.1/src/nctest.c 2016-05-20 17:40:06.000000000 +0200 @@ -213,8 +213,8 @@ ret = 1; goto usage; } break; - case OPT_IFACE_LIST: /* <count> [flags] */ - if(count <= 0 || flags > 3 || ifname || macstr || xfile) { + case OPT_IFACE_LIST: /* [count] [flags] */ + if(count < 0 || flags > 3 || ifname || macstr || xfile) { ret = 1; goto usage; } break; @@ -299,7 +299,13 @@ /* ================================================= */ case OPT_IFACE_LIST: /* <count> [flags] */ { - names = calloc(nnames, sizeof(char *)); + if (nnames <= 0 && (nnames = ncf_num_of_interfaces(ncf, flags)) <= 0) { + fprintf(stderr, "can't get number of %s interfaces\n", + get_flags_descr(flags)); + return -1; + } + + names = calloc(nnames + 1, sizeof(char *)); if(!names) { fprintf(stderr, "can't allocate names array\n"); return -1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/netcontrol-0.3.0/src/netcf-xml.c new/netcontrol-0.3.1/src/netcf-xml.c --- old/netcontrol-0.3.0/src/netcf-xml.c 2013-03-26 17:34:36.000000000 +0100 +++ new/netcontrol-0.3.1/src/netcf-xml.c 2016-05-20 17:40:06.000000000 +0200 @@ -37,6 +37,7 @@ #include <assert.h> #include <sys/socket.h> #include <netinet/in.h> +#include <net/if_arp.h> #include <arpa/inet.h> #include <sutils.h> @@ -243,6 +244,9 @@ if(!syntax || !handle || !ifp || !ifp->name) return -1; + if(syntax->strict && ifp->arp_type != ARPHRD_ETHER) + return 1; + if(__map_iftype_to_netcf(ifp->type) == NC_IFTYPE_UNKNOWN) return 1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/netcontrol-0.3.0/src/ntypes.h new/netcontrol-0.3.1/src/ntypes.h --- old/netcontrol-0.3.0/src/ntypes.h 2013-03-26 13:44:08.000000000 +0100 +++ new/netcontrol-0.3.1/src/ntypes.h 2016-05-20 17:40:06.000000000 +0200 @@ -92,6 +92,10 @@ NC_IFTYPE_TUN, NC_IFTYPE_TAP, NC_IFTYPE_DUMMY, + NC_IFTYPE_OVS, + NC_IFTYPE_TEAM, + NC_IFTYPE_MACVLAN, + NC_IFTYPE_MACVTAP, } nc_iftype_t; /* diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/netcontrol-0.3.0/src/sysfs.c new/netcontrol-0.3.1/src/sysfs.c --- old/netcontrol-0.3.0/src/sysfs.c 2013-03-26 13:44:08.000000000 +0100 +++ new/netcontrol-0.3.1/src/sysfs.c 2016-05-20 17:40:06.000000000 +0200 @@ -191,50 +191,49 @@ } int -nc_sysfs_get_bonding_parent(const char *name, char **parent) +nc_sysfs_netif_get_linkpath(const char *name, const char *attr, char **res) { char path[PATH_MAX + 1] = {'\0'}; - char *res = NULL, *ptr; snprintf(path, sizeof(path), "%s/%s/%s", - NC_SYSFS_CLASS_NET_PATH, name, "master"); - - if(nc_readlink(path, &res) == 0) { - ptr = strrchr(res, '/'); - ptr = ptr ? ptr + 1 : res; + NC_SYSFS_CLASS_NET_PATH, name, attr); - if(nc_string_dup(parent, ptr) == 0) { - free(res); - return 0; - } - free(res); - } - return -1; + return nc_readlink(path, res); } int -nc_sysfs_get_bridge_parent(const char *name, char **parent) +nc_sysfs_netif_get_linkbase(const char *name, const char *attr, char **res) { - char path[PATH_MAX + 1] = {'\0'}; - char *res = NULL, *ptr; - - snprintf(path, sizeof(path), "%s/%s/%s", - NC_SYSFS_CLASS_NET_PATH, name, "brport/bridge"); + char *path = NULL, *ptr; - if(nc_readlink(path, &res) == 0) { - ptr = strrchr(res, '/'); - ptr = ptr ? ptr + 1 : res; + if (nc_sysfs_netif_get_linkpath(name, attr, &path) == 0) { + ptr = strrchr(path, '/'); + ptr = ptr ? ptr + 1 : path; - if(nc_string_dup(parent, ptr) == 0) { - free(res); + if(nc_string_dup(res, ptr) == 0) { + free(path); return 0; } - free(res); + free(path); } return -1; } int +nc_sysfs_get_bonding_parent(const char *name, char **parent) +{ + if (!nc_sysfs_netif_exists(name, "bonding_slave")) + return -1; + return nc_sysfs_netif_get_linkbase(name, "master", parent); +} + +int +nc_sysfs_get_bridge_parent(const char *name, char **parent) +{ + return nc_sysfs_netif_get_linkbase(name, "brport/bridge", parent); +} + +int nc_sysfs_bonding_get_slaves(const char *master, nc_string_array_t *list) { return __nc_sysfs_read_list(NC_SYSFS_CLASS_NET_PATH, master, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/netcontrol-0.3.0/src/sysfs.h new/netcontrol-0.3.1/src/sysfs.h --- old/netcontrol-0.3.0/src/sysfs.h 2013-03-26 13:44:08.000000000 +0100 +++ new/netcontrol-0.3.1/src/sysfs.h 2016-05-20 17:40:06.000000000 +0200 @@ -62,5 +62,7 @@ int nc_sysfs_netif_get_long(const char *, const char *, long *); int nc_sysfs_netif_get_ulong(const char *, const char *, unsigned long *); int nc_sysfs_netif_get_bus_id(const char *, char **); +int nc_sysfs_netif_get_linkpath(const char *, const char *, char **); +int nc_sysfs_netif_get_linkbase(const char *, const char *, char **); #endif /* __NETCONTROL_SYSFS_H */