Skip to content

Commit bc06c6f

Browse files
authored
Incorporate DHCPv6 Relay Agent into dhcp-relay docker (sonic-net#8321)
1 parent 4da623c commit bc06c6f

File tree

14 files changed

+83
-73
lines changed

14 files changed

+83
-73
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
group:isc-dhcp-relay
1+
group:dhcp-relay

dockers/docker-dhcp-relay/dhcp-relay.programs.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[group:isc-dhcp-relay]
1+
[group:dhcp-relay]
22
programs=
33
{%- set add_preceding_comma = { 'flag': False } %}
44
{% for vlan_name in VLAN_INTERFACE %}
@@ -12,6 +12,6 @@ isc-dhcpv4-relay-{{ vlan_name }}
1212
{% if VLAN and vlan_name in VLAN and 'dhcpv6_servers' in VLAN[vlan_name] and VLAN[vlan_name]['dhcpv6_servers']|length > 0 %}
1313
{% if add_preceding_comma.flag %},{% endif %}
1414
{% set _dummy = add_preceding_comma.update({'flag': True}) %}
15-
isc-dhcpv6-relay-{{ vlan_name }}
15+
dhcp6relay
1616
{%- endif %}
1717
{% endfor %}

dockers/docker-dhcp-relay/dhcpv6-relay.agents.j2

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,8 @@
77
{% endfor %}
88
{% if relay_for_ipv6.flag %}
99
{% set _dummy = relay_for_ipv6.update({'flag': False}) %}
10-
[program:isc-dhcpv6-relay-{{ vlan_name }}]
11-
{# We treat this VLAN as a downstream interface (-l), as we only want to listen for requests #}
12-
command=/usr/sbin/dhcrelay -d -6 --name-alias-map-file /tmp/port-name-alias-map.txt -l {{ vlan_name }}
13-
{#- We treat all other interfaces as upstream interfaces (-u), as we only want to listen for replies #}
14-
{%- for dhcpv6_server in VLAN[vlan_name]['dhcpv6_servers'] %}
15-
{%- if dhcpv6_server | ipv6 %}
16-
{%- for (name, prefix) in VLAN_INTERFACE|pfx_filter %}
17-
{%- if prefix | ipv6 and name != vlan_name %} -u {{ dhcpv6_server }}%%{{ name }} {% endif -%}
18-
{% endfor %}
19-
{% for (name, prefix) in INTERFACE|pfx_filter %}
20-
{% if prefix | ipv6 %} -u {{ dhcpv6_server }}%%{{ name }} {% endif -%}
21-
{% endfor %}
22-
{% for (name, prefix) in PORTCHANNEL_INTERFACE|pfx_filter %}
23-
{% if prefix | ipv6 %} -u {{ dhcpv6_server }}%%{{ name }} {% endif -%}
24-
{% endfor %}
25-
{% endif -%}
26-
{% endfor %}
10+
[program:dhcp6relay]
11+
command=/usr/sbin/dhcp6relay
2712

2813
priority=3
2914
autostart=false

dockers/docker-dhcp-relay/dhcpv6-relay.monitors.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ stderr_logfile=syslog
7070
dependent_startup=true
7171
dependent_startup_wait_for=
7272
{%- if relay_for_ipv4.flag %}isc-dhcpv4-relay-{{ vlan_name }}:running {% endif %}
73-
{% if relay_for_ipv6.flag %}isc-dhcpv6-relay-{{ vlan_name }}:running{% endif %}
73+
{% if relay_for_ipv6.flag %}dhcp6relay:running{% endif %}
7474

7575

7676
{% set _dummy = relay_for_ipv4.update({'flag': False}) %}

rules/dhcp6relay.dep

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
SPATH := $($(SONIC_DHCP6RELAY)_SRC_PATH)
3+
DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/dhcp6relay.mk rules/dhcp6relay.dep
4+
DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST)
5+
DEP_FILES += $(shell git ls-files $(SPATH))
6+
7+
$(SONIC_DHCP6RELAY)_CACHE_MODE := GIT_CONTENT_SHA
8+
$(SONIC_DHCP6RELAY)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST)
9+
$(SONIC_DHCP6RELAY)_DEP_FILES := $(DEP_FILES)

rules/dhcp6relay.mk

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# SONiC DHCPV6 RELAY Package
2+
3+
SONIC_DHCP6RELAY_VERSION = 1.0.0-0
4+
SONIC_DHCP6RELAY_PKG_NAME = dhcp6relay
5+
6+
SONIC_DHCP6RELAY = sonic-$(SONIC_DHCP6RELAY_PKG_NAME)_$(SONIC_DHCP6RELAY_VERSION)_$(CONFIGURED_ARCH).deb
7+
$(SONIC_DHCP6RELAY)_DEPENDS = $(LIBSWSSCOMMON) $(LIBHIREDIS) $(LIBSWSSCOMMON_DEV) $(LIBHIREDIS_DEV)
8+
$(DOCKER_DHCP_RELAY)_INSTALL_DEBS = $(LIBSWSSCOMMON) $(LIBHIREDIS) $(LIBSWSSCOMMON_DEV) $(LIBHIREDIS_DEV)
9+
$(SONIC_DHCP6RELAY)_SRC_PATH = $(SRC_PATH)/$(SONIC_DHCP6RELAY_PKG_NAME)
10+
SONIC_DPKG_DEBS += $(SONIC_DHCP6RELAY)

rules/docker-dhcp-relay.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ DOCKER_DHCP_RELAY_DBG = $(DOCKER_DHCP_RELAY_STEM)-$(DBG_IMAGE_MARK).gz
66

77
$(DOCKER_DHCP_RELAY)_PATH = $(DOCKERS_PATH)/$(DOCKER_DHCP_RELAY_STEM)
88

9-
$(DOCKER_DHCP_RELAY)_DEPENDS += $(ISC_DHCP_RELAY) $(SONIC_DHCPMON)
9+
$(DOCKER_DHCP_RELAY)_DEPENDS += $(ISC_DHCP_RELAY) $(SONIC_DHCPMON) $(SONIC_DHCP6RELAY) $(LIBSWSSCOMMON)
1010

1111
$(DOCKER_DHCP_RELAY)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_DEPENDS)
1212
$(DOCKER_DHCP_RELAY)_DBG_DEPENDS += $(ISC_DHCP_RELAY_DBG)

