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

bridge: add isDefaultGateway field #50

Merged
merged 2 commits into from
May 20, 2016
Merged

bridge: add isDefaultGateway field #50

merged 2 commits into from
May 20, 2016

Conversation

steveej
Copy link
Member

@steveej steveej commented Sep 4, 2015

When isDefaultGateway is true it automatically sets isGateway to true.
The default route will be added via the (bridge's) gateway IP.
If a default gateway has been configured via IPAM in the same configuration file, the plugin will error out.

Fixes #27.
Fixes #184.

for i, route := range result.IP4.Routes {
if defaultNet.String() == route.Dst.String() {
if route.GW != nil && !route.GW.Equal(result.IP4.Gateway) {
return errors.New(fmt.Sprintf(
Copy link
Contributor

Choose a reason for hiding this comment

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

fmt.Errorf

@eyakubovich
Copy link
Contributor

I think it's a reasonable solution but I need to sleep on this. There are some implications for integrating it with rkt and it setting up a default route.

@steveej
Copy link
Member Author

steveej commented Sep 5, 2015

I'd like to point out again that the default behaviour hasn't been changed, it does require a configuration change to make this happen. Only if isDefaultGateway is provided instead of or in addition to isGateway the default gateway will be set.

@eyakubovich
Copy link
Contributor

@steveej I guess you're right. However there's also fact that this is almost sugar on top of IPAM routes. You could do the same with "routes": { "dst": "0.0.0.0/0", "gw": "$GW } in the IPAM section. At the same this maybe inconvenient but in that case it should be handled in the IPAM section/plugins and not the bridge.

@steveej
Copy link
Member Author

steveej commented Sep 9, 2015

I see your point. I followed the already existing isGateway, which could also replaced via IPAM by adding a route that has the IPAM subnet as the destination.
One thing that has bothered me so far is that the gateway is automatically assumed to be the first subnet address using the isGateway attribute. In case the gateway is different, people would have to configure the routes manually via IPAM, and the isGateway would not fit in anymore.

So, I would like a solution of that moves the gateway attributes to IPAM and allows for better flexibility.
Opinions?

@eyakubovich
Copy link
Contributor

The first address is only assumed if IPAM did not provide a gateway address (https://github.com/appc/cni/blob/master/plugins/main/bridge/bridge.go#L195). The "gateway" field in the IPAM result JSON is optional, so there is a problem that if IPAM returns some routes but not the gateway, it can get messed up. Maybe we can issue a warning or something in this case.

@steveej
Copy link
Member Author

steveej commented Sep 24, 2015

@eyakubovich: my understanding on this is that we'll move the gateway attributes to IPAM and leave the behavior as is, but add a convenience option to set the default GW as already implemented in this PR.

Please confirm and I'll update the implementation accordingly.

@@ -196,6 +201,7 @@ func cmdAdd(args *skel.CmdArgs) error {
return err
}

// TODO: make this optional when IPv6 is supported
Copy link
Member

@jellonek jellonek May 20, 2016

Choose a reason for hiding this comment

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

After inclusion of IPv6 next line should be extended with && result.IP6 == nil so this comment is hmmm... not precise.

edit: and then error in next line should be similarly extended.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a hint that there's going to be multiple options, logically IPv4 || IPv6

@jellonek
Copy link
Member

LGTM

@squaremo
Copy link
Member

LGTM. As discussed on IRC, it's worth waiting for #211 and rebasing, for the tests, before merging.

steveej added 2 commits May 21, 2016 00:38
When isDefaultGateway is true it automatically sets isGateway to true.
The default route will be added via the (bridge's) gateway IP.
If a default gateway has been configured via IPAM in the same
configuration file, the plugin will error out.
@steveej steveej merged commit 20fa3d3 into containernetworking:master May 20, 2016
@steveej steveej deleted the gwfix branch May 20, 2016 23:35
architkulkarni pushed a commit to architkulkarni/cni that referenced this pull request Jul 12, 2024
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.

4 participants