[dhcp_relay] Upgrade dhcp_relay container to bookworm (#17783)

* [dhcp_relay] Update dhcp_relay to bookworm
This commit is contained in:
Yaqiang Zhu 2024-03-22 00:27:51 +08:00 committed by GitHub
parent 6ada967685
commit b3845b620d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 160 additions and 212 deletions

View File

@ -1,5 +1,5 @@
{% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} {% 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 docker_container_name
ARG image_version ARG image_version

View File

@ -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)_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_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_PYTHON_WHEELS = $(SONIC_UTILITIES_PY3)
$(DOCKER_DHCP_RELAY)_INSTALL_DEBS = $(PYTHON3_SWSSCOMMON) $(DOCKER_DHCP_RELAY)_INSTALL_DEBS = $(PYTHON3_SWSSCOMMON)
@ -29,9 +29,7 @@ $(DOCKER_DHCP_RELAY)_SERVICE_BEFORE = ntp-config
$(DOCKER_DHCP_RELAY)_SERVICE_DEPENDENT_OF = swss $(DOCKER_DHCP_RELAY)_SERVICE_DEPENDENT_OF = swss
SONIC_DOCKER_IMAGES += $(DOCKER_DHCP_RELAY) SONIC_DOCKER_IMAGES += $(DOCKER_DHCP_RELAY)
SONIC_BULLSEYE_DOCKERS += $(DOCKER_DHCP_RELAY)
SONIC_DOCKER_DBG_IMAGES += $(DOCKER_DHCP_RELAY_DBG) SONIC_DOCKER_DBG_IMAGES += $(DOCKER_DHCP_RELAY_DBG)
SONIC_BULLSEYE_DBG_DOCKERS += $(DOCKER_DHCP_RELAY_DBG)
ifeq ($(INCLUDE_KUBERNETES),y) ifeq ($(INCLUDE_KUBERNETES),y)
$(DOCKER_DHCP_RELAY)_DEFAULT_FEATURE_OWNER = kube $(DOCKER_DHCP_RELAY)_DEFAULT_FEATURE_OWNER = kube

View File

@ -1,7 +1,7 @@
# isc-dhcp packages # isc-dhcp packages
ISC_DHCP_VERSION = 4.4.1 ISC_DHCP_VERSION = 4.4.3-P1
ISC_DHCP_VERSION_FULL = ${ISC_DHCP_VERSION}-2.3+deb11u2 ISC_DHCP_VERSION_FULL = ${ISC_DHCP_VERSION}-2
export ISC_DHCP_VERSION ISC_DHCP_VERSION_FULL export ISC_DHCP_VERSION ISC_DHCP_VERSION_FULL

View File

@ -418,7 +418,9 @@ RUN apt-get update && apt-get install -y \
auditd \ auditd \
# For protobuf # For protobuf
protobuf-compiler \ protobuf-compiler \
libprotobuf-dev libprotobuf-dev \
# For sonic-dhcp6relay build
libjsoncpp-dev
{%- if CROSS_BUILD_ENVIRON == "y" %} {%- if CROSS_BUILD_ENVIRON == "y" %}
# Arm vs. amd64 versions conflict - remove amd64 packages # Arm vs. amd64 versions conflict - remove amd64 packages

View File

@ -4,11 +4,11 @@ Date: Thu, 25 Apr 2019 22:07:20 +0000
Subject: [PATCH] Customizable Option 82 circuit ID and remote ID fields Subject: [PATCH] Customizable Option 82 circuit ID and remote ID fields
--- ---
relay/dhcrelay.c | 171 ++++++++++++++++++++++++++++++++++++++++------- relay/dhcrelay.c | 178 +++++++++++++++++++++++++++++++++++++++--------
1 file changed, 147 insertions(+), 24 deletions(-) 1 file changed, 150 insertions(+), 28 deletions(-)
diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c
index 0cb2ef6..418b943 100644 index 3b9c71b..19843f7 100644
--- a/relay/dhcrelay.c --- a/relay/dhcrelay.c
+++ b/relay/dhcrelay.c +++ b/relay/dhcrelay.c
@@ -75,6 +75,8 @@ int bad_circuit_id = 0; /* Circuit ID option in matching RAI option @@ -75,6 +75,8 @@ int bad_circuit_id = 0; /* Circuit ID option in matching RAI option
@ -20,7 +20,7 @@ index 0cb2ef6..418b943 100644
int max_hop_count = 10; /* Maximum hop count */ int max_hop_count = 10; /* Maximum hop count */
int no_daemon = 0; int no_daemon = 0;
@@ -151,10 +153,20 @@ static const char url[] = @@ -160,10 +162,20 @@ static const char url[] =
char *progname; char *progname;
@ -42,7 +42,7 @@ index 0cb2ef6..418b943 100644
" [-A <length>] [-c <hops>]\n" \ " [-A <length>] [-c <hops>]\n" \
" [-p <port> | -rp <relay-port>]\n" \ " [-p <port> | -rp <relay-port>]\n" \
" [-pf <pid-file>] [--no-pid]\n"\ " [-pf <pid-file>] [--no-pid]\n"\
@@ -171,11 +183,11 @@ char *progname; @@ -180,11 +192,11 @@ char *progname;
" -l lower0 [ ... -l lowerN]\n" \ " -l lower0 [ ... -l lowerN]\n" \
" -u upper0 [ ... -u upperN]\n" \ " -u upper0 [ ... -u upperN]\n" \
" lower (client link): [address%%]interface[#index]\n" \ " lower (client link): [address%%]interface[#index]\n" \
@ -56,7 +56,7 @@ index 0cb2ef6..418b943 100644
" [-A <length>] [-c <hops>] [-p <port>]\n" \ " [-A <length>] [-c <hops>] [-p <port>]\n" \
" [-pf <pid-file>] [--no-pid]\n"\ " [-pf <pid-file>] [--no-pid]\n"\
" [-m append|replace|forward|discard]\n" \ " [-m append|replace|forward|discard]\n" \
@@ -190,13 +202,13 @@ char *progname; @@ -199,13 +211,13 @@ char *progname;
" -l lower0 [ ... -l lowerN]\n" \ " -l lower0 [ ... -l lowerN]\n" \
" -u upper0 [ ... -u upperN]\n" \ " -u upper0 [ ... -u upperN]\n" \
" lower (client link): [address%%]interface[#index]\n" \ " lower (client link): [address%%]interface[#index]\n" \
@ -72,10 +72,10 @@ index 0cb2ef6..418b943 100644
" [-p <port> | -rp <relay-port>]\n" \ " [-p <port> | -rp <relay-port>]\n" \
" [-pf <pid-file>] [--no-pid]\n" \ " [-pf <pid-file>] [--no-pid]\n" \
" [-m append|replace|forward|discard]\n" \ " [-m append|replace|forward|discard]\n" \
@@ -204,18 +216,18 @@ char *progname; @@ -213,18 +225,18 @@ char *progname;
" [-iu interface0 [ ... -iu interfaceN]\n" \ " [-iu interface0 [ ... -iu interfaceN]\n" \
" [-id interface0 [ ... -id interfaceN]\n" \ " [-id interface0 [ ... -id interfaceN]\n" \
" [-U interface]\n" \ " [-U interface] [-g <ip-address>]\n" \
-" server0 [ ... serverN]\n\n" \ -" server0 [ ... serverN]\n\n" \
+" server0 [ ... serverN]\n\n" DHCRELAY_OPTION82_USAGE \ +" server0 [ ... serverN]\n\n" DHCRELAY_OPTION82_USAGE \
" %s {--version|--help|-h}" " %s {--version|--help|-h}"
@ -88,13 +88,13 @@ index 0cb2ef6..418b943 100644
" [-i interface0 [ ... -i interfaceN]\n" \ " [-i interface0 [ ... -i interfaceN]\n" \
" [-iu interface0 [ ... -iu interfaceN]\n" \ " [-iu interface0 [ ... -iu interfaceN]\n" \
" [-id interface0 [ ... -id interfaceN]\n" \ " [-id interface0 [ ... -id interfaceN]\n" \
" [-U interface]\n" \ " [-U interface] [-g <ip-address>]\n" \
-" server0 [ ... serverN]\n\n" \ -" server0 [ ... serverN]\n\n" \
+" server0 [ ... serverN]\n\n" DHCRELAY_OPTION82_USAGE \ +" server0 [ ... serverN]\n\n" DHCRELAY_OPTION82_USAGE \
" %s {--version|--help|-h}" " %s {--version|--help|-h}"
#endif #endif
#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_set = 1;
local_family = AF_INET; local_family = AF_INET;
#endif #endif
@ -110,7 +110,7 @@ index 0cb2ef6..418b943 100644
add_agent_options = 1; add_agent_options = 1;
} else if (!strcmp(argv[i], "-A")) { } else if (!strcmp(argv[i], "-A")) {
#ifdef DHCPv6 #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); return (-1);
} }
@ -192,7 +192,7 @@ index 0cb2ef6..418b943 100644
/* /*
* Examine a packet to see if it's a candidate to have a Relay * 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 * 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, add_relay_agent_options(struct interface_info *ip, struct dhcp_packet *packet,
unsigned length, struct in_addr giaddr) { unsigned length, struct in_addr giaddr) {
int is_dhcp = 0, mms; int is_dhcp = 0, mms;
@ -206,7 +206,7 @@ index 0cb2ef6..418b943 100644
/* If we're not adding agent options to packets, we can skip /* If we're not adding agent options to packets, we can skip
this. */ 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; op = sp;
#endif #endif
@ -258,7 +258,7 @@ index 0cb2ef6..418b943 100644
} }
if (adding_link_select) { 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 not, forward without adding the option.
*/ */
if (max - sp >= optlen + 3) { if (max - sp >= optlen + 3) {
@ -267,7 +267,7 @@ index 0cb2ef6..418b943 100644
/* Okay, cons up *our* Relay Agent Information option. */ /* Okay, cons up *our* Relay Agent Information option. */
*sp++ = DHO_DHCP_AGENT_OPTIONS; *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... */ /* Copy in the circuit id... */
*sp++ = RAI_CIRCUIT_ID; *sp++ = RAI_CIRCUIT_ID;
@ -292,5 +292,5 @@ index 0cb2ef6..418b943 100644
/* RFC3527: Use the inbound packet's interface address in /* RFC3527: Use the inbound packet's interface address in
-- --
2.17.1 2.25.1

View File

@ -9,10 +9,10 @@ Subject: [PATCH] Support for loading port alias map file to replace port name
1 file changed, 104 insertions(+), 1 deletion(-) 1 file changed, 104 insertions(+), 1 deletion(-)
diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c
index 00c81d3..54f132a 100644 index 0d9b2e7..b72b1bc 100644
--- a/relay/dhcrelay.c --- a/relay/dhcrelay.c
+++ b/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; char *dhcrelay_sub_id = NULL;
#endif #endif
@ -24,11 +24,11 @@ index 00c81d3..54f132a 100644
+static struct interface_name_alias_tuple *g_interface_name_alias_map = NULL; +static struct interface_name_alias_tuple *g_interface_name_alias_map = NULL;
+static size_t g_interface_name_alias_map_size = 0; +static size_t g_interface_name_alias_map_size = 0;
+ +
#ifndef UNIT_TEST
static void do_relay4(struct interface_info *, struct dhcp_packet *, static void do_relay4(struct interface_info *, struct dhcp_packet *,
unsigned int, unsigned int, struct iaddr, unsigned int, unsigned int, struct iaddr,
struct hardware *); @@ -152,6 +160,10 @@ extern int strip_relay_agent_options(struct interface_info *,
@@ -143,6 +151,10 @@ static int strip_relay_agent_options(struct interface_info *, #ifndef UNIT_TEST
static void request_v4_interface(const char* name, int flags); 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 load_interface_alias_map(const char *port_alias_map_file_path);
@ -36,9 +36,9 @@ index 00c81d3..54f132a 100644
+static void free_interface_alias_map(void); +static void free_interface_alias_map(void);
+ +
static const char copyright[] = static const char copyright[] =
"Copyright 2004-2018 Internet Systems Consortium."; "Copyright 2004-2022 Internet Systems Consortium.";
static const char arr[] = "All rights reserved."; static const char arr[] = "All rights reserved.";
@@ -158,7 +170,7 @@ char *progname; @@ -167,7 +179,7 @@ char *progname;
"\n" \ "\n" \
" %%%% A single %%\n" \ " %%%% A single %%\n" \
" %%h Hostname of device\n" \ " %%h Hostname of device\n" \
@ -47,7 +47,7 @@ index 00c81d3..54f132a 100644
" %%P Hardware address of interface that generated the request\n" \ " %%P Hardware address of interface that generated the request\n" \
" %%C Client hardware address\n" \ " %%C Client hardware address\n" \
" %%I DHCP relay agent IP 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" \ " [-p <port> | -rp <relay-port>]\n" \
" [-pf <pid-file>] [--no-pid]\n"\ " [-pf <pid-file>] [--no-pid]\n"\
" [-m append|replace|forward|discard]\n" \ " [-m append|replace|forward|discard]\n" \
@ -55,7 +55,7 @@ index 00c81d3..54f132a 100644
" [-i interface0 [ ... -i interfaceN]\n" \ " [-i interface0 [ ... -i interfaceN]\n" \
" [-iu interface0 [ ... -iu interfaceN]\n" \ " [-iu interface0 [ ... -iu interfaceN]\n" \
" [-id interface0 [ ... -id 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" \ " %s -6 [-d] [-q] [-I] [-c <hops>]\n" \
" [-p <port> | -rp <relay-port>]\n" \ " [-p <port> | -rp <relay-port>]\n" \
" [-pf <pid-file>] [--no-pid]\n" \ " [-pf <pid-file>] [--no-pid]\n" \
@ -63,7 +63,7 @@ index 00c81d3..54f132a 100644
" [-s <subscriber-id>]\n" \ " [-s <subscriber-id>]\n" \
" -l lower0 [ ... -l lowerN]\n" \ " -l lower0 [ ... -l lowerN]\n" \
" -u upper0 [ ... -u upperN]\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; no_dhcrelay_pid = ISC_TRUE;
} else if (!strcmp(argv[i], "--no-pid")) { } else if (!strcmp(argv[i], "--no-pid")) {
no_pid_file = ISC_TRUE; no_pid_file = ISC_TRUE;
@ -75,7 +75,7 @@ index 00c81d3..54f132a 100644
} else if (argv[i][0] == '-') { } else if (argv[i][0] == '-') {
usage("Unknown command: %s", argv[i]); usage("Unknown command: %s", argv[i]);
} else { } else {
@@ -841,6 +860,7 @@ main(int argc, char **argv) { @@ -865,6 +884,7 @@ main(int argc, char **argv) {
dispatch(); dispatch();
/* In fact dispatch() never returns. */ /* In fact dispatch() never returns. */
@ -83,7 +83,7 @@ index 00c81d3..54f132a 100644
return (0); 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) { if (packet->htype && !packet->giaddr.s_addr) {
int ret = 0, vlanid = 0; int ret = 0, vlanid = 0;
@ -91,10 +91,11 @@ index 00c81d3..54f132a 100644
ret = _bridgefdbquery(print_hw_addr(packet->htype, packet->hlen, packet->chaddr), ret = _bridgefdbquery(print_hw_addr(packet->htype, packet->hlen, packet->chaddr),
ifname, 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); strncpy(ifname, ip->name, IFNAMSIZ);
} }
+
+ // Attempt to translate SONiC interface name to vendor alias + // Attempt to translate SONiC interface name to vendor alias
+ ret = get_interface_alias_by_name(ifname, ifalias); + ret = get_interface_alias_by_name(ifname, ifalias);
+ if (ret < 0) { + if (ret < 0) {
@ -106,11 +107,10 @@ index 00c81d3..54f132a 100644
+ +
+ strncpy(ifname, ifalias, IFNAMSIZ); + strncpy(ifname, ifalias, IFNAMSIZ);
+ } + }
+
str = ifname; str = ifname;
} }
break; @@ -2361,3 +2394,73 @@ void request_v4_interface(const char* name, int flags) {
@@ -2313,3 +2346,73 @@ void request_v4_interface(const char* name, int flags) {
interface_snorf(tmp, (INTERFACE_REQUESTED | flags)); interface_snorf(tmp, (INTERFACE_REQUESTED | flags));
interface_dereference(&tmp, MDL); interface_dereference(&tmp, MDL);
} }
@ -185,5 +185,5 @@ index 00c81d3..54f132a 100644
+ g_interface_name_alias_map_size = 0; + g_interface_name_alias_map_size = 0;
+} +}
-- --
2.17.1 2.25.1

