Skip to content

Datapath portion of egress label-based policy enforcement#2954

Merged
tgraf merged 5 commits intocilium:masterfrom
joestringer:submit/bpf-egress-labels
Mar 9, 2018
Merged

Datapath portion of egress label-based policy enforcement#2954
tgraf merged 5 commits intocilium:masterfrom
joestringer:submit/bpf-egress-labels

Conversation

@joestringer
Copy link
Copy Markdown
Member

@joestringer joestringer commented Feb 27, 2018

Fixes: #2553

This PR implements egress label-based policies (labels + labels-dependent l4) in the datapath. It's prepared in a way that allows it to be merged independent of the rest of the label-based egress policy work. The last two commits should be fixed up when label-based egress support lands in the tree.

The core change is that one of the pad bits in struct policy_key now represents whether the entry represents ingress (0) or egress (1). Because the entire field is currently padding, and is set to 0, this allows the change to be backward-compatible - earlier versions will only set the bit to 0, indicating ingress, and upon upgrade the entries will be treated exactly the same.

In addition to this change, there is a new map, cilium_remote_lxc, which maps destination IP addresses to remote identites. This will be populated by subsequent changes in the userspace.

Note that when the egress bit is set in the policy_key for the POLICY_MAP, the sec_label represents the destination identity rather than the source identity.

@joestringer joestringer added wip area/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. labels Feb 27, 2018
@joestringer joestringer requested a review from a team February 27, 2018 18:02
@joestringer joestringer force-pushed the submit/bpf-egress-labels branch 2 times, most recently from 4ef008d to 8e73983 Compare March 2, 2018 01:45
@joestringer joestringer requested review from a team as code owners March 2, 2018 01:45
@joestringer joestringer changed the title [WIP] Datapath portion of egress label-based policy enforcement Datapath portion of egress label-based policy enforcement Mar 2, 2018
@aanm
Copy link
Copy Markdown
Member

aanm commented Mar 2, 2018

@joestringer is there a duplicate commit from #2992? It seems some of the code is similar

@joestringer
Copy link
Copy Markdown
Member Author

@aanm yes, one commit is the same. This work requires the l4-only bug to be fixed or current l4 egress policy breaks.

Introduce a new map, `cilium_remote_lxc`, which maps from an IP (v4/v6)
address to an identity for a remote node. Then, extend the
policy_key to include directionality. With these two bits in place, we
can reuse the existing POLICY_MAP to enforce egress label-based
policies, including egress label-based policy and L3-dependent L4 policy.

Signed-off-by: Joe Stringer <joe@covalent.io>
This test was previously erroneously checking whether app3 could
communicate with http3, which should not be allowed based on the policy.
Update this to disallow.

Signed-off-by: Joe Stringer <joe@covalent.io>
Signed-off-by: Joe Stringer <joe@covalent.io>
Existing test cases and so on are all geared around there only being L4
policy enforcement on egress, and the label-based egress work is not
quite ready yet. Since the L4 policies are not being pushed into the
`POLICY_MAP` yet, always apply L4 policy from the egress path.

This should be removed when label-based egress policy is properly
plumbed down through userspace.

Signed-off-by: Joe Stringer <joe@covalent.io>
Signed-off-by: Joe Stringer <joe@covalent.io>
@joestringer joestringer force-pushed the submit/bpf-egress-labels branch from 8e73983 to 8b3f4e2 Compare March 8, 2018 21:34
@joestringer
Copy link
Copy Markdown
Member Author

test-me-please

Copy link
Copy Markdown
Contributor

@tgraf tgraf left a comment

Choose a reason for hiding this comment

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

Awesome work

Comment thread bpf/lib/maps.h
.size_key = sizeof(struct endpoint_key),
.size_value = sizeof(struct remote_endpoint_info),
.pinning = PIN_GLOBAL_NS,
.max_elem = ENDPOINTS_MAP_SIZE, /* XXX: Consider resizing? */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it's fine but bumping it to 250K doesn't hurt either. The map is still quite small. Please create a GH to track adjusting this on demand. Given regenerations, we could easily resize the map.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Created #3075. Main reason I put this comment was that it's now referring to remote containers so binding it to the same limit as the lxcmap might not be appropriate.

@tgraf tgraf merged commit 6dbbdf6 into cilium:master Mar 9, 2018
@joestringer joestringer deleted the submit/bpf-egress-labels branch March 9, 2018 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Label-based egress support: datapath implementation

3 participants