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

Support 'gateway' option when creating network #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion pkg/plugin/dhcp_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (m *dhcpManager) renew(v6 bool, info udhcpc.Info) error {
Warn("udhcpc renew with changed IP")
}

if !v6 && info.Gateway != "" {
if !v6 && info.Gateway != "" && m.opts.Gateway == "" {
newGateway := net.ParseIP(info.Gateway)

routes, err := m.netHandle.RouteListFiltered(unix.AF_INET, &netlink.Route{
Expand Down
6 changes: 5 additions & 1 deletion pkg/plugin/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,11 @@ func (p *Plugin) CreateEndpoint(ctx context.Context, r CreateEndpointRequest) (C
} else {
res.Interface.Address = info.IP
hint.IPv4 = ip
hint.Gateway = info.Gateway
if opts.Gateway != "" {
hint.Gateway = opts.Gateway
} else {
hint.Gateway = info.Gateway
}
}
p.joinHints[r.EndpointID] = hint

Expand Down
1 change: 1 addition & 0 deletions pkg/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func IsDHCPPlugin(driver string) bool {
// DHCPNetworkOptions contains options for the DHCP network driver
type DHCPNetworkOptions struct {
Bridge string
Gateway string
IPv6 bool
LeaseTimeout time.Duration `mapstructure:"lease_timeout"`
IgnoreConflicts bool `mapstructure:"ignore_conflicts"`
Expand Down