@@ -59,12 +59,13 @@ void DHCPMgr::handle_swss_notification() {
5959 swss::SubscriberStateTable config_db_portchannel_table (config_db_ptr.get (), " PORTCHANNEL_INTERFACE" );
6060 swss::SubscriberStateTable config_db_device_metadata_table (config_db_ptr.get (), " DEVICE_METADATA" );
6161 swss::SubscriberStateTable config_db_vlan_member_table (config_db_ptr.get (), " VLAN_MEMBER" );
62- swss::SubscriberStateTable config_db_vlan_interface_table (config_db_ptr.get (), " VLAN_INTERFACE" );
6362 swss::SubscriberStateTable config_db_feature_table (config_db_ptr.get (), " FEATURE" );
6463 swss::SubscriberStateTable config_db_vlan_table (config_db_ptr.get (), " VLAN" );
6564 config_db_dhcp_server_ipv4_ptr = std::make_shared<swss::SubscriberStateTable>(config_db_ptr.get (), " DHCP_SERVER_IPV4" );
6665 state_db_dhcp_server_ipv4_ip_ptr = std::make_shared<swss::SubscriberStateTable>(state_db_ptr.get (), " DHCP_SERVER_IPV4_SERVER_IP" );
6766 swss::SubscriberStateTable config_db_port_table (config_db_ptr.get (), " PORT" );
67+ swss::SubscriberStateTable config_db_dpu_table (config_db_ptr.get (), " DPUS" );
68+ swss::SubscriberStateTable state_db_interface_table (state_db_ptr.get (), " INTERFACE_TABLE" );
6869
6970 std::deque<swss::KeyOpFieldsValuesTuple> entries;
7071 swss::Select swss_select;
@@ -74,12 +75,13 @@ void DHCPMgr::handle_swss_notification() {
7475 swss_select.addSelectable (&config_db_portchannel_table);
7576 swss_select.addSelectable (&config_db_device_metadata_table);
7677 swss_select.addSelectable (&config_db_vlan_member_table);
77- swss_select.addSelectable (&config_db_vlan_interface_table);
7878 swss_select.addSelectable (&config_db_feature_table);
7979 swss_select.addSelectable (&config_db_vlan_table);
8080 swss_select.addSelectable (config_db_dhcp_server_ipv4_ptr.get ());
8181 swss_select.addSelectable (state_db_dhcp_server_ipv4_ip_ptr.get ());
8282 swss_select.addSelectable (&config_db_port_table);
83+ swss_select.addSelectable (&config_db_dpu_table);
84+ swss_select.addSelectable (&state_db_interface_table);
8385
8486 while (!stop_thread) {
8587 swss::Selectable *selectable;
@@ -125,8 +127,8 @@ void DHCPMgr::handle_swss_notification() {
125127 } else if (selectable == static_cast <swss::Selectable *>(&config_db_vlan_member_table)) {
126128 config_db_vlan_member_table.pops (entries);
127129 process_vlan_member_notification (entries);
128- } else if (selectable == static_cast <swss::Selectable *>(&config_db_vlan_interface_table )) {
129- config_db_vlan_interface_table .pops (entries);
130+ } else if (selectable == static_cast <swss::Selectable *>(&state_db_interface_table )) {
131+ state_db_interface_table .pops (entries);
130132 process_vlan_interface_notification (entries);
131133 } else if (selectable == static_cast <swss::Selectable *>(&config_db_feature_table)) {
132134 config_db_feature_table.pops (entries);
@@ -137,6 +139,9 @@ void DHCPMgr::handle_swss_notification() {
137139 } else if (selectable == static_cast <swss::Selectable *>(&config_db_port_table)) {
138140 config_db_port_table.pops (entries);
139141 process_port_notification (entries);
142+ } else if (selectable == static_cast <swss::Selectable *>(&config_db_dpu_table)) {
143+ config_db_dpu_table.pops (entries);
144+ process_port_notification (entries);
140145 }
141146 }
142147}
@@ -157,6 +162,8 @@ void DHCPMgr::process_device_metadata_notification(std::deque<swss::KeyOpFieldsV
157162 std::string key = kfvKey (entry);
158163 std::vector<swss::FieldValueTuple> field_values = kfvFieldsValues (entry);
159164 std::string operation = kfvOp (entry);
165+ std::shared_ptr<swss::DBConnector> config_db = std::make_shared<swss::DBConnector>(" CONFIG_DB" , 0 );
166+ swss::Table midplane_tbl (config_db.get (), " MID_PLANE_BRIDGE" );
160167
161168 if (key != " localhost" ) {
162169 continue ;
@@ -191,6 +198,20 @@ void DHCPMgr::process_device_metadata_notification(std::deque<swss::KeyOpFieldsV
191198 send_dualTor_event = true ;
192199 }
193200
201+ // Handle is_SmartSwitch logic
202+ if (subtype_found && subtype_value == " SmartSwitch" ) {
203+ m_config.is_SmartSwitch = true ;
204+ std::string bridge_name;
205+ bool ok = midplane_tbl.hget (" GLOBAL" , " bridge" , bridge_name);
206+ if (ok) {
207+ m_config.midplane_bridge = bridge_name;
208+ } else {
209+ syslog (LOG_ERR, " Failed to read midplane bridge name\n " );
210+ }
211+ } else if (m_config.is_SmartSwitch ) {
212+ m_config.is_SmartSwitch = false ;
213+ }
214+
194215 if (send_dualTor_event) {
195216 relay_config *relay_msg = nullptr ;
196217 try {
@@ -599,7 +620,11 @@ void DHCPMgr::process_vlan_member_notification(std::deque<swss::KeyOpFieldsValue
599620
600621void DHCPMgr::process_vlan_interface_notification (std::deque<swss::KeyOpFieldsValuesTuple> &entries) {
601622 for (auto &entry : entries) {
602- std::string key = kfvKey (entry);
623+ std::string key = kfvKey (entry);
624+ // Only process VLAN interfaces (keys starting with "Vlan" and Vlan with IP suffix)
625+ if (key.rfind (" Vlan" , 0 ) != 0 ) {
626+ continue ;
627+ }
603628
604629 std::string vlan;
605630 std::string vrf;
@@ -608,7 +633,7 @@ void DHCPMgr::process_vlan_interface_notification(std::deque<swss::KeyOpFieldsVa
608633 vlan = key;
609634 vrf = " default" ;
610635 for (auto &fv : kfvFieldsValues (entry)) {
611- if (fvField (fv) == " vrf_name " ) {
636+ if (fvField (fv) == " vrf " ) {
612637 vrf = fvValue (fv);
613638 break ;
614639 }
@@ -720,8 +745,10 @@ void DHCPMgr::process_dhcp_server_ipv4_notification(std::deque<swss::KeyOpFields
720745 }
721746
722747 /* Validation to check vlan is present in VLAN table or not */
748+ /* If its a smartswitch, we are checking midplane_bridge details */
723749 std::string value;
724- if (!vlan_tbl.hget (vlan, " vlanid" , value)) {
750+ if ((!vlan_tbl.hget (vlan, " vlanid" , value))
751+ && (!m_config.is_SmartSwitch || (!m_config.midplane_bridge .empty () && m_config.midplane_bridge != vlan))) {
725752 delete relay_msg;
726753 continue ;
727754 }
@@ -808,6 +835,9 @@ void DHCPMgr::process_port_notification(std::deque<swss::KeyOpFieldsValuesTuple>
808835 if (fvField (fv) == " alias" ) {
809836 port_msg->alias = fvValue (fv);
810837 break ;
838+ } else if (fvField (fv) == " midplane_interface" ) {
839+ port_msg->alias = fvValue (fv);
840+ break ;
811841 }
812842 }
813843 } else {
0 commit comments