Skip to content
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

Changes to add template support for copp.json. #5053

Merged
merged 3 commits into from
Jul 31, 2020

Conversation

abdosi
Copy link
Contributor

@abdosi abdosi commented Jul 28, 2020

Changes:=

Changes to add template support for copp.json.
This is needed so that we can install different type of
Traps based on Device Role (Tor/Leaf/Mgmt/etc...).

Initial use case is to install DHCP/DHCPv6 trap only
for Tor router.

This PR is dependent on sonic-net/sonic-swss#1366.

Currently this change is not compatible with warm-reboot from previous image version.
Need to handle warm-reboot case with this change. This will done in separate PR

Testing:
Manually Verified based on Device Role json file getting generated. Also verfied if Device_Metadata or it's sub-param are not present then no exception is generated and correct template is formed.
Dump APP DB to have correct traps based on generated json file.

This is needed so that we can install differnt type of
Traps based on Device Role (Tor/Leaf/Mgmt/etc...).

Initial use case is to install DHCP/DHCPv6 tarp only
for tor router.

Signed-off-by: Abhishek Dosi <[email protected]>
},
"OP": "SET"
},
{% if DEVICE_METADATA['localhost']['type'] == "ToRRouter" %}
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be better to check for the existence of type. If not present, the template might crash - Ref

Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you please ensure if the type is not defined, the trap is installed? Type is not a mandatory parameter and this might cause backward compatibility issues in cases where type field is not defined

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@prsunny @dgsudharsan Updated to add default else condition for backward compatibility
if DEVICE_METADATA and it sub-parameters are not define.

@prsunny
Copy link
Contributor

prsunny commented Jul 28, 2020

@dgsudharsan, please review

Signed-off-by: Abhishek Dosi <[email protected]>
},
"OP": "SET"
},
{% if DEVICE_METADATA is defined and DEVICE_METADATA['localhost'] is defined and DEVICE_METADATA['localhost']['type'] is defined and DEVICE_METADATA['localhost']['type'] == "ToRRouter" %}
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO, device_metadata and device_metadata['localhost'] check is kind of redundant. Our initialization is highly dependent on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@prsunny yes that is correct and few places we are not even checking type also.
However just made it to make sure we can avoid any exception at least for this template

prsunny
prsunny previously approved these changes Jul 30, 2020
{
"COPP_TABLE:trap.group.lldp.udld": {
"trap_ids": "lldp,udld",
"trap_action":"trap",
Copy link
Collaborator

Choose a reason for hiding this comment

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

If type (if defined) is not ToRRouter have the trap-ids only for lldp & udlp and else case have ""trap_ids": "lldp,dhcp,dhcpv6,udld","

Copy link
Contributor Author

@abdosi abdosi Jul 30, 2020

Choose a reason for hiding this comment

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

@venkatmahalingam yes this is the behavior

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@venkatmahalingam got your point. Updated accordingly.

@abdosi
Copy link
Contributor Author

abdosi commented Jul 30, 2020

retest vsimage please

@abdosi
Copy link
Contributor Author

abdosi commented Jul 31, 2020

retest vsimage please

@abdosi abdosi merged commit ec435b9 into sonic-net:master Jul 31, 2020
@abdosi abdosi deleted the copp_changes branch July 31, 2020 21:14
lguohan pushed a commit to sonic-net/sonic-swss that referenced this pull request Aug 1, 2020
Removed 00-copp.config.json from swss debian package

Changes to make copp.json as j2 template based based on device role.
copp.json.j2 is moved into docker-orchagent. docker-init.sh of orchagent will create json file form j2 template.

This PR is dependent on : sonic-net/sonic-buildimage#5053

Signed-off-by: Abhishek Dosi <[email protected]>
abdosi added a commit to sonic-net/sonic-swss that referenced this pull request Aug 1, 2020
Removed 00-copp.config.json from swss debian package

Changes to make copp.json as j2 template based based on device role.
copp.json.j2 is moved into docker-orchagent. docker-init.sh of orchagent will create json file form j2 template.

This PR is dependent on : sonic-net/sonic-buildimage#5053

Signed-off-by: Abhishek Dosi <[email protected]>
abdosi added a commit that referenced this pull request Aug 1, 2020
* Changes to add template support for copp.json.
This is needed so that we can install differnt type of
Traps based on Device Role (Tor/Leaf/Mgmt/etc...).

Initial use case is to install DHCP/DHCPv6 tarp only
for tor router.

Signed-off-by: Abhishek Dosi <[email protected]>

* Fixed based on review comments.

Signed-off-by: Abhishek Dosi <[email protected]>

* Fixed based on review comment.
@chaoskao
Copy link

hi @abdosi
What's the use case of CoPP should configure trap DHCP packet

santhosh-kt pushed a commit to santhosh-kt/sonic-buildimage that referenced this pull request Feb 25, 2021
* Changes to add template support for copp.json.
This is needed so that we can install differnt type of
Traps based on Device Role (Tor/Leaf/Mgmt/etc...).

Initial use case is to install DHCP/DHCPv6 tarp only
for tor router.

Signed-off-by: Abhishek Dosi <[email protected]>

* Fixed based on review comments.

Signed-off-by: Abhishek Dosi <[email protected]>

* Fixed based on review comment.
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