diff --git a/dhcp4relay/src/dhcp4relay.cpp b/dhcp4relay/src/dhcp4relay.cpp index bc68509..4362460 100644 --- a/dhcp4relay/src/dhcp4relay.cpp +++ b/dhcp4relay/src/dhcp4relay.cpp @@ -864,7 +864,7 @@ void update_vlan_mapping(std::string vlan, bool is_add) { if (is_add) { std::string value; std::shared_ptr vlan_intf_tbl = std::make_shared(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"; @@ -1337,7 +1337,7 @@ void config_event_callback(evutil_socket_t fd, short event, void *arg) { std::string value; std::shared_ptr dhcp_relay_tbl = std::make_shared(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; } @@ -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 @@ -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 diff --git a/dhcp4relay/src/dhcp4relay.h b/dhcp4relay/src/dhcp4relay.h index 000c33c..d7565b6 100644 --- a/dhcp4relay/src/dhcp4relay.h +++ b/dhcp4relay/src/dhcp4relay.h @@ -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" +#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 diff --git a/dhcp4relay/src/dhcp4relay_mgr.cpp b/dhcp4relay/src/dhcp4relay_mgr.cpp index c5d631b..115c824 100644 --- a/dhcp4relay/src/dhcp4relay_mgr.cpp +++ b/dhcp4relay/src/dhcp4relay_mgr.cpp @@ -356,11 +356,11 @@ void DHCPMgr::process_relay_notification(std::dequeservers.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; @@ -379,7 +379,7 @@ void DHCPMgr::process_relay_notification(std::deque config_db = std::make_shared("CONFIG_DB", 0); std::shared_ptr vlan_intf_tbl = std::make_shared(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 { @@ -441,7 +441,7 @@ void DHCPMgr::process_feature_notification(std::deque