Bug#852480: ipconfig dhcp only works on first kernel interface

2017-12-25 Thread Tomasz Nitecki
Hey,

I can confirm that this issue also affects buster running on a server
with dual ethernet ports (rather unsuprisingly as buster is shipped with
klibc 2.0.4-9) and that using klibc 2.0.4-10 (built from source) fixes
this issue. Thanks for the fix!


Regards,
T.



signature.asc
Description: OpenPGP digital signature


Bug#852480: ipconfig dhcp only works on first kernel interface

2017-07-26 Thread Baptiste Jonglez
Hi,

I can confirm the bug on a PCengines APU2 with three network interfaces,
using klibc 2.0.4-9 (Debian stretch): the initramfs repeatedly fails to
get an IP address through DHCP, even though DHCP responses are correctly
sent back by the server.

The patch from Steve has been integrated in the klibc source package as
2.0.4-10, but not yet released.  I built this 2.0.4-10 version and tested
it, and it indeed fixes the issue.  Would it be possible to release it?

Thanks!
Baptiste


signature.asc
Description: PGP signature


Bug#852480: ipconfig dhcp only works on first kernel interface

2017-01-24 Thread Steve Langasek
Package: klibc
Version: 2.0.4-9
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu zesty ubuntu-patch

If ipconfig from klibc tries to send dhcp requests on multiple interfaces,
it will only succeed in configuring the network if the first answer it gets
is from the interface that's first in the kernel enumeration.

This bug has been reported in Ubuntu at
.

The attached debdiff resolves the issue, by opening a separate socket for
each interface ipconfig tries to configure and correctly processing the
responses on each socket.

-- 
Steve Langasek   Give me a lever long enough and a Free OS
Debian Developer   to set it on, and I can move the world.
Ubuntu Developerhttp://www.debian.org/
slanga...@ubuntu.com vor...@debian.org
From 8dae2546a0a69ffafcd8ef1fc5b00642b853f154 Mon Sep 17 00:00:00 2001
From: Steve Langasek 
Date: Tue, 24 Jan 2017 13:05:19 -0800
Subject: [PATCH] debian/patches/dhcp-one-socket-per-interface.patch: Use
 separate sockets for DHCP from multiple interfaces.  Thanks to Jay Vosburgh
 .  Closes LP: #1652348.

---
 debian/changelog   |   3 +
 debian/patches/dhcp-one-socket-per-interface.patch | 271 +
 debian/patches/series  |   1 +
 3 files changed, 275 insertions(+)
 create mode 100644 debian/patches/dhcp-one-socket-per-interface.patch

diff --git a/debian/changelog b/debian/changelog
index ebdfaa3..42b7028 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,6 +4,9 @@ klibc (2.0.4-10) UNRELEASED; urgency=medium
 DHCPREQUEST and DHCPDISCOVER.  Thanks to Mathieu Trudel-Lapierre
 .  Closes: #733988, LP:
 #1327412.
+  * debian/patches/dhcp-one-socket-per-interface.patch: Use separate
+sockets for DHCP from multiple interfaces.  Thanks to Jay Vosburgh
+.  Closes LP: #1652348.
 
  -- Steve Langasek   Tue, 24 Jan 2017 07:25:36 -0800
 
diff --git a/debian/patches/dhcp-one-socket-per-interface.patch b/debian/patches/dhcp-one-socket-per-interface.patch
new file mode 100644
index 000..e1da799
--- /dev/null
+++ b/debian/patches/dhcp-one-socket-per-interface.patch
@@ -0,0 +1,271 @@
+Author: Jay Vosburgh 
+Description: Use separate sockets for DHCP from multiple interfaces
+ Previously ipconfig would use a single multiplexed packet socket to listen
+ for DHCP responses on multiple interfaces.  This fails if the interface that
+ responds is not the first one enumerated by the kernel, because ipconfig
+ looks for responses in interface order and is throwing them away if they're
+ not a proper match.
+ .
+ Fix this by using a separate socket for each interface so that each response
+ is processed in a correct context.
+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1652348
+
+diff --git a/usr/kinit/ipconfig/main.c b/usr/kinit/ipconfig/main.c
+index 7be2a1fcb5af..e00f049173fb 100644
+--- a/usr/kinit/ipconfig/main.c
 b/usr/kinit/ipconfig/main.c
+@@ -30,6 +30,7 @@ static unsigned int default_caps = CAP_DHCP | CAP_BOOTP | CAP_RARP;
+ static int loop_timeout = -1;
+ static int configured;
+ static int bringup_first = 0;
++static int n_devices = 0;
+ 
+ /* DHCP vendor class identifier */
+ char vendor_class_identifier[260];
+@@ -220,6 +221,7 @@ static void complete_device(struct netdev *dev)
+ 	configure_device(dev);
+ 	dump_device_config(dev);
+ 	print_device_config(dev);
++	packet_close(dev);
+ 
+ 	++configured;
+ 
+@@ -374,34 +376,35 @@ struct netdev *ifaces;
+  *  0 = No dhcp/bootp packet was received
+  *  1 = A packet was received and handled
+  */
+-static int do_pkt_recv(int pkt_fd, time_t now)
++static int do_pkt_recv(int nr, struct pollfd *fds, time_t now)
+ {
+-	int ret = 0;
++	int i, ret = 0;
+ 	struct state *s;
+ 
+-	for (s = slist; s; s = s->next)
+-		ret |= process_receive_event(s, now);
++	for (i = 0, s = slist; s && nr; s = s->next, i++) {
++		if (fds[i].revents & POLLRDNORM) {
++			ret |= process_receive_event(s, now);
++			nr--;
++		}
++	}
+ 	return ret;
+ }
+ 
+ static int loop(void)
+ {
+-#define NR_FDS	1
+-	struct pollfd fds[NR_FDS];
++	struct pollfd *fds;
+ 	struct state *s;
+-	int pkt_fd;
+-	int nr = 0, rc = 0;
++	int i, nr = 0, rc = 0;
+ 	struct timeval now, prev;
+ 	time_t start;
+ 
+-	pkt_fd = packet_open();
+-	if (pkt_fd == -1) {
+-		perror("packet_open");
+-		return -1;
++	fds = malloc(sizeof(struct pollfd) * n_devices);
++	if (!fds) {
++		fprintf(stderr, "malloc failed\n");
++		goto bail;
+ 	}
+ 
+-	fds[0].fd = pkt_fd;
+-	fds[0].events = POLLRDNORM;
++	memset(fds, 0, sizeof(*fds));
+ 
+ 	gettimeofday(, NULL);
+ 	start = now.tv_sec;
+@@ -412,9 +415,12 @@ static int loop(void)
+ 		int timeout_ms;
+ 		int x;
+ 
+-		for (s = slist; s; s