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

[acl] Add default deny rule for l3 table #734

Merged
merged 2 commits into from
Jun 23, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,12 @@
"priority":9996
},
"OP":"SET"
},
{
"ACL_RULE_TABLE:dataacl:default_rule":{
"PACKET_ACTION":"DROP",
Copy link
Contributor

Choose a reason for hiding this comment

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

Add one more attribute: "ETHER_TYPE":"0x0800",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shouldn't none-ip packet be dropped as well?

Copy link
Collaborator

Choose a reason for hiding this comment

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

all packet includes lldp, arp, lacp, they should not be dropped. It is better to limit to only ip.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Didn't quite get it. Shouldn't we have an explicit ACL rule to allow lldp/arp packets?

Copy link
Contributor

Choose a reason for hiding this comment

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

The implicit rule is to drop all IP and IPv6 packets.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Modified so that it drops IP packets only.

"priority":1
Copy link
Contributor

Choose a reason for hiding this comment

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

All capitalized to make it look unified.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved.

},
"OP":"SET"
}
]
12 changes: 11 additions & 1 deletion src/sonic-config-engine/translate_acl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ def dump_json(filename, data):
with open(filename, 'w') as outfile:
json.dump(data, outfile, indent=4, sort_keys=True, separators=(',', ':'))

def default_deny_rule(table_name):
rule_props = {}
rule_data = {}
rule_data["ACL_RULE_TABLE:"+table_name+":default_rule"] = rule_props
rule_data["OP"] = "SET"
rule_props["priority"] = 1
rule_props["PACKET_ACTION"] = "DROP"
return rule_data

def generate_rule_json(table_name, rule, max_priority, mirror):
rule_idx = rule.config.sequence_id
rule_props = {}
Expand Down Expand Up @@ -120,7 +129,8 @@ def generate_table_json(aclset, aclname, ports, mirror, max_priority, output_pat
rule_props = generate_rule_json(table_name, aclentry, max_priority, mirror)
if rule_props:
rule_data.append(rule_props)

if not mirror:
rule_data.append(default_deny_rule(table_name))
dump_json(os.path.join(output_path, "rules_for_"+table_name+".json"), rule_data)

def translate_acl_fixed_port(filename, output_path, port, max_priority):
Expand Down