Skip to contentSkip to conversation

gdhcp/client: Don't attach a DHCP client to veth* devices

RFC PATCH In review Zoltán Böszörményi 2 participants 2 messages Jul 11, 2023 – Aug 16, 2023

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 gdhcp/client: Don't attach a DHCP client to veth* devices

veth* interfaces are created as sub-interfaces for a bridge by Docker and not actually used for communication in my use case.

But Connman tries to use DHCPv4 on them and they end up with an IP address in the 169.254.x.x range with routes added to them, which extra routes in turn break networking on the host.

This is a very bad approach, hence the RFC status of the patch. It may be better if Connman didn't add routing for interfaces with only a link local address. Please give me some pointers so I can implement it properly.

---
 gdhcp/client.c | 5 +++++
 1 file changed, 5 insertions(+)
gdhcp/client.c +5 -0
index 82017692..36c233a1 100644
@@ -1175,6 +1175,11 @@ GDHCPClient *g_dhcp_client_new(GDHCPType type,
 		goto error;
 	}
 
+	if (strncmp(dhcp_client->interface, "veth", 4) == 0) {
+		*error = G_DHCP_CLIENT_ERROR_INTERFACE_IN_USE;
+		goto error;
+	}
+
 	if (!interface_is_up(ifindex)) {
 		*error = G_DHCP_CLIENT_ERROR_INTERFACE_DOWN;
 		goto error;
Signature · 1 line
2.41.0
#1 lore raw

Hi Zoltan,

Quoted 23 lines

veth* interfaces are created as sub-interfaces for a bridge by Docker and not actually used for communication in my use case.

But Connman tries to use DHCPv4 on them and they end up with an IP address in the 169.254.x.x range with routes added to them, which extra routes in turn break networking on the host.

This is a very bad approach, hence the RFC status of the patch. It may be better if Connman didn't add routing for interfaces with only a link local address. Please give me some pointers so I can implement it properly.

---
gdhcp/client.c | 5 +++++

1 file changed, 5 insertions(+)
gdhcp/client.c +0 -0
index 82017692..36c233a1 100644
@@ -1175,6 +1175,11 @@ GDHCPClient *g_dhcp_client_new(GDHCPType type,
 goto error;

gdhcp/client.c GDHCPClient *g_dhcp_client_new(GDHCPType type, · line 1185

Quoted 10 lines
gdhcp/client.c +5 -0
 }
 
+ if (strncmp(dhcp_client->interface, "veth", 4) == 0) {
+ *error = G_DHCP_CLIENT_ERROR_INTERFACE_IN_USE;
+ goto error;
+ }
+
 if (!interface_is_up(ifindex)) {
 *error = G_DHCP_CLIENT_ERROR_INTERFACE_DOWN;
 goto error;

bad approach indeed. No hard code interface name matching in the DHCP client code.

Regards

Marcel