Skip to content

Adding vrrpsyncd module #3313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

Adding vrrpsyncd module #3313

wants to merge 18 commits into from

Conversation

vvbrcm
Copy link

@vvbrcm vvbrcm commented Oct 2, 2024

What I did
Add module vrrpsyncd to program VRRP entities (VIP and VMAC) from kernel to APP_DB
Why I did it
Support VRRP component
How I verified it
UT
Details if related

@vvbrcm vvbrcm requested a review from prsunny as a code owner October 2, 2024 01:23
Copy link

linux-foundation-easycla bot commented Oct 2, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@adyeung
Copy link

adyeung commented Oct 2, 2024

@philo-micas @madhupalu please help review

@nmoray
Copy link

nmoray commented Oct 3, 2024

@vvbrcm can you please confirm if you are planning to extend this PR only to accomodate vrrporch related changes too?

@vvbrcm
Copy link
Author

vvbrcm commented Oct 3, 2024

@vvbrcm can you please confirm if you are planning to extend this PR only to accomodate vrrporch related changes too?

Please refer to below PR link for vrrporch changes.
#3315

@nmoray
Copy link

nmoray commented Oct 4, 2024

@philo-micas vrrpsyncd needs to be spawned from the supervisord.conf of swss container. Thus, are you planning to add this in PR#18617 itself?

}
else
{
family = "ipv4";
Copy link

@nmoray nmoray Oct 7, 2024

Choose a reason for hiding this comment

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

This variable doesn't seem to be used while creating a key for VRRP_TABLE as per HLD.

Copy link
Author

Choose a reason for hiding this comment

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

Will remove the unused variable 'family'.

@nmoray
Copy link

nmoray commented Oct 7, 2024

@vvbrcm I quickly tested this implementation but it seems something is still missing as the VRRP_TABLE is not getting created in the APPL_DB even though vrrpsyncd received the system MAC.
Logs:

Oct  4 13:08:19.665187 sonic NOTICE swss#vrrpsyncd: :- VrrpSync: Got system Mac b4:db:91:de:13:02
Oct  4 13:08:19.665187 sonic NOTICE swss#vrrpsyncd: :- main: Listens to ifaddr and link messages...

if (afi == AF_INET6)
{
family = "ipv6";
len = "/128";

Choose a reason for hiding this comment

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

What is the purpose of this len variable ? Shouldn't it represent IP interface subnet ?

Copy link
Author

Choose a reason for hiding this comment

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

The primary interface on which VRRP is running will add the interface address with interface subnet. VRRP VIP on the macvlan interface will be an IP address with mask /32(IPv4) or /128 (IPv6).

if DEBUG
DBGFLAGS = -ggdb -DDEBUG
else
DBGFLAGS = -ggdb -DDEBUG

Choose a reason for hiding this comment

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

This probably should be "DBGFLAGS = -g"

Copy link
Author

Choose a reason for hiding this comment

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

Yes, changed it.

}


void VrrpSync::VrrpUpdateNetdevFlags(string &ifname, int afi, bool up)
Copy link

Choose a reason for hiding this comment

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

Do we need the third arg (up) ?

Copy link
Author

Choose a reason for hiding this comment

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

Will remove it.

Selectable *temps;
int ret;

using namespace std::chrono;
Copy link

Choose a reason for hiding this comment

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

why do we need this?

if ((nlmsg_type == RTM_DELLINK) || (nlmsg_type == RTM_DELADDR))
delete_key = true;

delete_key = delete_key;
Copy link

Choose a reason for hiding this comment

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

It needs to be removed

Copy link
Author

Choose a reason for hiding this comment

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

Will remove it

if (!ifname)
return false;

if (strncmp(ifname, "vrrp", 4))
Copy link

@nmoray nmoray Oct 9, 2024

Choose a reason for hiding this comment

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

It must be "Vrrp" as the interface name will be
"Vrrp-<af>-<vrrp_instance_number>".

Copy link
Author

Choose a reason for hiding this comment

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

From FRR the macvlan interface name was thought to be of the format vrrp-afi-instance ex vrrp4-2-1.
@philo-micas, can you please check.

Copy link

@micas-net micas-net Oct 10, 2024

Choose a reason for hiding this comment

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

The Macvlan device name starting with 'Vrrp4-' or 'Vrrp6-', ex Vrrp4-5 and Vrrp6-5.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed


VrrpDbUpdate(ifname, key, m_vrrpinfo[key].parent_ifname, afi, vip, m_vrrpinfo[key].vmac, false);

VrrpUpdateVipNbr(ifname, m_vrrpinfo[key].parent_ifname, afi, vip, true);
Copy link

@micas-net micas-net Oct 9, 2024

Choose a reason for hiding this comment

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

Check the indent here please, and there are also same issues below.

}