View File

@ -9,18 +9,18 @@ Subject: [PATCH 1/3] Add --enable-use-sockets to configure flags in
1 file changed, 1 insertion(+), 1 deletion(-) 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/debian/rules b/debian/rules diff --git a/debian/rules b/debian/rules
index d3fcc1d..2a7219d 100755 index dc2a9b1..3d12fb5 100755
--- a/debian/rules --- a/debian/rules
+++ b/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_DHCLIENT_DB='\"$(LEASE_PATH)/dhclient.leases\"'
CFLAGS+=-D_PATH_DHCLIENT6_DB='\"$(LEASE_PATH)/dhclient6.leases\"' CFLAGS+=-D_PATH_DHCLIENT6_DB='\"$(LEASE_PATH)/dhclient6.leases\"'
-CONFFLAGS=--prefix=/usr --with-libbind=/usr --enable-log-pid --enable-paranoia -CONFFLAGS+=--prefix=/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 --enable-use-sockets
include /usr/share/dpkg/buildtools.mk
# cross-architecture building # cross-architecture building
ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
-- --
2.17.1 2.25.1

View File

@ -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(-) 1 file changed, 120 insertions(+), 119 deletions(-)
diff --git a/includes/osdep.h b/includes/osdep.h diff --git a/includes/osdep.h b/includes/osdep.h
index cfae90b..f07c43c 100644 index 0742858..dfccb8c 100644
--- a/includes/osdep.h --- a/includes/osdep.h
+++ b/includes/osdep.h +++ b/includes/osdep.h
@@ -48,37 +48,6 @@ @@ -47,37 +47,6 @@
#define BYTE_ORDER DHCP_BYTE_ORDER #define BYTE_ORDER DHCP_BYTE_ORDER
#endif /* BYTE_ORDER */ #endif /* BYTE_ORDER */
@ -50,7 +50,7 @@ index cfae90b..f07c43c 100644
#if !defined (TIME_MAX) #if !defined (TIME_MAX)
# define TIME_MAX 2147483647 # define TIME_MAX 2147483647
#endif #endif
@@ -91,94 +60,6 @@ @@ -90,98 +59,10 @@
# define vsnprintf isc_print_vsnprintf # define vsnprintf isc_print_vsnprintf
#endif #endif
@ -102,6 +102,10 @@ index cfae90b..f07c43c 100644
-# define USE_UPF_RECEIVE -# define USE_UPF_RECEIVE
-#endif -#endif
- -
#if defined (SO_BINDTODEVICE) && !defined (HAVE_SO_BINDTODEVICE)
# define HAVE_SO_BINDTODEVICE
#endif
-/* Porting:: -/* Porting::
- -
- If you add support for sending packets directly out an interface, - If you add support for sending packets directly out an interface,
@ -145,7 +149,7 @@ index cfae90b..f07c43c 100644
/* If we don't have a DLPI packet filter, we have to filter in userland. /* If we don't have a DLPI packet filter, we have to filter in userland.
Probably not worth doing, actually. */ Probably not worth doing, actually. */
#if defined (USE_DLPI_RECEIVE) && !defined (USE_DLPI_PFMOD) #if defined (USE_DLPI_RECEIVE) && !defined (USE_DLPI_PFMOD)
@@ -288,4 +169,124 @@ @@ -287,4 +168,124 @@
# define STDERR_FILENO 2 # define STDERR_FILENO 2
#endif #endif
@ -271,5 +275,5 @@ index cfae90b..f07c43c 100644
+ +
#endif /* __ISC_DHCP_OSDEP_H__ */ #endif /* __ISC_DHCP_OSDEP_H__ */
-- --
2.17.1 2.25.1

