Skip to content

Commit

Permalink
[dhcp_relay] Upgrade dhcp_relay container to bookworm (#17783)
Browse files Browse the repository at this point in the history
* [dhcp_relay] Update dhcp_relay to bookworm
  • Loading branch information
yaqiangz authored and pull[bot] committed Jan 19, 2025
1 parent 6bf9007 commit 504ebe6
Show file tree
Hide file tree
Showing 16 changed files with 161 additions and 213 deletions.
2 changes: 1 addition & 1 deletion dockers/docker-dhcp-relay/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %}
FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}}
FROM docker-config-engine-bookworm-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}}

ARG docker_container_name
ARG image_version
Expand Down
8 changes: 3 additions & 5 deletions rules/docker-dhcp-relay.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ $(DOCKER_DHCP_RELAY)_PATH = $(DOCKERS_PATH)/$(DOCKER_DHCP_RELAY_STEM)

$(DOCKER_DHCP_RELAY)_DEPENDS += $(ISC_DHCP_RELAY) $(SONIC_DHCPMON) $(SONIC_DHCPRELAY) $(LIBSWSSCOMMON) $(SONIC_RSYSLOG_PLUGIN)

$(DOCKER_DHCP_RELAY)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BULLSEYE)_DBG_DEPENDS)
$(DOCKER_DHCP_RELAY)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BOOKWORM)_DBG_DEPENDS)
$(DOCKER_DHCP_RELAY)_DBG_DEPENDS += $(ISC_DHCP_RELAY_DBG) $(SONIC_DHCPRELAY_DBG) $(SONIC_DHCPMON_DBG) $(SONIC_RSYSLOG_PLUGIN)

$(DOCKER_DHCP_RELAY)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BULLSEYE)_DBG_IMAGE_PACKAGES)
$(DOCKER_DHCP_RELAY)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BOOKWORM)_DBG_IMAGE_PACKAGES)

$(DOCKER_DHCP_RELAY)_LOAD_DOCKERS = $(DOCKER_CONFIG_ENGINE_BULLSEYE)
$(DOCKER_DHCP_RELAY)_LOAD_DOCKERS = $(DOCKER_CONFIG_ENGINE_BOOKWORM)

$(DOCKER_DHCP_RELAY)_INSTALL_PYTHON_WHEELS = $(SONIC_UTILITIES_PY3)
$(DOCKER_DHCP_RELAY)_INSTALL_DEBS = $(PYTHON3_SWSSCOMMON)
Expand All @@ -29,9 +29,7 @@ $(DOCKER_DHCP_RELAY)_SERVICE_BEFORE = ntp-config
$(DOCKER_DHCP_RELAY)_SERVICE_DEPENDENT_OF = swss

SONIC_DOCKER_IMAGES += $(DOCKER_DHCP_RELAY)
SONIC_BULLSEYE_DOCKERS += $(DOCKER_DHCP_RELAY)
SONIC_DOCKER_DBG_IMAGES += $(DOCKER_DHCP_RELAY_DBG)
SONIC_BULLSEYE_DBG_DOCKERS += $(DOCKER_DHCP_RELAY_DBG)

ifeq ($(INCLUDE_KUBERNETES),y)
$(DOCKER_DHCP_RELAY)_DEFAULT_FEATURE_OWNER = kube
Expand Down
4 changes: 2 additions & 2 deletions rules/isc-dhcp.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# isc-dhcp packages

ISC_DHCP_VERSION = 4.4.1
ISC_DHCP_VERSION_FULL = ${ISC_DHCP_VERSION}-2.3+deb11u2
ISC_DHCP_VERSION = 4.4.3-P1
ISC_DHCP_VERSION_FULL = ${ISC_DHCP_VERSION}-2

export ISC_DHCP_VERSION ISC_DHCP_VERSION_FULL

