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

Implement receiving / filtering prefixes from outside #21

Merged
merged 3 commits into from
Jul 20, 2023

Conversation

fedepaol
Copy link
Member

Here we implement the incoming routes accepting (and filtering) and we add e2e tests for it.

This is based on #19 for the testing part.
Also, it will require metallb/metallb#2001 to validate injection on dual stack.

@fedepaol fedepaol force-pushed the receivetests branch 3 times, most recently from 0625cd1 to 81a57b8 Compare July 17, 2023 17:07
@fedepaol fedepaol mentioned this pull request Jul 18, 2023
}
res.HasV6 = true
}
return res
Copy link
Member

Choose a reason for hiding this comment

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

should we sort the prefixes here?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -20,8 +20,7 @@ route-map {{.neighbor.ID}}-out permit {{counter .neighbor.ID}}
deny all the others.*/ -}}
{{- define "neighborfilters" -}}

route-map {{.neighbor.ID}}-in deny 20
Copy link
Member

Choose a reason for hiding this comment

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

was there a reason we went with this approach instead of "deny any" now?

Comment on lines 108 to 111
if !found {
return false
}
return true
Copy link
Member

Choose a reason for hiding this comment

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

nit: return found


func ValidateNodesDoNotHaveRoutes(pods []*v1.Pod, neigh frrcontainer.FRR, prefixes ...string) {
ginkgo.By(fmt.Sprintf("Checking routes %v not injected from %s", prefixes, neigh.Name))
Consistently(func() error {
Copy link
Member

Choose a reason for hiding this comment

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

should you add an eventually first? (this might bite us when/if we update the resource as part of the test)

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, we always call this after a "doHaveRoutes" but there's no guarantee. I'll add

@fedepaol fedepaol force-pushed the receivetests branch 6 times, most recently from 375f619 to 73b9c2a Compare July 19, 2023 13:57
PrefixesV6: sortMap(advsV6),
}
return res, nil
}
Copy link
Member

Choose a reason for hiding this comment

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

nit: missing newline

if n.ToAdvertise.Allowed.Mode == v1beta1.AllowAll {
res.Outgoing, err = toAdvertiseToFRR(n.ToAdvertise, ipv4Prefixes, ipv6Prefixes)
if err != nil {
return nil, err
Copy link
Member

Choose a reason for hiding this comment

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

nit: format err with the neighbor's name/addr

Comment on lines 141 to 142
if !ok { // shouldn't happen as we check in previous loop, just in case
return nil, fmt.Errorf("unexpected err - no community prefix matching %s", p)
return fmt.Errorf("unexpected err - no community prefix matching %s", p)
Copy link
Member

Choose a reason for hiding this comment

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

I think this is misleading now since it seems advs and communitesforPrefix diverged? shouldn't communityPrefixesToMap be aware of the allowed advs when building the map? i.e

return nil, fmt.Errorf("prefix %s with community %s not in allowed list for neighbor %s", p, pfxs.Community, n.Address)

gone (maybe changing the error message here might be enough, in case we want to keep the other func as is)

Copy link
Member Author

Choose a reason for hiding this comment

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

done

}
return res, nil
}
func prefixesToMap(toAdvertise v1beta1.Advertise, ipv4Prefixes, ipv6Prefixes []string) (map[string]*frr.OutgoingFilter, map[string]*frr.OutgoingFilter) {
Copy link
Member

Choose a reason for hiding this comment

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

can you add some docs around the new functions (reduce the change of getting lost here)?

Comment on lines -102 to -103
// TODO: check that the prefix matches the passed IPv4/IPv6 prefixes
advs[p] = &frr.AdvertisementConfig{Prefix: p, IPFamily: family}
Copy link
Member

Choose a reason for hiding this comment

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

ah I missed this on my pr, my idea was verifying that the explicit prefix mentioned belongs to the router's "global" ones (ipv4Prefixes, ipv6Prefixes), did you remove it on purpose?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, I missed it. I will leave a TODO because doing it while we process seems a bit ugly, so it might worth having an ad hoc validate function. Let's wait after we do the merging thing and the dust settles

@@ -54,10 +53,32 @@ route-map {{$.neighbor.ID}}-out permit {{counter $.neighbor.ID}}

{{/* If the neighbor does not have an advertisement, we need to add a prefix to deny
for when we have a prefix but a given peer is not selected for any prefixes */}}
{{- if not .neighbor.HasV4Advertisements}}
{{- if not .neighbor.Outgoing.PrefixesV4 }}
Copy link
Member

Choose a reason for hiding this comment

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

neat, this returns according to the slice being empty or not?

Copy link
Member Author

Choose a reason for hiding this comment

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

yep


// shouldFailConsistentyl checks for the failure to happen
// and then checks it consistently.
func shouldFailConsistently(toCheck func() error) {
Copy link
Member

Choose a reason for hiding this comment

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

neat

@fedepaol fedepaol force-pushed the receivetests branch 2 times, most recently from a4beb97 to a545a36 Compare July 19, 2023 15:00
Here we implement the translation and the rendering of the inbound path.

Signed-off-by: Federico Paolinelli <[email protected]>
To consume the version where we can inject v4 and v6 prefixes from the
external containers.

Signed-off-by: Federico Paolinelli <[email protected]>
We add tests to cover incoming routes acceptance / filtering.

Signed-off-by: Federico Paolinelli <[email protected]>
Copy link
Member

@oribon oribon left a comment

Choose a reason for hiding this comment

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

lgtm

@fedepaol fedepaol added this pull request to the merge queue Jul 20, 2023
Merged via the queue into metallb:main with commit bb0b6c3 Jul 20, 2023
8 checks passed
karampok pushed a commit to karampok/frr-k8s that referenced this pull request Jun 18, 2024
…shift-4.14-ose-frr

Updating ose-frr images to be consistent with ART
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants