Skip to content

[cfgmgr]: Add vrfmgrd #621

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

Merged
merged 5 commits into from
Sep 19, 2018
Merged

[cfgmgr]: Add vrfmgrd #621

merged 5 commits into from
Sep 19, 2018

Conversation

marian-pritsak
Copy link
Collaborator

vrfmgrd is responsible for VRF configuration in Linux
It creates VRF-Lite device for every VRF entry in Config DB

vrfmgrd is responsible for VRF configuration in Linux
It creates VRF-Lite device for every VRF entry in Config DB

Signed-off-by: Marian Pritsak <[email protected]>
@marian-pritsak
Copy link
Collaborator Author

Retest this please

#include "shellcmd.h"

#define VRF_TABLE_START 100
#define VRF_TABLE_END 164
Copy link
Contributor

Choose a reason for hiding this comment

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

what are these two numbers? does this limit to 64 vrfs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Linux routing table numbers. Do we need more?

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe can change to 1k initially.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done
Used 1001..2000 since there are a few reserved values in the first 256 tables.

{
return false;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

can we check the vrfTableMap, if it is there means the vrf has been created, then we can just return true. Instead of creating a new one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

cfgmgr/vrfmgr.h Outdated
private:
bool delLink(const string& vrfName);
bool setLink(const string& vrfName);
void returnTable(uint32_t table);
Copy link
Contributor

Choose a reason for hiding this comment

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

can you rename to recycleTableId?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

return false;
}

returnTable(m_vrfTableMap[vrfName]);
Copy link
Contributor

Choose a reason for hiding this comment

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

i feel we should move this after line 69 since we should only recycle the id when it is free.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@lguohan lguohan left a comment

Choose a reason for hiding this comment

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

i have some minor comments, but overall it looks good to me.

}

cmd << IP_CMD << " link add " << vrfName << " type vrf table " << table;
int ret = swss::exec(cmd.str(), res);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm think about warm restart support for vrfmgrd. If the vrf table has been configured on linux, adding it again would return error. Could it be changed to warm restart agnostic, like checking the existence of vrf table before adding it?

root@sonic:/home/admin# ip link add vrftest1 type vrf table 120
root@sonic:/home/admin# ip link add vrftest1 type vrf table 120
RTNETLINK answers: File exists
root@sonic:/home/admin# echo $?
2

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure if I follow. Warm restart reboots kernel. VRF netdevs will be gone after reboot.

Copy link
Contributor

Choose a reason for hiding this comment

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

There is SWSS docker warm restart. In that case, Linux env is kept.

Copy link
Contributor

Choose a reason for hiding this comment

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

there is no problem to get all vrfs using following command.

admin@str-s6000-on-4:~$ ip -br link show type vrf
vrftest1         DOWN           c2:31:e9:01:c8:f4 <NOARP,MASTER> 

the problem is to get the route table id.

Copy link
Contributor

Choose a reason for hiding this comment

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

do we need the table id? I can see the ip route add can use vrfname directly. @marian-pritsak , do you know who is going to use that table id?

Copy link
Contributor

Choose a reason for hiding this comment

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

from what I can see, it seems we can get form netlink messages.

https://github.com/FRRouting/frr/blob/master/zebra/if_netlink.c#L305

I do not know if there is a command line that can get this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ip -d shows table ID

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks

@nikos-github
Copy link
Contributor

nikos-github commented Sep 17, 2018

@marian-pritsak @lguohan Is there a plan on how sonic will handle IP addresses for interfaces enslaved to vrfs? Will they be handled the same way kernel does and also be checking the sysctl variables?

@marian-pritsak
Copy link
Collaborator Author

@nikos-github Here's the link to design draft

@lguohan
Copy link
Contributor

lguohan commented Sep 18, 2018

@prsunny and @jipanyang , can you check the pr, any more comments?

Copy link
Contributor

@jipanyang jipanyang left a comment

Choose a reason for hiding this comment

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

Two minor comments.

int ret = swss::exec(cmd.str(), res);
if (ret)
{
SWSS_LOG_ERROR("Command %s failed, rc: %i", res.c_str(), ret);
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably EXEC_WITH_ERROR_THROW(cmd, res) is better here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@@ -30,3 +30,7 @@ buffermgrd_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_SAI)
buffermgrd_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_SAI)
buffermgrd_LDADD = -lswsscommon

vrfmgrd_SOURCES = vrfmgrd.cpp vrfmgr.cpp $(top_srcdir)/orchagent/orch.cpp $(top_srcdir)/orchagent/request_parser.cpp shellcmd.h
Copy link
Contributor

Choose a reason for hiding this comment

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

Since every daemon here is taking "$(top_srcdir)/orchagent/orch.cpp $(top_srcdir)/orchagent/request_parser.cpp shellcmd.h", would it make sense to have a macro for them like

CFGMGR_COMMON_SOURCES = $(top_srcdir)/orchagent/orch.cpp $(top_srcdir)/orchagent/request_parser.cpp shellcmd.h

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe, but I don't like mixing that kind of refactoring with new features in a single PR

Signed-off-by: Marian Pritsak <[email protected]>
@lguohan
Copy link
Contributor

lguohan commented Sep 19, 2018

retest this please

@prsunny
Copy link
Collaborator

prsunny commented Sep 19, 2018

Looks good. Based on the Vxlan discussion today, we've to update the STATE_DB/APP_DB after the VRF is created in kernel. But this can be done in the next commit.

@lguohan lguohan merged commit 13df5a9 into sonic-net:master Sep 19, 2018
EdenGri pushed a commit to EdenGri/sonic-swss that referenced this pull request Feb 28, 2022
…nic-net#621)

[fast-reboot] Check if ASIC config has changed before fast reboot
* Adds script to compare checksums for config files between SONiC images
* Adds pre-check to fast reboot script to confirm config files match before performing fast reboot

Signed-off-by: Danny Allen <[email protected]>

* Fix formatting

* Incorporate feedback

* Add check for reboot type and override ability

* Clean up error checking
oleksandrivantsiv pushed a commit to oleksandrivantsiv/sonic-swss that referenced this pull request Mar 1, 2023
…cements (sonic-net#621)

* Fix debian/rules makefile: use shell commands instead of dollar
replacements because:
1. `ifeq` evaluates conditionals when it reads a Makefile.
2. no need to replace with shell command outputs
ref: https://stackoverflow.com/a/11994561/2514803
* Fix one more `echo`
* Revert back one shell replacement
* Fix some bash command and Makefile escaping issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants