Skip to content

hostcfgd service enhancements to support Management interface config handling in SONiC#4546

Open
rvasanthm wants to merge 1 commit intosonic-net:masterfrom
rvasanthm:master
Open

hostcfgd service enhancements to support Management interface config handling in SONiC#4546
rvasanthm wants to merge 1 commit intosonic-net:masterfrom
rvasanthm:master

Conversation

@rvasanthm
Copy link
Contributor

  • What I did
    1.Added support for Dynamic handling of Management port config(MTU, Speed, auto negotiation, admin status and Description config attributes).
  1. Added support for Dynamic handling of Management interface config (IPv4/IPv6 DHCP client, IPv4/IPv6 default gateway, IPv4/IPv6 addresses config and respective gateways config attributes).
  2. Added support for Management VRF handling
  • How I did it
    hostcfgd service enhancement details:
    Hostcfgd populates default config for a management interface (“eth0”) and register’s callback handlers to handle events/notifications from the following tables MGMT_PORT, MGMT_INTERFACE and MGMT_VRF_CONFIG in ConfigDB and starts listening for events at INIT phase. As soon as any change observed in above mentioned tables respective event handle will be called, and it determines the config change and programs the same in kernel and populates data in AppDb.

List of Event handlers added:
mgmt_port_handler is a callback method to handle port related config which is populated in MGMT_PORT table in ConfigDB.
mgmt_intf_handler is a callback method to handle interface IP config which is populated in MGMT_INTERFACE table in ConfigDB.
mgmt_vrf_handler is callback method to handle MGMT vrf config which is populated in MGMT_VRF_CONFIG table in ConfigDB.

  • How to verify it
    Update MGMT_PORT, MGMT_INTERFACE and MGMT_VRF_CONFIG config attributes mentioned below, config should be applied in kernel and it should get populated in AppDB.

  • Description for the change log
    Management interface config handling in SONiC by hostcfgd service.

Signed-off-by: Ravi Vasanthm [email protected]

…f Management port config(MTU, Speed, auto negotiation, admin status and Description config attributes), 2. Added support for Dynamic handling of Management interface config (IPv4/IPv6 DHCP client, IPv4/IPv6 default gateway, IPv4/IPv6 addresses config and respective gateways config attributes) and Management VRF handling.
echo "dhcp_mgmt_conf_handle, interface : $IF_NAME"

if [ "$IF_NAME" = "eth0" ]; then
echo "DHCP exit hook is called for $IF_NAME, reason : $reason"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you updated this echo "... called for $IF_NAME for updating ip addr in app db, reason : $reason" ?

@@ -0,0 +1,53 @@
#!/bin/sh
#
# DHCLIENT exit hook for ip address update in app db
Copy link
Collaborator

Choose a reason for hiding this comment

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

please add some more comments to explain why this information needs to be added in APP DB.

fi
;;
RENEW|REBIND|RENEW6|REBIND6)
if [ -n "$old_ip_address" ] && [ -n "$old_subnet_mask" ]; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a comment to explain where and how the old_ip_address and old_subnet_mask are updated?


ifdown --force eth0

# Check if ZTP DHCP policy has been installed
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason to remove the "ifdown --force eth0"? This line was present in this file from beginning. Are you sure that removal of this line wont affect any functionality?


return

def handle_mgmt_intf_gwaddr_cfg(self, op, ifname, gwaddr):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think its better to rename all functions related to management VRF using a prefix "mvrf". For example, this def "handle_mgmt_intf_gwaddr_cfg" is actually adding default route only for the management VRF case. Hence, its better to rename this to mvrf_configure_default_route. By the by, there is already a def "mgmt_intf_gwaddr_set",which handles default route. Is there a need for a separate function for "handle_mgmt_intf_gwaddr_cfg"?


return rc

def handle_mgmt_intf_creation(self, mgmt_intf_key):
Copy link
Collaborator

@kannankvs kannankvs May 8, 2020

Choose a reason for hiding this comment

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

I dont see this def being used in code. Can we remove? If we remove, the other def mgmt_vrf_add_default_routes can also be removed. Or, is the calling place for this function missed out? When mvrf is created, there should be a call for this to add default routes and also for taking all other actions as given in interfaces.j2 earlier.

entry = self.config_db.get_entry(CFG_MGMT_VRF, CFG_MGMT_VRF_KEY)
if entry:
if (('mgmtVrfEnabled' in entry) and (entry['mgmtVrfEnabled'] == 'true')):
vrf_table = '5000'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use the same macro in code instead of 5000.

mgmt_intf_gwaddr = entry['gwaddr']
self.handle_mgmt_intf_gwaddr_cfg("ADD", it[0], mgmt_intf_gwaddr)

def unconfigure_mgmt_vrf(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

unconfigure_mgmt_vrf definition is deleting "lo-m" and calls delete_mgmt_vrf_table which deletes the "mgmt" interface. When mvrf is disabled, where does it delink eth0 from master mgmt and where does it add the default routes and other routes back to default routing table? Same comment applies while enabling mvrf.

self.unconfigure_mgmt_vrf()
else:
self.unconfigure_mgmt_vrf()
except Exception as inst:
Copy link
Collaborator

Choose a reason for hiding this comment

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

what are the possible reasons for this exception? If mvrf enable/disable fails, will eth0 continue to remain in default/mgmt vrf and work normally in default/mgmt vrf?

def configure_mgmt_vrf(self):
self.create_mgmt_vrf_table()

cmd = 'ip link set dev mgmt up'
Copy link
Collaborator

Choose a reason for hiding this comment

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

If any of these steps fails, is it better to do a syslog to debug?

@rvasanthm
Copy link
Contributor Author

retest broadcom please

@prsunny prsunny closed this May 14, 2020
@prsunny prsunny reopened this May 14, 2020
@rvasanthm rvasanthm requested a review from lguohan as a code owner February 6, 2021 20:29
@rvasanthm rvasanthm requested a review from a team as a code owner June 10, 2022 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants