blob: ec83ddd7a8baf33892c46c0e1f7b8bce1a288c50 [file] [log] [blame]
Lorenz Brun0dca6c92025-01-28 15:04:13 +01001From a2c65ec075a9376e3b8e9fb72a96db36a613a1d0 Mon Sep 17 00:00:00 2001
2From: Lorenz Brun <lorenz@brun.one>
3Date: Thu, 2 Jan 2025 00:36:05 +0100
4Subject: [PATCH] Add linkGroup setting
5
6---
7 plugins/main/ptp/ptp.go | 11 +++++++++--
8 1 file changed, 9 insertions(+), 2 deletions(-)
9
10diff --git a/plugins/main/ptp/ptp.go b/plugins/main/ptp/ptp.go
Tim Windelschmidtcfbc9032025-07-15 14:18:45 +020011index 9c88d901..e0b283c5 100644
Lorenz Brun0dca6c92025-01-28 15:04:13 +010012--- a/plugins/main/ptp/ptp.go
13+++ b/plugins/main/ptp/ptp.go
Tim Windelschmidtcfbc9032025-07-15 14:18:45 +020014@@ -47,6 +47,7 @@ type NetConf struct {
Lorenz Brun0dca6c92025-01-28 15:04:13 +010015 IPMasq bool `json:"ipMasq"`
16 IPMasqBackend *string `json:"ipMasqBackend,omitempty"`
17 MTU int `json:"mtu"`
18+ LinkGroup int `json:"linkGroup,omitempty"`
19 }
20
21 func setupContainerVeth(netns ns.NetNS, ifName string, mtu int, pr *current.Result) (*current.Interface, *current.Interface, error) {
Tim Windelschmidtcfbc9032025-07-15 14:18:45 +020022@@ -146,7 +147,7 @@ func setupContainerVeth(netns ns.NetNS, ifName string, mtu int, pr *current.Resu
Lorenz Brun0dca6c92025-01-28 15:04:13 +010023 return hostInterface, containerInterface, nil
24 }
25
26-func setupHostVeth(vethName string, result *current.Result) error {
27+func setupHostVeth(vethName string, group int, result *current.Result) error {
28 // hostVeth moved namespaces and may have a new ifindex
Tim Windelschmidtcfbc9032025-07-15 14:18:45 +020029 veth, err := netlinksafe.LinkByName(vethName)
Lorenz Brun0dca6c92025-01-28 15:04:13 +010030 if err != nil {
Tim Windelschmidtcfbc9032025-07-15 14:18:45 +020031@@ -178,6 +179,12 @@ func setupHostVeth(vethName string, result *current.Result) error {
Lorenz Brun0dca6c92025-01-28 15:04:13 +010032 }
33 }
34
35+ if group != 0 {
36+ if err := netlink.LinkSetGroup(veth, group); err != nil {
37+ return fmt.Errorf("failed to set link group for if %q: %v", vethName, err)
38+ }
39+ }
40+
41 return nil
42 }
43
Tim Windelschmidtcfbc9032025-07-15 14:18:45 +020044@@ -225,7 +232,7 @@ func cmdAdd(args *skel.CmdArgs) error {
Lorenz Brun0dca6c92025-01-28 15:04:13 +010045 return err
46 }
47
48- if err = setupHostVeth(hostInterface.Name, result); err != nil {
49+ if err = setupHostVeth(hostInterface.Name, conf.LinkGroup, result); err != nil {
50 return err
51 }
52
53--
542.47.1
55