| From a2c65ec075a9376e3b8e9fb72a96db36a613a1d0 Mon Sep 17 00:00:00 2001 |
| From: Lorenz Brun <lorenz@brun.one> |
| Date: Thu, 2 Jan 2025 00:36:05 +0100 |
| Subject: [PATCH] Add linkGroup setting |
| |
| --- |
| plugins/main/ptp/ptp.go | 11 +++++++++-- |
| 1 file changed, 9 insertions(+), 2 deletions(-) |
| |
| diff --git a/plugins/main/ptp/ptp.go b/plugins/main/ptp/ptp.go |
| index 9c88d901..e0b283c5 100644 |
| --- a/plugins/main/ptp/ptp.go |
| +++ b/plugins/main/ptp/ptp.go |
| @@ -47,6 +47,7 @@ type NetConf struct { |
| IPMasq bool `json:"ipMasq"` |
| IPMasqBackend *string `json:"ipMasqBackend,omitempty"` |
| MTU int `json:"mtu"` |
| + LinkGroup int `json:"linkGroup,omitempty"` |
| } |
| |
| func setupContainerVeth(netns ns.NetNS, ifName string, mtu int, pr *current.Result) (*current.Interface, *current.Interface, error) { |
| @@ -146,7 +147,7 @@ func setupContainerVeth(netns ns.NetNS, ifName string, mtu int, pr *current.Resu |
| return hostInterface, containerInterface, nil |
| } |
| |
| -func setupHostVeth(vethName string, result *current.Result) error { |
| +func setupHostVeth(vethName string, group int, result *current.Result) error { |
| // hostVeth moved namespaces and may have a new ifindex |
| veth, err := netlinksafe.LinkByName(vethName) |
| if err != nil { |
| @@ -178,6 +179,12 @@ func setupHostVeth(vethName string, result *current.Result) error { |
| } |
| } |
| |
| + if group != 0 { |
| + if err := netlink.LinkSetGroup(veth, group); err != nil { |
| + return fmt.Errorf("failed to set link group for if %q: %v", vethName, err) |
| + } |
| + } |
| + |
| return nil |
| } |
| |
| @@ -225,7 +232,7 @@ func cmdAdd(args *skel.CmdArgs) error { |
| return err |
| } |
| |
| - if err = setupHostVeth(hostInterface.Name, result); err != nil { |
| + if err = setupHostVeth(hostInterface.Name, conf.LinkGroup, result); err != nil { |
| return err |
| } |
| |
| -- |
| 2.47.1 |
| |