Expand Down
4 changes: 3 additions & 1 deletion sonic-slave-bookworm/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,9 @@ RUN apt-get update && apt-get install -y \
auditd \
# For protobuf
protobuf-compiler \
libprotobuf-dev
libprotobuf-dev \
# For sonic-dhcp6relay build
libjsoncpp-dev

{%- if CROSS_BUILD_ENVIRON == "y" %}
# Arm vs. amd64 versions conflict - remove amd64 packages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ Date: Thu, 25 Apr 2019 22:07:20 +0000
Subject: [PATCH] Customizable Option 82 circuit ID and remote ID fields

---
relay/dhcrelay.c | 171 ++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 147 insertions(+), 24 deletions(-)
relay/dhcrelay.c | 178 +++++++++++++++++++++++++++++++++++++++--------
1 file changed, 150 insertions(+), 28 deletions(-)

diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c
index 0cb2ef6..418b943 100644
index 3b9c71b..19843f7 100644
--- a/relay/dhcrelay.c
+++ b/relay/dhcrelay.c
@@ -75,6 +75,8 @@ int bad_circuit_id = 0; /* Circuit ID option in matching RAI option
Expand All @@ -20,7 +20,7 @@ index 0cb2ef6..418b943 100644
int max_hop_count = 10; /* Maximum hop count */

int no_daemon = 0;
@@ -151,10 +153,20 @@ static const char url[] =
@@ -160,10 +162,20 @@ static const char url[] =

char *progname;

