-
Notifications
You must be signed in to change notification settings - Fork 596
[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
Conversation
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]>
Retest this please |
cfgmgr/vrfmgr.cpp
Outdated
#include "shellcmd.h" | ||
|
||
#define VRF_TABLE_START 100 | ||
#define VRF_TABLE_END 164 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; | ||
} | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
cfgmgr/vrfmgr.cpp
Outdated
return false; | ||
} | ||
|
||
returnTable(m_vrfTableMap[vrfName]); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this 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.
cfgmgr/vrfmgr.cpp
Outdated
} | ||
|
||
cmd << IP_CMD << " link add " << vrfName << " type vrf table " << table; | ||
int ret = swss::exec(cmd.str(), res); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
@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? |
@nikos-github Here's the link to design draft |
Signed-off-by: Marian Pritsak <[email protected]>
Signed-off-by: Marian Pritsak <[email protected]>
Signed-off-by: Marian Pritsak <[email protected]>
@prsunny and @jipanyang , can you check the pr, any more comments? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two minor comments.
cfgmgr/vrfmgr.cpp
Outdated
int ret = swss::exec(cmd.str(), res); | ||
if (ret) | ||
{ | ||
SWSS_LOG_ERROR("Command %s failed, rc: %i", res.c_str(), ret); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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]>
retest this please |
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. |
…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
…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
vrfmgrd is responsible for VRF configuration in Linux
It creates VRF-Lite device for every VRF entry in Config DB