Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions dhcp4relay/src/dhcp4relay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ void update_vlan_mapping(std::string vlan, bool is_add) {
if (is_add) {
std::string value;
std::shared_ptr<swss::Table> vlan_intf_tbl = std::make_shared<swss::Table>(config_db.get(), CFG_VLAN_INTF_TABLE_NAME);
vlan_intf_tbl->hget(vlan, "vrf_name", value);
vlan_intf_tbl->hget(vlan, VRF_NAME_FIELD, value);
if (value.size() <= 0) {
/* use default instance as vrf */
vlan_vrf_map[vlan] = "default";
Expand Down Expand Up @@ -1337,7 +1337,7 @@ void config_event_callback(evutil_socket_t fd, short event, void *arg) {
std::string value;
std::shared_ptr<swss::Table> dhcp_relay_tbl = std::make_shared<swss::Table>(config_db.get(),
"DHCPV4_RELAY");
dhcp_relay_tbl->hget((msg->vlan), "server_vrf", value);
dhcp_relay_tbl->hget((msg->vlan), SERVER_VRF_FIELD, value);
if ((msg->vrf.empty()) || (value.length() != 0)) {
return;
}
Expand Down Expand Up @@ -1381,7 +1381,7 @@ void config_event_callback(evutil_socket_t fd, short event, void *arg) {
std::string value;

// Check for the presence of specific keys
v4_relay_intf_tbl->hget(vlan.second.vlan, "link_selection", value);
v4_relay_intf_tbl->hget(vlan.second.vlan, LINK_SELECTION_FIELD, value);
// Check if "link_selection" is present
if (value.length() > 0) {
// Fetch the value of "link_selection" from the database
Expand All @@ -1391,7 +1391,7 @@ void config_event_callback(evutil_socket_t fd, short event, void *arg) {
vlan.second.link_selection_opt.clear();
}

v4_relay_intf_tbl->hget(vlan.second.vlan, "source_interface", value);
v4_relay_intf_tbl->hget(vlan.second.vlan, SOURCE_INTERFACE_FIELD, value);
// Check if "source_interface" is present
if (value.length() > 0) {
// Fetch the value of "source_interface" from the database
Expand Down
5 changes: 5 additions & 0 deletions dhcp4relay/src/dhcp4relay.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
#define DHCPv4_OPTION_LIMIT 255
#define RAWSOCKET_RECV_SIZE 1048576
#define CLIENT_IF_PREFIX "Ethernet"
#define VRF_NAME_FIELD "vrf_name" // typo "vrf" caused VRF-update miss; field is "vrf_name"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment can probably be removed. It's already covered in PR description.

#define SERVER_VRF_FIELD "server_vrf"
#define SOURCE_INTERFACE_FIELD "source_interface"
#define LINK_SELECTION_FIELD "link_selection"
#define STATE_FIELD "state"
#define BUFFER_SIZE 9200 // TODO: change to dynamic size based on MTU
#define MAX_DHCP_PKT_SIZE 1472 // 1500 - (IP + UDP)headers
#define MAC_ADDR_STR_LEN 17
Expand Down
14 changes: 7 additions & 7 deletions dhcp4relay/src/dhcp4relay_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,11 @@ void DHCPMgr::process_relay_notification(std::deque<swss::KeyOpFieldsValuesTuple
getline(ss, substr, ',');
relay_msg->servers.push_back(substr);
}
} else if (f == "server_vrf") {
} else if (f == SERVER_VRF_FIELD) {
relay_msg->vrf = v;
} else if (f == "source_interface") {
} else if (f == SOURCE_INTERFACE_FIELD) {
relay_msg->source_interface = v;
} else if (f == "link_selection") {
} else if (f == LINK_SELECTION_FIELD) {
relay_msg->link_selection_opt = v;
} else if (f == "server_id_override") {
relay_msg->server_id_override_opt = v;
Expand All @@ -379,7 +379,7 @@ void DHCPMgr::process_relay_notification(std::deque<swss::KeyOpFieldsValuesTuple
std::string value;
std::shared_ptr<swss::DBConnector> config_db = std::make_shared<swss::DBConnector>("CONFIG_DB", 0);
std::shared_ptr<swss::Table> vlan_intf_tbl = std::make_shared<swss::Table>(config_db.get(), CFG_VLAN_INTF_TABLE_NAME);
vlan_intf_tbl->hget(vlan, "vrf_name", value);
vlan_intf_tbl->hget(vlan, VRF_NAME_FIELD, value);
if (value.size() <= 0) {
relay_msg->vrf = "default";
} else {
Expand Down Expand Up @@ -441,7 +441,7 @@ void DHCPMgr::process_feature_notification(std::deque<swss::KeyOpFieldsValuesTup

std::string state;
for (auto &field : kfvFieldsValues(entry)) {
if (fvField(field) == "state") {
if (fvField(field) == STATE_FIELD) {
state = fvValue(field);
break;
}
Expand Down Expand Up @@ -633,7 +633,7 @@ void DHCPMgr::process_vlan_interface_notification(std::deque<swss::KeyOpFieldsVa
vlan = key;
vrf = "default";
for (auto &fv : kfvFieldsValues(entry)) {
if (fvField(fv) == "vrf") {
if (fvField(fv) == VRF_NAME_FIELD) {
vrf = fvValue(fv);
break;
}
Expand Down Expand Up @@ -706,7 +706,7 @@ void DHCPMgr::process_dhcp_server_ipv4_notification(std::deque<swss::KeyOpFields
if (operation == "SET") {
std::string state;
for (auto &fv : kfvFieldsValues(entry)) {
if (fvField(fv) == "state") {
if (fvField(fv) == STATE_FIELD) {
state = fvValue(fv);
break;
}
Expand Down
Loading