Expand All @@ -42,7 +42,7 @@ index 0cb2ef6..418b943 100644
" [-A <length>] [-c <hops>]\n" \
" [-p <port> | -rp <relay-port>]\n" \
" [-pf <pid-file>] [--no-pid]\n"\
@@ -171,11 +183,11 @@ char *progname;
@@ -180,11 +192,11 @@ char *progname;
" -l lower0 [ ... -l lowerN]\n" \
" -u upper0 [ ... -u upperN]\n" \
" lower (client link): [address%%]interface[#index]\n" \
Expand All @@ -56,7 +56,7 @@ index 0cb2ef6..418b943 100644
" [-A <length>] [-c <hops>] [-p <port>]\n" \
" [-pf <pid-file>] [--no-pid]\n"\
" [-m append|replace|forward|discard]\n" \
@@ -190,13 +202,13 @@ char *progname;
@@ -199,13 +211,13 @@ char *progname;
" -l lower0 [ ... -l lowerN]\n" \
" -u upper0 [ ... -u upperN]\n" \
" lower (client link): [address%%]interface[#index]\n" \
Expand All @@ -72,10 +72,10 @@ index 0cb2ef6..418b943 100644
" [-p <port> | -rp <relay-port>]\n" \
" [-pf <pid-file>] [--no-pid]\n" \
" [-m append|replace|forward|discard]\n" \
@@ -204,18 +216,18 @@ char *progname;
@@ -213,18 +225,18 @@ char *progname;
" [-iu interface0 [ ... -iu interfaceN]\n" \
" [-id interface0 [ ... -id interfaceN]\n" \
" [-U interface]\n" \
" [-U interface] [-g <ip-address>]\n" \
-" server0 [ ... serverN]\n\n" \
+" server0 [ ... serverN]\n\n" DHCRELAY_OPTION82_USAGE \
" %s {--version|--help|-h}"
Expand All @@ -88,13 +88,13 @@ index 0cb2ef6..418b943 100644
" [-i interface0 [ ... -i interfaceN]\n" \
" [-iu interface0 [ ... -iu interfaceN]\n" \
" [-id interface0 [ ... -id interfaceN]\n" \
" [-U interface]\n" \
" [-U interface] [-g <ip-address>]\n" \
-" server0 [ ... serverN]\n\n" \
+" server0 [ ... serverN]\n\n" DHCRELAY_OPTION82_USAGE \
" %s {--version|--help|-h}"
#endif
#endif
@@ -471,6 +483,15 @@ main(int argc, char **argv) {
@@ -480,6 +492,15 @@ main(int argc, char **argv) {
local_family_set = 1;
local_family = AF_INET;
#endif
Expand All @@ -110,7 +110,7 @@ index 0cb2ef6..418b943 100644
add_agent_options = 1;
} else if (!strcmp(argv[i], "-A")) {
#ifdef DHCPv6
@@ -1171,6 +1192,81 @@ find_interface_by_agent_option(struct dhcp_packet *packet,
@@ -1207,6 +1228,81 @@ find_interface_by_agent_option(struct dhcp_packet *packet,
return (-1);
}

Expand Down Expand Up @@ -192,7 +192,7 @@ index 0cb2ef6..418b943 100644
/*
* Examine a packet to see if it's a candidate to have a Relay
* Agent Information option tacked onto its tail. If it is, tack
@@ -1180,9 +1276,12 @@ static int
@@ -1216,9 +1312,12 @@ int
add_relay_agent_options(struct interface_info *ip, struct dhcp_packet *packet,
unsigned length, struct in_addr giaddr) {
int is_dhcp = 0, mms;
Expand All @@ -206,7 +206,7 @@ index 0cb2ef6..418b943 100644

/* If we're not adding agent options to packets, we can skip
this. */
@@ -1316,17 +1415,40 @@ add_relay_agent_options(struct interface_info *ip, struct dhcp_packet *packet,
@@ -1357,17 +1456,40 @@ add_relay_agent_options(struct interface_info *ip, struct dhcp_packet *packet,
op = sp;
#endif

Expand Down Expand Up @@ -258,7 +258,7 @@ index 0cb2ef6..418b943 100644
}

if (adding_link_select) {
@@ -1351,7 +1473,7 @@ add_relay_agent_options(struct interface_info *ip, struct dhcp_packet *packet,
@@ -1392,7 +1514,7 @@ add_relay_agent_options(struct interface_info *ip, struct dhcp_packet *packet,
* If not, forward without adding the option.
*/
if (max - sp >= optlen + 3) {
Expand All @@ -267,7 +267,7 @@ index 0cb2ef6..418b943 100644

/* Okay, cons up *our* Relay Agent Information option. */
*sp++ = DHO_DHCP_AGENT_OPTIONS;
@@ -1359,16 +1481,16 @@ add_relay_agent_options(struct interface_info *ip, struct dhcp_packet *packet,
@@ -1400,16 +1522,16 @@ add_relay_agent_options(struct interface_info *ip, struct dhcp_packet *packet,

/* Copy in the circuit id... */
*sp++ = RAI_CIRCUIT_ID;
Expand All @@ -292,5 +292,5 @@ index 0cb2ef6..418b943 100644

/* RFC3527: Use the inbound packet's interface address in
--
2.17.1
2.25.1

Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Subject: [PATCH] Support for loading port alias map file to replace port name
1 file changed, 104 insertions(+), 1 deletion(-)

diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c
index 00c81d3..54f132a 100644
index 0d9b2e7..b72b1bc 100644
--- a/relay/dhcrelay.c
+++ b/relay/dhcrelay.c
@@ -129,6 +129,14 @@ static void setup_streams(void);
@@ -133,6 +133,14 @@ static void setup_streams(void);
char *dhcrelay_sub_id = NULL;
#endif

Expand All @@ -24,21 +24,21 @@ index 00c81d3..54f132a 100644
+static struct interface_name_alias_tuple *g_interface_name_alias_map = NULL;
+static size_t g_interface_name_alias_map_size = 0;
+
#ifndef UNIT_TEST
static void do_relay4(struct interface_info *, struct dhcp_packet *,
unsigned int, unsigned int, struct iaddr,
struct hardware *);
@@ -143,6 +151,10 @@ static int strip_relay_agent_options(struct interface_info *,

@@ -152,6 +160,10 @@ extern int strip_relay_agent_options(struct interface_info *,
#ifndef UNIT_TEST
static void request_v4_interface(const char* name, int flags);

+static int load_interface_alias_map(const char *port_alias_map_file_path);
+static int get_interface_alias_by_name(const char *if_name, char *if_alias_out);
+static void free_interface_alias_map(void);
+
static const char copyright[] =
"Copyright 2004-2018 Internet Systems Consortium.";
"Copyright 2004-2022 Internet Systems Consortium.";
static const char arr[] = "All rights reserved.";
@@ -158,7 +170,7 @@ char *progname;
@@ -167,7 +179,7 @@ char *progname;
"\n" \
" %%%% A single %%\n" \
" %%h Hostname of device\n" \
Expand All @@ -47,23 +47,23 @@ index 00c81d3..54f132a 100644
" %%P Hardware address of interface that generated the request\n" \
" %%C Client hardware address\n" \
" %%I DHCP relay agent IP Address\n" \
@@ -171,6 +183,7 @@ char *progname;
@@ -180,6 +192,7 @@ char *progname;
" [-p <port> | -rp <relay-port>]\n" \
" [-pf <pid-file>] [--no-pid]\n"\
" [-m append|replace|forward|discard]\n" \
+" [--name-alias-map-file <name-alias-map-file>]\n" \
" [-i interface0 [ ... -i interfaceN]\n" \
" [-iu interface0 [ ... -iu interfaceN]\n" \
" [-id interface0 [ ... -id interfaceN]\n" \
@@ -179,6 +192,7 @@ char *progname;
@@ -188,6 +201,7 @@ char *progname;
" %s -6 [-d] [-q] [-I] [-c <hops>]\n" \
" [-p <port> | -rp <relay-port>]\n" \
" [-pf <pid-file>] [--no-pid]\n" \
+" [--name-alias-map-file <name-alias-map-file>]\n" \
" [-s <subscriber-id>]\n" \
" -l lower0 [ ... -l lowerN]\n" \
" -u upper0 [ ... -u upperN]\n" \
@@ -619,6 +633,11 @@ main(int argc, char **argv) {
@@ -643,6 +657,11 @@ main(int argc, char **argv) {
no_dhcrelay_pid = ISC_TRUE;
} else if (!strcmp(argv[i], "--no-pid")) {
no_pid_file = ISC_TRUE;
Expand All @@ -75,26 +75,27 @@ index 00c81d3..54f132a 100644
} else if (argv[i][0] == '-') {
usage("Unknown command: %s", argv[i]);
} else {
@@ -841,6 +860,7 @@ main(int argc, char **argv) {
@@ -865,6 +884,7 @@ main(int argc, char **argv) {
dispatch();

/* In fact dispatch() never returns. */
+ free_interface_alias_map();
return (0);
}

@@ -1271,6 +1291,7 @@ format_relay_agent_rfc3046_msg(const struct interface_info *ip, struct dhcp_pack
@@ -1307,6 +1327,7 @@ format_relay_agent_rfc3046_msg(const struct interface_info *ip, struct dhcp_pack
*/
if (packet->htype && !packet->giaddr.s_addr) {
int ret = 0, vlanid = 0;
+ char ifalias[IFNAMSIZ] = { 0 };

ret = _bridgefdbquery(print_hw_addr(packet->htype, packet->hlen, packet->chaddr),
ifname,
@@ -1287,6 +1308,18 @@ format_relay_agent_rfc3046_msg(const struct interface_info *ip, struct dhcp_pack
@@ -1322,6 +1343,18 @@ format_relay_agent_rfc3046_msg(const struct interface_info *ip, struct dhcp_pack

strncpy(ifname, ip->name, IFNAMSIZ);
}
+
+ // Attempt to translate SONiC interface name to vendor alias
+ ret = get_interface_alias_by_name(ifname, ifalias);
+ if (ret < 0) {
Expand All @@ -106,11 +107,10 @@ index 00c81d3..54f132a 100644
+
+ strncpy(ifname, ifalias, IFNAMSIZ);
+ }
+
str = ifname;
}
break;
@@ -2313,3 +2346,73 @@ void request_v4_interface(const char* name, int flags) {
@@ -2361,3 +2394,73 @@ void request_v4_interface(const char* name, int flags) {
interface_snorf(tmp, (INTERFACE_REQUESTED | flags));
interface_dereference(&tmp, MDL);
}
Expand Down Expand Up @@ -185,5 +185,5 @@ index 00c81d3..54f132a 100644
+ g_interface_name_alias_map_size = 0;
+}
--
2.17.1
2.25.1

Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ Subject: [PATCH 1/3] Add --enable-use-sockets to configure flags in
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/debian/rules b/debian/rules
index d3fcc1d..2a7219d 100755
index dc2a9b1..3d12fb5 100755
--- a/debian/rules
+++ b/debian/rules
@@ -24,7 +24,7 @@ CFLAGS+=-D_PATH_DHCLIENT_CONF='\"/etc/dhcp/dhclient.conf\"'
@@ -23,7 +23,7 @@ CFLAGS+=-D_PATH_DHCLIENT_CONF='\"/etc/dhcp/dhclient.conf\"'
CFLAGS+=-D_PATH_DHCLIENT_DB='\"$(LEASE_PATH)/dhclient.leases\"'
CFLAGS+=-D_PATH_DHCLIENT6_DB='\"$(LEASE_PATH)/dhclient6.leases\"'

-CONFFLAGS=--prefix=/usr --with-libbind=/usr --enable-log-pid --enable-paranoia
+CONFFLAGS=--prefix=/usr --with-libbind=/usr --enable-log-pid --enable-paranoia --enable-use-sockets
-CONFFLAGS+=--prefix=/usr --enable-log-pid --enable-paranoia
+CONFFLAGS+=--prefix=/usr --enable-log-pid --enable-paranoia --enable-use-sockets

include /usr/share/dpkg/buildtools.mk
# cross-architecture building
ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
--
2.17.1
2.25.1

Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Subject: [PATCH 2/3] Bugfix: Ensure HAVE_SO_BINDTODEVICE has a chance to be
1 file changed, 120 insertions(+), 119 deletions(-)

diff --git a/includes/osdep.h b/includes/osdep.h
index cfae90b..f07c43c 100644
index 0742858..dfccb8c 100644
--- a/includes/osdep.h
+++ b/includes/osdep.h
@@ -48,37 +48,6 @@
@@ -47,37 +47,6 @@
#define BYTE_ORDER DHCP_BYTE_ORDER
#endif /* BYTE_ORDER */

Expand Down Expand Up @@ -50,7 +50,7 @@ index cfae90b..f07c43c 100644
#if !defined (TIME_MAX)
# define TIME_MAX 2147483647
#endif
@@ -91,94 +60,6 @@
@@ -90,98 +59,10 @@
# define vsnprintf isc_print_vsnprintf
#endif

Expand Down Expand Up @@ -102,6 +102,10 @@ index cfae90b..f07c43c 100644
-# define USE_UPF_RECEIVE
-#endif
-
#if defined (SO_BINDTODEVICE) && !defined (HAVE_SO_BINDTODEVICE)
# define HAVE_SO_BINDTODEVICE
#endif

-/* Porting::
-
- If you add support for sending packets directly out an interface,
Expand Down Expand Up @@ -145,7 +149,7 @@ index cfae90b..f07c43c 100644
/* If we don't have a DLPI packet filter, we have to filter in userland.
Probably not worth doing, actually. */
#if defined (USE_DLPI_RECEIVE) && !defined (USE_DLPI_PFMOD)
@@ -288,4 +169,124 @@
@@ -287,4 +168,124 @@
# define STDERR_FILENO 2
#endif

Expand Down Expand Up @@ -271,5 +275,5 @@ index cfae90b..f07c43c 100644
+
#endif /* __ISC_DHCP_OSDEP_H__ */
--
2.17.1
2.25.1

Loading

0 comments on commit 504ebe6

Please sign in to comment.