Bug#433568: [PATCH] Add vlan support, based on YunQiang Su patch and Philipp Kern's rewrite, with own additions. Closes: #433568

2016-04-23 Thread Philipp Kern
On Fri, Apr 15, 2016 at 03:17:00AM +0100, Dimitri John Ledkov wrote:
> ---
> 
>  Changes since last version:
>  - Corrected Philipp's name
>  - Adjusted vlan_failed text message
>  - Adding a di_error if vlan_id is preseeded and not supported
>  - Added NetworkManager vlan type
>  - Sent templates for review

>From a patch point of view I'm mostly happy. But this should incorporate the
newly suggested templates as well. Plus there are a few nits below.

> +netcfg (1.139) UNRELEASED; urgency=medium
> +
> +  * Add vlan support, based on YunQiang Su patch and Philipp Kern's
> +rewrite, with own additions. Closes: #433568

Please capitalize VLAN and put Closes into parantheses.

Suggested patch description:

Add VLAN support.

This is based on YunQiang Su patch and Philipp Kern's rewrite, with own
additions.

Closes: #433568

> +
> + -- Dimitri John Ledkov   Mon, 04 Apr 2016 12:18:08 +0100
> +
>  netcfg (1.138) unstable; urgency=medium
>  
>[ Hendrik Brueckner ]
> diff --git a/debian/netcfg-common.templates b/debian/netcfg-common.templates
> index 2b77936..ebbfbb3 100644
> --- a/debian/netcfg-common.templates
> +++ b/debian/netcfg-common.templates
> @@ -26,6 +26,34 @@ _Description: Domain name:
>   If you are setting up a home network, you can make something up, but make
>   sure you use the same domain name on all your computers.
>  
> +Template: netcfg/use_vlan
> +Type: boolean
> +Default: false
> +# :sl6:
> +_Description: Are you connected to an IEEE 802.1Q VLAN trunk port?
> + Virtual LAN (VLAN) is a concept of partitioning a physical network to create
> + distinct broadcast domains. Packets can be marked for different IDs by
> + tagging, so that a single interconnect (trunk) may be used to transport
> + data for various VLANs.
> + .
> + If your network interface is directly connected to a VLAN trunk port,
> + specifying a VLAN ID may be necessary to get a working connection.
> +
> +Template: netcfg/vlan_id
> +Type: string
> +# :sl6:
> +_Description: VLAN ID (1-4094):
> + If your network interface is directly connected to a VLAN trunk port,
> + specifying a VLAN ID may be necessary to get a working connection.
> +
> +Template: netcfg/vlan_failed
> +Type: error
> +# :sl6:
> +_Description: Error setting up VLAN
> + The command used to set up VLAN during the installation returned an
> + error, please check installer logs, or go back and try another
> + configuration.
> +
>  Template: netcfg/get_nameservers
>  Type: string
>  # :sl1:
> @@ -371,4 +399,3 @@ _Choices: ${essid_list} Enter ESSID manually
>  # :sl1:
>  _Description: Wireless network:
>   Select the wireless network to use during the installation process.
> -
> diff --git a/dhcp.c b/dhcp.c
> index fe06950..9476bac 100644
> --- a/dhcp.c
> +++ b/dhcp.c
> @@ -459,7 +459,7 @@ int netcfg_activate_dhcp (struct debconfclient *client, 
> struct netcfg_interface
>  kill_dhcp_client();
>  loop_setup();
>  
> -interface_up(interface->name);
> +netcfg_interface_up(interface);
>  
>  for (;;) {
>  di_debug("State is now %i", state);
> diff --git a/netcfg-common.c b/netcfg-common.c
> index c6d1d8d..ac2c6df 100644
> --- a/netcfg-common.c
> +++ b/netcfg-common.c
> @@ -267,7 +267,7 @@ int is_raw_80211(const char *iface)
>  
>  #if defined(__s390__)
>  // Layer 3 qeth on s390(x) cannot do arping to test gateway reachability.
> -int is_layer3_qeth(const char *iface)
> +int is_layer3_qeth(const struct netcfg_interface *interface)
>  {
>  const int bufsize = 1024;
>  int retval = 0;
> @@ -277,6 +277,12 @@ int is_layer3_qeth(const char *iface)
>  ssize_t slen;
>  char* driver;
>  int fd;
> +char* iface;
> +
> +if (interface->parentif)
> +iface = interface->parentif;
> +else
> +iface = interface->name;
>  
>  // This is sufficient for both /driver and /layer2.
>  len = strlen(SYSCLASSNET) + strlen(iface) + strlen("/device/driver") + 1;
> @@ -329,7 +335,7 @@ out:
>  return retval;
>  }
>  #else
> -int is_layer3_qeth(const char *iface __attribute__((unused)))
> +int is_layer3_qeth(const struct netcfg_interface *interface  
> __attribute__((unused)))
>  {
>  return 0;
>  }
> @@ -1338,6 +1344,24 @@ void interface_down (const char *if_name)
>  }
>  }
>  
> +void netcfg_interface_up (const struct netcfg_interface *iface)
> +{
> + if (iface->parentif)
> + interface_up (iface->parentif);
> +
> + if (iface->name)
> + interface_up (iface->name);
> +}
> +
> +void netcfg_interface_down (const struct netcfg_interface *iface)
> +{
> + if (iface->name)
> + interface_down (iface->name);
> +
> + if (iface->parentif)
> + interface_down (iface->parentif);
> +}
> +
>  void parse_args (int argc, char ** argv)
>  {
>  if (argc == 2) {
> @@ -1528,7 +1552,7 @@ int netcfg_detect_link(struct debconfclient *client, 
> const struct netcfg_interfa
>  if (ethtool_lite(if_name) == 

Bug#433568: [PATCH] Add vlan support, based on YunQiang Su patch and Philipp Kern's rewrite, with own additions. Closes: #433568

2016-04-14 Thread Dimitri John Ledkov
---

 Changes since last version:
 - Corrected Philipp's name
 - Adjusted vlan_failed text message
 - Adding a di_error if vlan_id is preseeded and not supported
 - Added NetworkManager vlan type
 - Sent templates for review

 Makefile   |   2 +-
 debian/changelog   |   7 +++
 debian/netcfg-common.templates |  29 +++-
 dhcp.c |   2 +-
 netcfg-common.c|  32 +++--
 netcfg.c   |  20 +---
 netcfg.h   |  11 +
 nm-conf.c  |  35 +-
 nm-conf.h  |  10 +++-
 static.c   |  12 ++---
 vlan.c | 101 +
 wireless.c |   4 +-
 write_interface.c  |  19 +++-
 13 files changed, 260 insertions(+), 24 deletions(-)
 create mode 100644 vlan.c

diff --git a/Makefile b/Makefile
index a15d476..03343c9 100644
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@ TARGETS ?= netcfg-static netcfg
 
 LDOPTS = -ldebconfclient -ldebian-installer
 CFLAGS = -W -Wall -Werror -DNDEBUG 
-DNETCFG_VERSION="\"$(NETCFG_VERSION)\"" -I.
-COMMON_OBJS= netcfg-common.o wireless.o write_interface.o ipv6.o
+COMMON_OBJS= netcfg-common.o wireless.o write_interface.o ipv6.o vlan.o
 NETCFG_O   = netcfg.o dhcp.o static.o ethtool-lite.o wpa.o wpa_ctrl.o 
rdnssd.o autoconfig.o
 NETCFG_STATIC_O= netcfg-static.o static.o ethtool-lite.o
 
diff --git a/debian/changelog b/debian/changelog
index f3dd40c..2ed40a2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+netcfg (1.139) UNRELEASED; urgency=medium
+
+  * Add vlan support, based on YunQiang Su patch and Philipp Kern's
+rewrite, with own additions. Closes: #433568
+
+ -- Dimitri John Ledkov   Mon, 04 Apr 2016 12:18:08 +0100
+
 netcfg (1.138) unstable; urgency=medium
 
   [ Hendrik Brueckner ]
diff --git a/debian/netcfg-common.templates b/debian/netcfg-common.templates
index 2b77936..ebbfbb3 100644
--- a/debian/netcfg-common.templates
+++ b/debian/netcfg-common.templates
@@ -26,6 +26,34 @@ _Description: Domain name:
  If you are setting up a home network, you can make something up, but make
  sure you use the same domain name on all your computers.
 
+Template: netcfg/use_vlan
+Type: boolean
+Default: false
+# :sl6:
+_Description: Are you connected to an IEEE 802.1Q VLAN trunk port?
+ Virtual LAN (VLAN) is a concept of partitioning a physical network to create
+ distinct broadcast domains. Packets can be marked for different IDs by
+ tagging, so that a single interconnect (trunk) may be used to transport
+ data for various VLANs.
+ .
+ If your network interface is directly connected to a VLAN trunk port,
+ specifying a VLAN ID may be necessary to get a working connection.
+
+Template: netcfg/vlan_id
+Type: string
+# :sl6:
+_Description: VLAN ID (1-4094):
+ If your network interface is directly connected to a VLAN trunk port,
+ specifying a VLAN ID may be necessary to get a working connection.
+
+Template: netcfg/vlan_failed
+Type: error
+# :sl6:
+_Description: Error setting up VLAN
+ The command used to set up VLAN during the installation returned an
+ error, please check installer logs, or go back and try another
+ configuration.
+
 Template: netcfg/get_nameservers
 Type: string
 # :sl1:
@@ -371,4 +399,3 @@ _Choices: ${essid_list} Enter ESSID manually
 # :sl1:
 _Description: Wireless network:
  Select the wireless network to use during the installation process.
-
diff --git a/dhcp.c b/dhcp.c
index fe06950..9476bac 100644
--- a/dhcp.c
+++ b/dhcp.c
@@ -459,7 +459,7 @@ int netcfg_activate_dhcp (struct debconfclient *client, 
struct netcfg_interface
 kill_dhcp_client();
 loop_setup();
 
-interface_up(interface->name);
+netcfg_interface_up(interface);
 
 for (;;) {
 di_debug("State is now %i", state);
diff --git a/netcfg-common.c b/netcfg-common.c
index c6d1d8d..ac2c6df 100644
--- a/netcfg-common.c
+++ b/netcfg-common.c
@@ -267,7 +267,7 @@ int is_raw_80211(const char *iface)
 
 #if defined(__s390__)
 // Layer 3 qeth on s390(x) cannot do arping to test gateway reachability.
-int is_layer3_qeth(const char *iface)
+int is_layer3_qeth(const struct netcfg_interface *interface)
 {
 const int bufsize = 1024;
 int retval = 0;
@@ -277,6 +277,12 @@ int is_layer3_qeth(const char *iface)
 ssize_t slen;
 char* driver;
 int fd;
+char* iface;
+
+if (interface->parentif)
+iface = interface->parentif;
+else
+iface = interface->name;
 
 // This is sufficient for both /driver and /layer2.
 len = strlen(SYSCLASSNET) + strlen(iface) + strlen("/device/driver") + 1;
@@ -329,7 +335,7 @@ out:
 return retval;
 }
 #else
-int is_layer3_qeth(const char *iface __attribute__((unused)))
+int is_layer3_qeth(const struct netcfg_interface *interface  
__attribute__((unused)))
 {