View File

@ -6,16 +6,16 @@ Subject: [PATCH 3/3] If destination of BOOTREQUEST is directed broadcast,
interfaces interfaces
--- ---
common/discover.c | 46 +++++++++++++++++++--- common/discover.c | 40 +++++++++++++++++++--
includes/dhcpd.h | 3 ++ includes/dhcpd.h | 3 ++
relay/dhcrelay.c | 98 +++++++++++++++++++++++++++++++++++++++++------ relay/dhcrelay.c | 90 +++++++++++++++++++++++++++++++++++++++++++----
3 files changed, 131 insertions(+), 16 deletions(-) 3 files changed, 123 insertions(+), 10 deletions(-)
diff --git a/common/discover.c b/common/discover.c diff --git a/common/discover.c b/common/discover.c
index 98ac46a..53afecc 100644 index 0c5ad39..32f2516 100644
--- a/common/discover.c --- a/common/discover.c
+++ b/common/discover.c +++ b/common/discover.c
@@ -236,6 +236,7 @@ struct iface_conf_list { @@ -239,6 +239,7 @@ struct iface_conf_list {
struct iface_info { struct iface_info {
char name[IF_NAMESIZE+1]; /* name of the interface, e.g. "bge0" */ char name[IF_NAMESIZE+1]; /* name of the interface, e.g. "bge0" */
struct sockaddr_storage addr; /* address information */ struct sockaddr_storage addr; /* address information */
@ -23,7 +23,7 @@ index 98ac46a..53afecc 100644
isc_uint64_t flags; /* interface flags, e.g. IFF_LOOPBACK */ isc_uint64_t flags; /* interface flags, e.g. IFF_LOOPBACK */
}; };
@@ -367,6 +368,17 @@ next_iface(struct iface_info *info, int *err, struct iface_conf_list *ifaces) { @@ -370,6 +371,17 @@ next_iface(struct iface_info *info, int *err, struct iface_conf_list *ifaces) {
} }
info->flags = tmp.lifr_flags; info->flags = tmp.lifr_flags;
@ -41,7 +41,7 @@ index 98ac46a..53afecc 100644
ifaces->next++; ifaces->next++;
*err = 0; *err = 0;
return 1; return 1;
@@ -410,6 +422,7 @@ struct iface_conf_list { @@ -413,6 +425,7 @@ struct iface_conf_list {
struct iface_info { struct iface_info {
char name[IFNAMSIZ]; /* name of the interface, e.g. "bge0" */ char name[IFNAMSIZ]; /* name of the interface, e.g. "bge0" */
struct sockaddr_storage addr; /* address information */ struct sockaddr_storage addr; /* address information */
@ -49,17 +49,17 @@ index 98ac46a..53afecc 100644
isc_uint64_t flags; /* interface flags, e.g. IFF_LOOPBACK */ isc_uint64_t flags; /* interface flags, e.g. IFF_LOOPBACK */
}; };
@@ -487,7 +500,8 @@ end_iface_scan(struct iface_conf_list *ifaces) { @@ -490,7 +503,8 @@ end_iface_scan(struct iface_conf_list *ifaces) {
/* XXX: perhaps create drealloc() rather than do it manually */ /* XXX: perhaps create drealloc() rather than do it manually */
void void
add_ipv4_addr_to_interface(struct interface_info *iface, add_ipv4_addr_to_interface(struct interface_info *iface,
- const struct in_addr *addr) { - const struct in_addr *addr) {
+ const struct in_addr *addr, + const struct in_addr *addr,
+ const struct in_addr *netmask) { + const struct in_addr *netmask) {
/* /*
* We don't expect a lot of addresses per IPv4 interface, so * We don't expect a lot of addresses per IPv4 interface, so
* we use 4, as our "chunk size" for collecting addresses. * we use 4, as our "chunk size" for collecting addresses.
@@ -498,6 +512,11 @@ add_ipv4_addr_to_interface(struct interface_info *iface, @@ -501,6 +515,11 @@ add_ipv4_addr_to_interface(struct interface_info *iface,
log_fatal("Out of memory saving IPv4 address " log_fatal("Out of memory saving IPv4 address "
"on interface."); "on interface.");
} }
@ -71,7 +71,7 @@ index 98ac46a..53afecc 100644
iface->address_count = 0; iface->address_count = 0;
iface->address_max = 4; iface->address_max = 4;
} else if (iface->address_count >= iface->address_max) { } else if (iface->address_count >= iface->address_max) {
@@ -515,9 +534,23 @@ add_ipv4_addr_to_interface(struct interface_info *iface, @@ -518,9 +537,23 @@ add_ipv4_addr_to_interface(struct interface_info *iface,
iface->address_max * sizeof(struct in_addr)); iface->address_max * sizeof(struct in_addr));
dfree(iface->addresses, MDL); dfree(iface->addresses, MDL);
iface->addresses = tmp; iface->addresses = tmp;
@ -96,15 +96,15 @@ index 98ac46a..53afecc 100644
} }
#ifdef DHCPv6 #ifdef DHCPv6
@@ -656,6 +689,7 @@ discover_interfaces(int state) { @@ -661,6 +694,7 @@ discover_interfaces(int state) {
if ((info.addr.ss_family == AF_INET) && if ((info.addr.ss_family == AF_INET) &&
(local_family == AF_INET)) { (local_family == AF_INET)) {
struct sockaddr_in *a = (struct sockaddr_in*)&info.addr; struct sockaddr_in *a = (struct sockaddr_in*)&info.addr;
+ struct sockaddr_in *n = (struct sockaddr_in*)&info.netmask; + struct sockaddr_in *n = (struct sockaddr_in*)&info.netmask;
struct iaddr addr; struct iaddr addr;
/* We don't want the loopback interface. */ /* We don't want the loopback interface. */
@@ -670,7 +704,7 @@ discover_interfaces(int state) { @@ -675,7 +709,7 @@ discover_interfaces(int state) {
if (a->sin_addr.s_addr != htonl(INADDR_ANY)) if (a->sin_addr.s_addr != htonl(INADDR_ANY))
tmp->configured = 1; tmp->configured = 1;
@ -114,10 +114,10 @@ index 98ac46a..53afecc 100644
/* invoke the setup hook */ /* invoke the setup hook */
addr.len = 4; addr.len = 4;
diff --git a/includes/dhcpd.h b/includes/dhcpd.h diff --git a/includes/dhcpd.h b/includes/dhcpd.h
index df3da59..2c7f059 100644 index 20f9bfb..b54a36e 100644
--- a/includes/dhcpd.h --- a/includes/dhcpd.h
+++ b/includes/dhcpd.h +++ b/includes/dhcpd.h
@@ -1369,6 +1369,9 @@ struct interface_info { @@ -1380,6 +1380,9 @@ struct interface_info {
struct in_addr *addresses; /* Addresses associated with this struct in_addr *addresses; /* Addresses associated with this
* interface. * interface.
*/ */
@ -128,7 +128,7 @@ index df3da59..2c7f059 100644
int address_max; /* Size of addresses buffer. */ int address_max; /* Size of addresses buffer. */
struct in6_addr *v6addresses; /* IPv6 addresses associated with struct in6_addr *v6addresses; /* IPv6 addresses associated with
diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c
index 54f132a..beae977 100644 index b72b1bc..9143e85 100644
--- a/relay/dhcrelay.c --- a/relay/dhcrelay.c
+++ b/relay/dhcrelay.c +++ b/relay/dhcrelay.c
@@ -30,6 +30,7 @@ @@ -30,6 +30,7 @@
@ -139,7 +139,7 @@ index 54f132a..beae977 100644
#include <isc/file.h> #include <isc/file.h>
TIME default_lease_time = 43200; /* 12 hours... */ TIME default_lease_time = 43200; /* 12 hours... */
@@ -1001,20 +1002,95 @@ do_relay4(struct interface_info *ip, struct dhcp_packet *packet, @@ -1030,20 +1031,95 @@ do_relay4(struct interface_info *ip, struct dhcp_packet *packet,
/* Otherwise, it's a BOOTREQUEST, so forward it to all the /* Otherwise, it's a BOOTREQUEST, so forward it to all the
servers. */ servers. */
for (sp = servers; sp; sp = sp->next) { for (sp = servers; sp; sp = sp->next) {
@ -147,7 +147,6 @@ index 54f132a..beae977 100644
- ? fallback_interface : interfaces), - ? fallback_interface : interfaces),
- NULL, packet, length, ip->addresses[0], - NULL, packet, length, ip->addresses[0],
- &sp->to, NULL) < 0) { - &sp->to, NULL) < 0) {
- ++client_packet_errors;
+ int packet_relay_attempted = 0; + int packet_relay_attempted = 0;
+ +
+ log_debug("Server IP: %s", inet_ntoa(sp->to.sin_addr)); + log_debug("Server IP: %s", inet_ntoa(sp->to.sin_addr));
@ -180,14 +179,16 @@ index 54f132a..beae977 100644
+ log_debug("Packet destined for broadcast IP of %s", out->name); + log_debug("Packet destined for broadcast IP of %s", out->name);
+ if (send_packet(out, NULL, packet, + if (send_packet(out, NULL, packet,
+ length, ip->addresses[0],&sp->to, NULL) < 0) { + length, ip->addresses[0],&sp->to, NULL) < 0) {
+ ++client_packet_errors; ++client_packet_errors;
+ } else { } else {
+ log_debug("Forwarded BOOTREQUEST for %s to %s on interface %s", - log_debug("Forwarded BOOTREQUEST for %s to %s",
+ print_hw_addr(packet->htype, packet->hlen, + log_debug("Forwarded BOOTREQUEST for %s to %s on interface %s",
+ packet->chaddr), print_hw_addr(packet->htype, packet->hlen,
+ inet_ntoa(sp->to.sin_addr), out->name); packet->chaddr),
- inet_ntoa(sp->to.sin_addr));
+ inet_ntoa(sp->to.sin_addr), out->name);
+ +
+ ++client_packets_relayed; ++client_packets_relayed;
+ } + }
+ +
+ packet_relay_attempted = 1; + packet_relay_attempted = 1;
@ -198,8 +199,9 @@ index 54f132a..beae977 100644
+ +
+ if (packet_relay_attempted) + if (packet_relay_attempted)
+ break; + break;
+ } }
+ - }
+ if (packet_relay_attempted) + if (packet_relay_attempted)
+ continue; + continue;
+ +
@ -217,12 +219,7 @@ index 54f132a..beae977 100644
+ +
+ ++client_packets_relayed; + ++client_packets_relayed;
+ } + }
} else { + } else {
- log_debug("Forwarded BOOTREQUEST for %s to %s",
- print_hw_addr(packet->htype, packet->hlen,
- packet->chaddr),
- inet_ntoa(sp->to.sin_addr));
- ++client_packets_relayed;
+ for (out = interfaces; out; out = out->next) { + for (out = interfaces; out; out = out->next) {
+ // Only relay BOOTREQUEST on upstream interfaces + // Only relay BOOTREQUEST on upstream interfaces
+ if (!(out->flags & INTERFACE_UPSTREAM)) + if (!(out->flags & INTERFACE_UPSTREAM))
@ -240,12 +237,11 @@ index 54f132a..beae977 100644
+ ++client_packets_relayed; + ++client_packets_relayed;
+ } + }
+ } + }
} + }
} + }
-
} }
/* Strip any Relay Agent Information options from the DHCP packet #endif /* UNIT_TEST */
-- --
2.17.1 2.25.1