src/dhcp6relay/src/configInterface.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ swss::SubscriberStateTable ipHelpersTable(configDbPtr.get(), "DHCP_RELAY");
1313
swss::Select swssSelect;
1414

1515
/**
16-
* @code void deinitialize_swss()
16+
* @code void initialize_swss()
1717
*
1818
* @brief initialize DB tables and start SWSS listening thread
1919
*
2020
* @return none
2121
*/
22-
void initialize_swss(std::vector<relay_config> *vlans, swss::DBConnector *db)
22+
void initialize_swss(std::vector<relay_config> *vlans)
2323
{
2424
try {
2525
swssSelect.addSelectable(&ipHelpersTable);
@@ -85,7 +85,7 @@ void handleSwssNotification(std::vector<relay_config> *vlans)
8585
* @brief handles DHCPv6 relay configuration change notification
8686
*
8787
* @param ipHelpersTable DHCP table
88-
* @param context list of vlans/argument config that contains strings of server and option
88+
* @param vlans list of vlans/argument config that contains strings of server and option
8989
*
9090
* @return none
9191
*/
@@ -103,7 +103,7 @@ void handleRelayNotification(swss::SubscriberStateTable &ipHelpersTable, std::ve
103103
* @brief process DHCPv6 relay servers and options configuration change notification
104104
*
105105
* @param entries queue of std::tuple<std::string, std::string, std::vector<FieldValueTuple>> entries in DHCP table
106-
* @param context list of vlans/argument config that contains strings of server and option
106+
* @param vlans list of vlans/argument config that contains strings of server and option
107107
*
108108
* @return none
109109
*/
@@ -117,6 +117,7 @@ void processRelayNotification(std::deque<swss::KeyOpFieldsValuesTuple> &entries,
117117
std::vector<swss::FieldValueTuple> fieldValues = kfvFieldsValues(entry);
118118

119119
relay_config intf;
120+
intf.is_option_79 = true;
120121
intf.interface = vlan;
121122
for (auto &fieldValue: fieldValues) {
122123
std::string f = fvField(fieldValue);
@@ -130,11 +131,8 @@ void processRelayNotification(std::deque<swss::KeyOpFieldsValuesTuple> &entries,
130131
}
131132
syslog(LOG_DEBUG, "key: %s, Operation: %s, f: %s, v: %s", vlan.c_str(), operation.c_str(), f.c_str(), v.c_str());
132133
}
133-
if(f == "dhcpv6_option|rfc6939_support") {
134-
if(v == "true")
135-
intf.is_option_79 = true;
136-
else if(v == "false")
137-
intf.is_option_79 = false;
134+
if(f == "dhcpv6_option|rfc6939_support" && v == "false") {
135+
intf.is_option_79 = false;
138136
}
139137
}
140138
vlans->push_back(intf);

src/dhcp6relay/src/configInterface.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
#include "relay.h"
55

66
/**
7-
* @code void deinitialize_swss()
7+
* @code void initialize_swss()
88
*
99
* @brief initialize DB tables and start SWSS listening thread
1010
*
1111
* @return none
1212
*/
13-
void initialize_swss(std::vector<relay_config> *vlans, swss::DBConnector *db);
13+
void initialize_swss(std::vector<relay_config> *vlans);
1414

1515
/**
1616
* @code void deinitialize_swss()
@@ -35,7 +35,7 @@ void get_dhcp(std::vector<relay_config> *vlans);
3535
*
3636
* @brief main thread for handling SWSS notification
3737
*
38-
* @param context list of vlans/argument config that contains strings of server and option
38+
* @param vlans list of vlans/argument config that contains strings of server and option
3939
*
4040
* @return none
4141
*/
@@ -47,7 +47,7 @@ void handleSwssNotification(std::vector<relay_config> *vlans);
4747
* @brief handles DHCPv6 relay configuration change notification
4848
*
4949
* @param ipHelpersTable DHCP table
50-
* @param context list of vlans/argument config that contains strings of server and option
50+
* @param vlans list of vlans/argument config that contains strings of server and option
5151
*
5252
* @return none
5353
*/

src/dhcp6relay/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ int main(int argc, char *argv[]) {
66
try {
77
std::vector<relay_config> vlans;
88
swss::DBConnector state_db("STATE_DB", 0);
9-
initialize_swss(&vlans, &state_db);
9+
initialize_swss(&vlans);
1010
loop_relay(&vlans, &state_db);
1111
}
1212
catch (std::exception &e)

0 commit comments

Comments
 (0)