summaryrefslogtreecommitdiff
path: root/libpod/network/netconflist.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2021-02-02 13:24:14 -0600
committerbaude <bbaude@redhat.com>2021-02-02 13:24:14 -0600
commitbd0e22ed14ca09a7b656f4603c13aac3a4066968 (patch)
treec2ddd23aa6fcd8900e515b37341332e8e5393f40 /libpod/network/netconflist.go
parentd66a18cb11688060a3ef737dd05758398279f053 (diff)
downloadpodman-bd0e22ed14ca09a7b656f4603c13aac3a4066968.tar.gz
podman-bd0e22ed14ca09a7b656f4603c13aac3a4066968.tar.bz2
podman-bd0e22ed14ca09a7b656f4603c13aac3a4066968.zip
Honor network options for macvlan networks
when creating a macvlan network, we should honor gateway, subnet, and mtu as provided by the user. Fixes: #9167 Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'libpod/network/netconflist.go')
-rw-r--r--libpod/network/netconflist.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/libpod/network/netconflist.go b/libpod/network/netconflist.go
index ca6a4a70b..9be98e78f 100644
--- a/libpod/network/netconflist.go
+++ b/libpod/network/netconflist.go
@@ -172,19 +172,31 @@ func HasDNSNamePlugin(paths []string) bool {
}
// NewMacVLANPlugin creates a macvlanconfig with a given device name
-func NewMacVLANPlugin(device string) MacVLANConfig {
+func NewMacVLANPlugin(device string, gateway net.IP, ipRange *net.IPNet, subnet *net.IPNet, mtu int) (MacVLANConfig, error) {
i := IPAMDHCP{DHCP: "dhcp"}
+ if gateway != nil || ipRange != nil || subnet != nil {
+ ipam, err := NewIPAMLocalHostRange(subnet, ipRange, gateway)
+ if err != nil {
+ return MacVLANConfig{}, err
+ }
+ ranges := make([][]IPAMLocalHostRangeConf, 0)
+ ranges = append(ranges, ipam)
+ i.Ranges = ranges
+ }
m := MacVLANConfig{
PluginType: "macvlan",
IPAM: i,
}
+ if mtu > 0 {
+ m.MTU = mtu
+ }
// CNI is supposed to use the default route if a
// parent device is not provided
if len(device) > 0 {
m.Master = device
}
- return m
+ return m, nil
}
// IfPassesFilter filters NetworkListReport and returns true if the filter match the given config