void VrrpSync::VrrpUpdateNetdevFlags(string &ifname, int afi, bool up)

Choose a reason for hiding this comment

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

Could you please explain why it is implemented in vrrpsyncd instead of macvlanmgrd?

Copy link
Author

Choose a reason for hiding this comment

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

This is for vrrp parent interface. Is this same logic present in macvlanmgrd? Is so, it could be removed.

struct vrrpmacip
{
unsigned int if_state;
std::string ifname;
Copy link

Choose a reason for hiding this comment

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

Please correct the alignments

Copy link
Author

Choose a reason for hiding this comment

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

ok

int ret;
string afi_str = (afi == AF_INET6)? "-6": "";

cmd = "ip " + afi_str + " neigh flush " + vip + " dev " + ifname;
Copy link

Choose a reason for hiding this comment

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

I guess it needs to be done only for op = "del".

Copy link
Author

Choose a reason for hiding this comment

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

Yes, had written it generically to del/replace. Currently only del is used.

}


void VrrpSync::VrrpUpdateNbr(string &ifname, int afi, string &vip, string &op)

Choose a reason for hiding this comment

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

It seems that the op parameter has not been used.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, had written it generically to del/replace. Currently only del is used.

@micas-net
Copy link

@philo-micas vrrpsyncd needs to be spawned from the supervisord.conf of swss container. Thus, are you planning to add this in PR#18617 itself?

has done. Thanks.

Copy link

@nser77 nser77 left a comment

Choose a reason for hiding this comment

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

Hi, I left a comment and I hope it is useful and not out of context!

Regards,

m_cfgDeviceMetadataTable(cfgDb, CFG_DEVICE_METADATA_TABLE_NAME)
{
m_nl_sock = nl_socket_alloc();
nl_connect(m_nl_sock, NETLINK_ROUTE);
Copy link

Choose a reason for hiding this comment

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

I'm not sure if this is required because vrrpsync needs to directly handle the netlink socket and if somenthing is missing from swss-common side my suggestion is to focus the effort in such library (netdispatcher and friends).

Anyway, if my previous comment is not correct, I think we want to:

  1. Manage the case where m_nl_sock is NULL
  2. Allocate a rx and tx buffer or specify 0,0 to enforce the default values.

Copy link

Choose a reason for hiding this comment

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

Other matches into sonic-swss repo:

cfgmgr/nbrmgr.cpp:54:    m_nl_sock = nl_socket_alloc();
cfgmgr/nbrmgr.cpp:59:    else if ((err = nl_connect(m_nl_sock, NETLINK_ROUTE)) < 0)
fpmsyncd/routesync.cpp:86:    m_nl_sock = nl_socket_alloc();
fpmsyncd/routesync.cpp:87:    nl_connect(m_nl_sock, NETLINK_ROUTE);

@vvbrcm
Copy link
Author

vvbrcm commented Oct 29, 2024

/azpw run Azure.sonic-buildimage

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-buildimage

Copy link

No pipelines are associated with this pull request.

@vvbrcm
Copy link
Author

vvbrcm commented Nov 6, 2024

/azpw run

@mssonicbld
Copy link
Collaborator

/AzurePipelines run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@wangxin
Copy link
Contributor

wangxin commented Nov 15, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vvbrcm
Copy link
Author

vvbrcm commented Nov 15, 2024

/azpw run Azure.sonic-swss

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-swss

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vvbrcm vvbrcm closed this Nov 18, 2024
@vvbrcm vvbrcm reopened this Nov 18, 2024
@vvbrcm
Copy link
Author

vvbrcm commented Nov 18, 2024

/azpw run Azure.sonic-swss

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-swss

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vvbrcm
Copy link
Author

vvbrcm commented Nov 18, 2024

/azpw run Azure.sonic-swss

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-swss

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vvbrcm
Copy link
Author

vvbrcm commented Nov 19, 2024

/azpw run Azure.sonic-swss

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-swss

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vvbrcm
Copy link
Author

vvbrcm commented Nov 26, 2024

/azpw run Azure.sonic-swss

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-swss

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vvbrcm
Copy link
Author

vvbrcm commented Dec 6, 2024

/azpw run Azure.sonic-swss

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-swss

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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.

8 participants