View File

@ -14,10 +14,10 @@ didn't discover the interface(s) when it started up.
1 file changed, 2 insertions(+), 1 deletion(-) 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/common/discover.c b/common/discover.c diff --git a/common/discover.c b/common/discover.c
index 8d5b958..5efff49 100644 index 32f2516..31dae3c 100644
--- a/common/discover.c --- a/common/discover.c
+++ b/common/discover.c +++ b/common/discover.c
@@ -1016,7 +1016,8 @@ discover_interfaces(int state) { @@ -668,7 +668,8 @@ discover_interfaces(int state) {
info.flags & IFF_LOOPBACK || info.flags & IFF_LOOPBACK ||
info.flags & IFF_POINTOPOINT) && !tmp) || info.flags & IFF_POINTOPOINT) && !tmp) ||
(!(info.flags & IFF_UP) && (!(info.flags & IFF_UP) &&
@ -25,8 +25,8 @@ index 8d5b958..5efff49 100644
+ state != DISCOVER_UNCONFIGURED && + state != DISCOVER_UNCONFIGURED &&
+ state != DISCOVER_RELAY)) + state != DISCOVER_RELAY))
continue; continue;
/* If there isn't already an interface by this name, /* If there isn't already an interface by this name,
-- --
2.17.1 2.25.1

View File

@ -4,11 +4,11 @@ Date: Tue, 1 Dec 2020 16:33:34 -0800
Subject: [PATCH] support for dual tor scenario Subject: [PATCH] support for dual tor scenario
--- ---
relay/dhcrelay.c | 117 +++++++++++++++++++++++++++++++++++++++-------- relay/dhcrelay.c | 115 +++++++++++++++++++++++++++++++++++++++--------
1 file changed, 98 insertions(+), 19 deletions(-) 1 file changed, 97 insertions(+), 18 deletions(-)
diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c
index e158efe..055d97f 100644 index 9143e85..4134a58 100644
--- a/relay/dhcrelay.c --- a/relay/dhcrelay.c
+++ b/relay/dhcrelay.c +++ b/relay/dhcrelay.c
@@ -56,6 +56,8 @@ int bogus_agent_drops = 0; /* Packets dropped because agent option @@ -56,6 +56,8 @@ int bogus_agent_drops = 0; /* Packets dropped because agent option
@ -34,52 +34,51 @@ index e158efe..055d97f 100644
#ifdef DHCPv6 #ifdef DHCPv6
/* Force use of DHCPv6 interface-id option. */ /* Force use of DHCPv6 interface-id option. */
isc_boolean_t use_if_id = ISC_FALSE; isc_boolean_t use_if_id = ISC_FALSE;
@@ -156,6 +165,8 @@ static int load_interface_alias_map(const char *port_alias_map_file_path); @@ -165,6 +174,8 @@ 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 int get_interface_alias_by_name(const char *if_name, char *if_alias_out);
static void free_interface_alias_map(void); static void free_interface_alias_map(void);
+static void free_downstream_intfs(void); +static void free_downstream_intfs(void);
+ +
static const char copyright[] = static const char copyright[] =
"Copyright 2004-2018 Internet Systems Consortium."; "Copyright 2004-2022 Internet Systems Consortium.";
static const char arr[] = "All rights reserved."; static const char arr[] = "All rights reserved.";
@@ -189,6 +200,7 @@ char *progname; @@ -198,6 +209,7 @@ char *progname;
" [-iu interface0 [ ... -iu interfaceN]\n" \ " [-iu interface0 [ ... -iu interfaceN]\n" \
" [-id interface0 [ ... -id interfaceN]\n" \ " [-id interface0 [ ... -id interfaceN]\n" \
" [-U interface]\n" \ " [-U interface] [-g <ip-address>]\n" \
+" [-dt]\n"\ +" [-dt]\n"\
" server0 [ ... serverN]\n\n" \ " server0 [ ... serverN]\n\n" \
" %s -6 [-d] [-q] [-I] [-c <hops>]\n" \ " %s -6 [-d] [-q] [-I] [-c <hops>]\n" \
" [-p <port> | -rp <relay-port>]\n" \ " [-p <port> | -rp <relay-port>]\n" \
@@ -210,6 +222,7 @@ char *progname; @@ -219,6 +231,7 @@ char *progname;
" [-iu interface0 [ ... -iu interfaceN]\n" \ " [-iu interface0 [ ... -iu interfaceN]\n" \
" [-id interface0 [ ... -id interfaceN]\n" \ " [-id interface0 [ ... -id interfaceN]\n" \
" [-U interface]\n" \ " [-U interface] [-g <ip-address>]\n" \
+" [-dt]\n"\ +" [-dt]\n"\
" server0 [ ... serverN]\n\n" \ " server0 [ ... serverN]\n\n" \
" %s -6 [-d] [-q] [-I] [-c <hops>] [-p <port>]\n" \ " %s -6 [-d] [-q] [-I] [-c <hops>] [-p <port>]\n" \
" [-pf <pid-file>] [--no-pid]\n" \ " [-pf <pid-file>] [--no-pid]\n" \
@@ -231,6 +244,7 @@ char *progname; @@ -240,6 +253,7 @@ char *progname;
" [-iu interface0 [ ... -iu interfaceN]\n" \ " [-iu interface0 [ ... -iu interfaceN]\n" \
" [-id interface0 [ ... -id interfaceN]\n" \ " [-id interface0 [ ... -id interfaceN]\n" \
" [-U interface]\n" \ " [-U interface] [-g <ip-address>]\n" \
+" [-dt]\n"\ +" [-dt]\n"\
" server0 [ ... serverN]\n\n" DHCRELAY_OPTION82_USAGE \ " server0 [ ... serverN]\n\n" DHCRELAY_OPTION82_USAGE \
" %s {--version|--help|-h}" " %s {--version|--help|-h}"
#else #else
@@ -242,6 +256,7 @@ char *progname; @@ -251,6 +265,7 @@ char *progname;
" [-iu interface0 [ ... -iu interfaceN]\n" \ " [-iu interface0 [ ... -iu interfaceN]\n" \
" [-id interface0 [ ... -id interfaceN]\n" \ " [-id interface0 [ ... -id interfaceN]\n" \
" [-U interface]\n" \ " [-U interface] [-g <ip-address>]\n" \
+" [-dt]\n"\ +" [-dt]\n"\
" server0 [ ... serverN]\n\n" DHCRELAY_OPTION82_USAGE \ " server0 [ ... serverN]\n\n" DHCRELAY_OPTION82_USAGE \
" %s {--version|--help|-h}" " %s {--version|--help|-h}"
#endif #endif
@@ -639,7 +654,16 @@ main(int argc, char **argv) { @@ -663,6 +678,15 @@ main(int argc, char **argv) {
usage(use_noarg, argv[i-1]); usage(use_noarg, argv[i-1]);
if (load_interface_alias_map(argv[i]) != 0) if (load_interface_alias_map(argv[i]) != 0)
log_fatal("Failed to load interface name-alias map."); log_fatal("Failed to load interface name-alias map.");
- } else if (argv[i][0] == '-') {
+ } else if (!strcmp(argv[i], "-dt")) { + } else if (!strcmp(argv[i], "-dt")) {
+#ifdef DHCPv6 +#ifdef DHCPv6
+ if (local_family_set && (local_family == AF_INET6)) { + if (local_family_set && (local_family == AF_INET6)) {
@ -89,11 +88,10 @@ index e158efe..055d97f 100644
+ local_family = AF_INET; + local_family = AF_INET;
+#endif +#endif
+ enable_support_for_dual_tor = 1; + enable_support_for_dual_tor = 1;
+ } else if (argv[i][0] == '-') { } else if (argv[i][0] == '-') {
usage("Unknown command: %s", argv[i]); usage("Unknown command: %s", argv[i]);
} else { } else {
struct hostent *he; @@ -771,7 +795,6 @@ main(int argc, char **argv) {
@@ -747,7 +771,6 @@ main(int argc, char **argv) {
log_fatal("No servers specified."); log_fatal("No servers specified.");
} }
@ -101,7 +99,7 @@ index e158efe..055d97f 100644
/* Set up the server sockaddrs. */ /* Set up the server sockaddrs. */
for (sp = servers; sp; sp = sp->next) { for (sp = servers; sp; sp = sp->next) {
sp->to.sin_port = local_port; sp->to.sin_port = local_port;
@@ -862,6 +885,8 @@ main(int argc, char **argv) { @@ -886,6 +909,8 @@ main(int argc, char **argv) {
/* In fact dispatch() never returns. */ /* In fact dispatch() never returns. */
free_interface_alias_map(); free_interface_alias_map();
@ -110,7 +108,7 @@ index e158efe..055d97f 100644
return (0); return (0);
} }
@@ -885,25 +910,50 @@ do_relay4(struct interface_info *ip, struct dhcp_packet *packet, @@ -909,25 +934,50 @@ do_relay4(struct interface_info *ip, struct dhcp_packet *packet,
return; return;
} }
@ -174,7 +172,7 @@ index e158efe..055d97f 100644
} }
/* If it's a bootreply, forward it to the client. */ /* If it's a bootreply, forward it to the client. */
@@ -913,6 +963,10 @@ do_relay4(struct interface_info *ip, struct dhcp_packet *packet, @@ -937,6 +987,10 @@ do_relay4(struct interface_info *ip, struct dhcp_packet *packet,
return; return;
} }
@ -182,10 +180,10 @@ index e158efe..055d97f 100644
+ if (enable_support_for_dual_tor && !out) + if (enable_support_for_dual_tor && !out)
+ return; + return;
+ +
log_debug("BOOTREPLY giaddr: %s\n", inet_ntoa(packet->giaddr));
if (!(packet->flags & htons(BOOTP_BROADCAST)) && if (!(packet->flags & htons(BOOTP_BROADCAST)) &&
can_unicast_without_arp(out)) { can_unicast_without_arp(out)) {
to.sin_addr = packet->yiaddr; @@ -970,9 +1024,13 @@ do_relay4(struct interface_info *ip, struct dhcp_packet *packet,
@@ -945,9 +999,13 @@ do_relay4(struct interface_info *ip, struct dhcp_packet *packet,
return; return;
if (!out) { if (!out) {
@ -202,7 +200,7 @@ index e158efe..055d97f 100644
return; return;
} }
@@ -989,6 +1047,7 @@ do_relay4(struct interface_info *ip, struct dhcp_packet *packet, @@ -1023,6 +1081,7 @@ do_relay4(struct interface_info *ip, struct dhcp_packet *packet,
that set giaddr, so we won't see it. */ that set giaddr, so we won't see it. */
if (!packet->giaddr.s_addr) if (!packet->giaddr.s_addr)
packet->giaddr = ip->addresses[0]; packet->giaddr = ip->addresses[0];
@ -210,7 +208,7 @@ index e158efe..055d97f 100644
if (packet->hops < max_hop_count) if (packet->hops < max_hop_count)
packet->hops = packet->hops + 1; packet->hops = packet->hops + 1;
else else
@@ -1264,7 +1323,6 @@ find_interface_by_agent_option(struct dhcp_packet *packet, @@ -1305,7 +1364,6 @@ find_interface_by_agent_option(struct dhcp_packet *packet,
/* Scan the interface list looking for an interface whose /* Scan the interface list looking for an interface whose
name matches the one specified in circuit_id. */ name matches the one specified in circuit_id. */
@ -218,7 +216,7 @@ index e158efe..055d97f 100644
for (ip = interfaces; ip; ip = ip->next) { for (ip = interfaces; ip; ip = ip->next) {
if (ip->circuit_id && if (ip->circuit_id &&
ip->circuit_id_len == circuit_id_len && ip->circuit_id_len == circuit_id_len &&
@@ -1668,6 +1726,7 @@ add_relay_agent_options(struct interface_info *ip, struct dhcp_packet *packet, @@ -1714,6 +1772,7 @@ add_relay_agent_options(struct interface_info *ip, struct dhcp_packet *packet,
*sp++ = 4u; *sp++ = 4u;
memcpy(sp, &giaddr.s_addr, 4); memcpy(sp, &giaddr.s_addr, 4);
sp += 4; sp += 4;
@ -226,7 +224,7 @@ index e158efe..055d97f 100644
packet->giaddr = uplink->addresses[0]; packet->giaddr = uplink->addresses[0];
log_debug ("Adding link selection suboption" log_debug ("Adding link selection suboption"
" with addr: %s", inet_ntoa(giaddr)); " with addr: %s", inet_ntoa(giaddr));
@@ -2398,6 +2457,7 @@ void request_v4_interface(const char* name, int flags) { @@ -2451,6 +2510,7 @@ void request_v4_interface(const char* name, int flags) {
struct interface_info *tmp = NULL; struct interface_info *tmp = NULL;
int len = strlen(name); int len = strlen(name);
isc_result_t status; isc_result_t status;
@ -234,7 +232,7 @@ index e158efe..055d97f 100644
if (len >= sizeof(tmp->name)) { if (len >= sizeof(tmp->name)) {
log_fatal("%s: interface name too long (is %d)", name, len); log_fatal("%s: interface name too long (is %d)", name, len);
@@ -2413,6 +2473,15 @@ void request_v4_interface(const char* name, int flags) { @@ -2466,6 +2526,15 @@ void request_v4_interface(const char* name, int flags) {
(flags & INTERFACE_UPSTREAM ? 'Y' : 'N'), (flags & INTERFACE_UPSTREAM ? 'Y' : 'N'),
(flags & INTERFACE_DOWNSTREAM ? 'Y' : 'N')); (flags & INTERFACE_DOWNSTREAM ? 'Y' : 'N'));
@ -247,10 +245,10 @@ index e158efe..055d97f 100644
+ ci->interface = tmp; + ci->interface = tmp;
+ } + }
+ +
strncpy(tmp->name, name, len); memcpy(tmp->name, name, len);
interface_snorf(tmp, (INTERFACE_REQUESTED | flags)); interface_snorf(tmp, (INTERFACE_REQUESTED | flags));
interface_dereference(&tmp, MDL); interface_dereference(&tmp, MDL);
@@ -2487,3 +2556,13 @@ free_interface_alias_map(void) { @@ -2540,3 +2609,13 @@ free_interface_alias_map(void) {
free(g_interface_name_alias_map); free(g_interface_name_alias_map);
g_interface_name_alias_map_size = 0; g_interface_name_alias_map_size = 0;
} }
@ -265,5 +263,5 @@ index e158efe..055d97f 100644
+ } + }
+} +}
-- --
2.17.1 2.25.1

View File

@ -4,13 +4,13 @@ Date: Fri, 12 Mar 2021 23:30:56 -0800
Subject: [PATCH] add option -si to support using src intf ip in relay Subject: [PATCH] add option -si to support using src intf ip in relay
--- ---
common/socket.c | 119 ++++++++++++++++++++++++++++++++++++----------- common/socket.c | 120 +++++++++++++++++++++++++++++++++++------------
includes/dhcpd.h | 1 + includes/dhcpd.h | 1 +
relay/dhcrelay.c | 8 ++++ relay/dhcrelay.c | 2 +
3 files changed, 100 insertions(+), 28 deletions(-) 3 files changed, 94 insertions(+), 29 deletions(-)
diff --git a/common/socket.c b/common/socket.c diff --git a/common/socket.c b/common/socket.c
index 483eb9c..da9f501 100644 index 3953eac..eae86e8 100644
--- a/common/socket.c --- a/common/socket.c
+++ b/common/socket.c +++ b/common/socket.c
@@ -83,6 +83,29 @@ static unsigned int global_v4_socket_references = 0; @@ -83,6 +83,29 @@ static unsigned int global_v4_socket_references = 0;
@ -43,7 +43,7 @@ index 483eb9c..da9f501 100644
/* /*
* If we can't bind() to a specific interface, then we can only have * If we can't bind() to a specific interface, then we can only have
* a single socket. This variable insures that we don't try to listen * a single socket. This variable insures that we don't try to listen
@@ -712,37 +735,77 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto) @@ -722,38 +745,77 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto)
struct hardware *hto; struct hardware *hto;
{ {
int result; int result;
@ -59,8 +59,9 @@ index 483eb9c..da9f501 100644
- pktinfo.ipi_ifindex = interface->ifp->ifr_index; - pktinfo.ipi_ifindex = interface->ifp->ifr_index;
- if (setsockopt(interface->wfdesc, IPPROTO_IP, - if (setsockopt(interface->wfdesc, IPPROTO_IP,
- IP_PKTINFO, (char *)&pktinfo, - IP_PKTINFO, (char *)&pktinfo,
- sizeof(pktinfo)) < 0) - sizeof(pktinfo)) < 0)
- log_fatal("setsockopt: IP_PKTINFO: %m"); - log_fatal("setsockopt: IP_PKTINFO for %s: %m",
- (char*)(interface->ifp));
+ struct msghdr m; + struct msghdr m;
+ struct iovec v; + struct iovec v;
+ struct sockaddr_in dst; + struct sockaddr_in dst;
@ -150,10 +151,10 @@ index 483eb9c..da9f501 100644
} }
diff --git a/includes/dhcpd.h b/includes/dhcpd.h diff --git a/includes/dhcpd.h b/includes/dhcpd.h
index 36cd518..0c25582 100644 index b54a36e..68d44cf 100644
--- a/includes/dhcpd.h --- a/includes/dhcpd.h
+++ b/includes/dhcpd.h +++ b/includes/dhcpd.h
@@ -2660,6 +2660,7 @@ ssize_t send_fallback6(struct interface_info *, struct packet *, @@ -2676,6 +2676,7 @@ ssize_t send_fallback6(struct interface_info *, struct packet *,
#endif #endif
#ifdef USE_SOCKET_SEND #ifdef USE_SOCKET_SEND
@ -162,10 +163,10 @@ index 36cd518..0c25582 100644
void if_register_send (struct interface_info *); void if_register_send (struct interface_info *);
void if_deregister_send (struct interface_info *); void if_deregister_send (struct interface_info *);
diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c
index 221106a..c44a79d 100644 index ccf7417..6aa1179 100644
--- a/relay/dhcrelay.c --- a/relay/dhcrelay.c
+++ b/relay/dhcrelay.c +++ b/relay/dhcrelay.c
@@ -431,6 +431,8 @@ main(int argc, char **argv) { @@ -440,6 +440,8 @@ main(int argc, char **argv) {
#endif #endif
} else if (!strcmp(argv[i], "-d")) { } else if (!strcmp(argv[i], "-d")) {
/* no_daemon = 1; */ /* no_daemon = 1; */
@ -175,5 +176,5 @@ index 221106a..c44a79d 100644
quiet = 1; quiet = 1;
quiet_interface_discovery = 1; quiet_interface_discovery = 1;
-- --
2.17.1 2.25.1

View File

@ -1,53 +0,0 @@
From 0a2f9a62bceb90b0d30461add2e25c4ce7a24547 Mon Sep 17 00:00:00 2001
From: Thomas Markwalder <tmark@isc.org>
Date: Fri, 20 Dec 2019 10:11:54 -0500
Subject: [PATCH] [#71] Fix dhcrelay agent option buffer pointer logic
relay/dhcrelay.c
strip_relay_agent_options()
strip_relay_agent_options()
- corrected buffer pointer logic
---
relay/dhcrelay.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c
index 896e1e2e..980dacae 100644
--- a/relay/dhcrelay.c
+++ b/relay/dhcrelay.c
@@ -1238,8 +1238,13 @@ strip_relay_agent_options(struct interface_info *in,
return (0);
if (sp != op) {
- memmove(sp, op, op[1] + 2);
- sp += op[1] + 2;
+ size_t mlen = op[1] + 2;
+ memmove(sp, op, mlen);
+ sp += mlen;
+ if (sp > max) {
+ return (0);
+ }
+
op = nextop;
} else
op = sp = nextop;
@@ -1620,8 +1620,13 @@ add_relay_agent_options(struct interface_info *ip, struct dhcp_packet *packet,
end_pad = NULL;
if (sp != op) {
- memmove(sp, op, op[1] + 2);
- sp += op[1] + 2;
+ size_t mlen = op[1] + 2;
+ memmove(sp, op, mlen);
+ sp += mlen;
+ if (sp > max) {
+ return (0);
+ }
+
op = nextop;
} else
op = sp = nextop;
--
2.17.1

View File

@ -1,8 +1,8 @@
diff --git a/debian/rules b/debian/rules diff --git a/debian/rules b/debian/rules
index 3c8318f..28f4657 100755 index 0906e53..6e96ffe 100755
--- a/debian/rules --- a/debian/rules
+++ b/debian/rules +++ b/debian/rules
@@ -37,6 +37,13 @@ export DO_LPF=1 @@ -38,6 +38,13 @@ export DO_LPF=1
CONFFLAGS+=--enable-use-sockets CONFFLAGS+=--enable-use-sockets
endif endif
@ -16,27 +16,27 @@ index 3c8318f..28f4657 100755
%: %:
dh $@ --parallel --with autoreconf dh $@ --parallel --with autoreconf
@@ -46,17 +53,17 @@ override_dh_auto_build: @@ -59,17 +66,17 @@ override_dh_auto_build:
# ldap-enabled build # ldap-enabled build
test -f Makefile && $(MAKE) distclean || true test -f Makefile && $(MAKE) distclean || true
./configure --with-ldap --with-ldapcrypto CFLAGS="$(CFLAGS) -DNSUPDATE" LIBS="-lirs-export $(LIBS)" $(CONFFLAGS) ./configure --with-ldap --with-ldapcrypto CFLAGS="$(CFLAGS) -DNSUPDATE" $(CONFFLAGS) LIBS="$(LIBS) -latomic"
- $(MAKE) - $(MAKE)
+ $(MAKE) $(PARALLEL) + $(MAKE) $(PARALLEL)
mv server/dhcpd dhcpd mv server/dhcpd dhcpd
# ddns-disabled build # ddns-disabled build
test -f Makefile && $(MAKE) distclean || true test -f Makefile && $(MAKE) distclean || true
./configure CFLAGS="$(CFLAGS)" $(CONFFLAGS) ./configure CFLAGS="$(CFLAGS)" $(CONFFLAGS) LIBS="$(LIBS) -latomic"
- $(MAKE) - $(MAKE)
+ $(MAKE) $(PARALLEL) + $(MAKE) $(PARALLEL)
mv client/dhclient dhclient mv client/dhclient dhclient
# ldap-disabled build # ldap-disabled build
test -f Makefile && $(MAKE) distclean || true test -f Makefile && $(MAKE) distclean || true
./configure CFLAGS="$(CFLAGS) -DNSUPDATE" LIBS="-lirs-export $(LIBS)" $(CONFFLAGS) ./configure CFLAGS="$(CFLAGS) -DNSUPDATE" $(CONFFLAGS) LIBS="$(LIBS) -latomic"
- $(MAKE) - $(MAKE)
+ $(MAKE) $(PARALLEL) + $(MAKE) $(PARALLEL)
override_dh_install: override_dh_install:
# rename some upstream files # rename some upstream files
-- --
2.34.1 2.25.1

View File

@ -1,8 +1,8 @@
diff --git a/common/discover.c b/common/discover.c diff --git a/common/discover.c b/common/discover.c
index ab50234..40e13f5 100644 index 20d7c54..9ee8bc2 100644
--- a/common/discover.c --- a/common/discover.c
+++ b/common/discover.c +++ b/common/discover.c
@@ -1614,3 +1614,16 @@ void interface_snorf (struct interface_info *tmp, int ir) @@ -1619,3 +1619,16 @@ void interface_snorf (struct interface_info *tmp, int ir)
} }
interface_reference (&interfaces, tmp, MDL); interface_reference (&interfaces, tmp, MDL);
} }
@ -21,10 +21,10 @@ index ab50234..40e13f5 100644
+} +}
\ No newline at end of file \ No newline at end of file
diff --git a/includes/dhcpd.h b/includes/dhcpd.h diff --git a/includes/dhcpd.h b/includes/dhcpd.h
index 257b31e..e7f9f06 100644 index 68d44cf..8c307b6 100644
--- a/includes/dhcpd.h --- a/includes/dhcpd.h
+++ b/includes/dhcpd.h +++ b/includes/dhcpd.h
@@ -2873,6 +2873,7 @@ extern int interface_count; @@ -2885,6 +2885,7 @@ extern int interface_count;
extern int interface_max; extern int interface_max;
isc_result_t interface_initialize(omapi_object_t *, const char *, int); isc_result_t interface_initialize(omapi_object_t *, const char *, int);
void discover_interfaces(int); void discover_interfaces(int);
@ -33,7 +33,7 @@ index 257b31e..e7f9f06 100644
int if_readsocket (omapi_object_t *); int if_readsocket (omapi_object_t *);
void reinitialize_interfaces (void); void reinitialize_interfaces (void);
diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c
index ff0ad17..31fe61b 100644 index 6aa1179..a1aa234 100644
--- a/relay/dhcrelay.c --- a/relay/dhcrelay.c
+++ b/relay/dhcrelay.c +++ b/relay/dhcrelay.c
@@ -92,6 +92,11 @@ struct downstream_intf_list { @@ -92,6 +92,11 @@ struct downstream_intf_list {
@ -48,23 +48,23 @@ index ff0ad17..31fe61b 100644
#ifdef DHCPv6 #ifdef DHCPv6
/* Force use of DHCPv6 interface-id option. */ /* Force use of DHCPv6 interface-id option. */
isc_boolean_t use_if_id = ISC_FALSE; isc_boolean_t use_if_id = ISC_FALSE;
@@ -199,6 +204,7 @@ char *progname; @@ -208,6 +213,7 @@ char *progname;
" [-i interface0 [ ... -i interfaceN]\n" \ " [-i interface0 [ ... -i interfaceN]\n" \
" [-iu interface0 [ ... -iu interfaceN]\n" \ " [-iu interface0 [ ... -iu interfaceN]\n" \
" [-id interface0 [ ... -id interfaceN]\n" \ " [-id interface0 [ ... -id interfaceN]\n" \
+" [-pg ip-address0 [ ... -pg ip-addressN]]\n" \ +" [-pg ip-address0 [ ... -pg ip-addressN]]\n" \
" [-U interface]\n" \ " [-U interface] [-g <ip-address>]\n" \
" [-dt]\n"\ " [-dt]\n"\
" server0 [ ... serverN]\n\n" \ " server0 [ ... serverN]\n\n" \
@@ -221,6 +227,7 @@ char *progname; @@ -230,6 +236,7 @@ char *progname;
" [-i interface0 [ ... -i interfaceN]\n" \ " [-i interface0 [ ... -i interfaceN]\n" \
" [-iu interface0 [ ... -iu interfaceN]\n" \ " [-iu interface0 [ ... -iu interfaceN]\n" \
" [-id interface0 [ ... -id interfaceN]\n" \ " [-id interface0 [ ... -id interfaceN]\n" \
+" [-pg ip-address0 [ ... -pg ip-addressN]]\n" \ +" [-pg ip-address0 [ ... -pg ip-addressN]]\n" \
" [-U interface]\n" \ " [-U interface] [-g <ip-address>]\n" \
" [-dt]\n"\ " [-dt]\n"\
" server0 [ ... serverN]\n\n" \ " server0 [ ... serverN]\n\n" \
@@ -649,6 +656,34 @@ main(int argc, char **argv) { @@ -673,6 +680,34 @@ main(int argc, char **argv) {
usage(use_noarg, argv[i-1]); usage(use_noarg, argv[i-1]);
path_dhcrelay_pid = argv[i]; path_dhcrelay_pid = argv[i];
no_dhcrelay_pid = ISC_TRUE; no_dhcrelay_pid = ISC_TRUE;
@ -99,7 +99,7 @@ index ff0ad17..31fe61b 100644
} else if (!strcmp(argv[i], "--no-pid")) { } else if (!strcmp(argv[i], "--no-pid")) {
no_pid_file = ISC_TRUE; no_pid_file = ISC_TRUE;
} else if (!strcmp(argv[i], "--name-alias-map-file")) { } else if (!strcmp(argv[i], "--name-alias-map-file")) {
@@ -818,6 +853,12 @@ main(int argc, char **argv) { @@ -842,6 +877,12 @@ main(int argc, char **argv) {
/* Discover all the network interfaces. */ /* Discover all the network interfaces. */
discover_interfaces(DISCOVER_RELAY); discover_interfaces(DISCOVER_RELAY);
@ -112,3 +112,6 @@ index ff0ad17..31fe61b 100644
#ifdef DHCPv6 #ifdef DHCPv6
if (local_family == AF_INET6) if (local_family == AF_INET6)
setup_streams(); setup_streams();
--
2.25.1

View File

@ -11,7 +11,6 @@
0010-Bugfix-correctly-set-interface-netmask.patch 0010-Bugfix-correctly-set-interface-netmask.patch
0011-dhcp-relay-Prevent-Buffer-Overrun.patch 0011-dhcp-relay-Prevent-Buffer-Overrun.patch
0012-add-option-si-to-support-using-src-intf-ip-in-relay.patch 0012-add-option-si-to-support-using-src-intf-ip-in-relay.patch
0013-Fix-dhcrelay-agent-option-buffer-pointer-logic.patch
0014-enable-parallel-build.patch 0014-enable-parallel-build.patch
0015-option-to-set-primary-address-in-interface.patch 0015-option-to-set-primary-address-in-interface.patch
0016-Don-t-look-up-the-ifindex-for-fallback.patch 0016-Don-t-look-up-the-ifindex-for-fallback.patch