From 964e3cb8002bfb22cc01ec95f4f19a1a6fd0fc60 Mon Sep 17 00:00:00 2001 From: Nolan Davidson Date: Wed, 2 Oct 2024 21:36:24 -0400 Subject: [PATCH 1/5] adding PID to route update message --- route.go | 7 ++++--- route_linux.go | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/route.go b/route.go index 1b4555d5..2ce95709 100644 --- a/route.go +++ b/route.go @@ -45,7 +45,7 @@ type Encap interface { Equal(Encap) bool } -//Protocol describe what was the originator of the route +// Protocol describe what was the originator of the route type RouteProtocol int // Route represents a netlink route. @@ -161,8 +161,9 @@ type flagString struct { // - unix.NLM_F_CREATE - Create config object if it doesn't already exist // - unix.NLM_F_APPEND - Add to the end of the object list type RouteUpdate struct { - Type uint16 - NlFlags uint16 + Type uint16 + NlFlags uint16 + SourcePID uint32 Route } diff --git a/route_linux.go b/route_linux.go index 28a132a2..e71a4b12 100644 --- a/route_linux.go +++ b/route_linux.go @@ -1787,9 +1787,10 @@ func routeSubscribeAt(newNs, curNs netns.NsHandle, ch chan<- RouteUpdate, done < continue } ch <- RouteUpdate{ - Type: m.Header.Type, - NlFlags: m.Header.Flags & (unix.NLM_F_REPLACE | unix.NLM_F_EXCL | unix.NLM_F_CREATE | unix.NLM_F_APPEND), - Route: route, + Type: m.Header.Type, + NlFlags: m.Header.Flags & (unix.NLM_F_REPLACE | unix.NLM_F_EXCL | unix.NLM_F_CREATE | unix.NLM_F_APPEND), + Route: route, + SourcePID: from.Pid, } } } From 0ab2eacf773e59894ced62bcf47541e48fa8e349 Mon Sep 17 00:00:00 2001 From: Nolan Davidson Date: Wed, 2 Oct 2024 21:41:21 -0400 Subject: [PATCH 2/5] rename package --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 802fce14..003b9112 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/vishvananda/netlink +module github.com/nsdavidson/netlink go 1.12 From 4d58f903ad1a1dd2fedab240f15325da0b03774f Mon Sep 17 00:00:00 2001 From: Nolan Davidson Date: Wed, 2 Oct 2024 21:46:20 -0400 Subject: [PATCH 3/5] rename everywhere --- addr_linux.go | 2 +- bridge_linux.go | 4 +- chain_linux.go | 2 +- class_linux.go | 2 +- conntrack_linux.go | 27 +++--- conntrack_test.go | 184 ++++++++++++++++++------------------- devlink_linux.go | 2 +- devlink_test.go | 2 +- filter_linux.go | 2 +- filter_test.go | 2 +- fou_linux.go | 2 +- genetlink_linux.go | 2 +- gtp_linux.go | 2 +- handle_linux.go | 2 +- handle_test.go | 3 +- ipset_linux.go | 2 +- ipset_linux_test.go | 2 +- link_linux.go | 2 +- link_test.go | 2 +- neigh_linux.go | 2 +- netlink_linux.go | 2 +- netlink_test.go | 2 +- netns_linux.go | 2 +- order.go | 2 +- proc_event_linux.go | 2 +- protinfo_linux.go | 2 +- qdisc_linux.go | 2 +- rdma_link_linux.go | 2 +- route_linux.go | 2 +- route_test.go | 2 +- rule_linux.go | 2 +- socket_linux.go | 2 +- socket_xdp_linux.go | 2 +- vdpa_linux.go | 2 +- vdpa_linux_test.go | 2 +- xdp_diag.go | 2 +- xfrm_monitor_linux.go | 2 +- xfrm_monitor_linux_test.go | 2 +- xfrm_policy_linux.go | 2 +- xfrm_state_linux.go | 2 +- 40 files changed, 147 insertions(+), 143 deletions(-) diff --git a/addr_linux.go b/addr_linux.go index 9b49baf9..e85240e8 100644 --- a/addr_linux.go +++ b/addr_linux.go @@ -7,7 +7,7 @@ import ( "strings" "syscall" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "github.com/vishvananda/netns" "golang.org/x/sys/unix" ) diff --git a/bridge_linux.go b/bridge_linux.go index fa5766b8..079fe509 100644 --- a/bridge_linux.go +++ b/bridge_linux.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "golang.org/x/sys/unix" ) @@ -146,7 +146,7 @@ func (h *Handle) bridgeVlanModify(cmd int, link Link, vid, vidEnd uint16, pvid, vlanEndInfo.Flags |= nl.BRIDGE_VLAN_INFO_RANGE_END br.AddRtAttr(nl.IFLA_BRIDGE_VLAN_INFO, vlanEndInfo.Serialize()) - } else { + } else { br.AddRtAttr(nl.IFLA_BRIDGE_VLAN_INFO, vlanInfo.Serialize()) } diff --git a/chain_linux.go b/chain_linux.go index 5008e710..cd4d1b50 100644 --- a/chain_linux.go +++ b/chain_linux.go @@ -3,7 +3,7 @@ package netlink import ( "errors" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "golang.org/x/sys/unix" ) diff --git a/class_linux.go b/class_linux.go index 08fb16c2..da513681 100644 --- a/class_linux.go +++ b/class_linux.go @@ -8,7 +8,7 @@ import ( "fmt" "syscall" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "golang.org/x/sys/unix" ) diff --git a/conntrack_linux.go b/conntrack_linux.go index 69c5eca0..c0eea75b 100644 --- a/conntrack_linux.go +++ b/conntrack_linux.go @@ -9,7 +9,7 @@ import ( "strings" "time" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "golang.org/x/sys/unix" ) @@ -218,10 +218,11 @@ type ProtoInfo interface { type ProtoInfoTCP struct { State uint8 } + // Protocol returns "tcp". -func (*ProtoInfoTCP) Protocol() string {return "tcp"} +func (*ProtoInfoTCP) Protocol() string { return "tcp" } func (p *ProtoInfoTCP) toNlData() ([]*nl.RtAttr, error) { - ctProtoInfo := nl.NewRtAttr(unix.NLA_F_NESTED | nl.CTA_PROTOINFO, []byte{}) + ctProtoInfo := nl.NewRtAttr(unix.NLA_F_NESTED|nl.CTA_PROTOINFO, []byte{}) ctProtoInfoTCP := nl.NewRtAttr(unix.NLA_F_NESTED|nl.CTA_PROTOINFO_TCP, []byte{}) ctProtoInfoTCPState := nl.NewRtAttr(nl.CTA_PROTOINFO_TCP_STATE, nl.Uint8Attr(p.State)) ctProtoInfoTCP.AddChild(ctProtoInfoTCPState) @@ -231,14 +232,16 @@ func (p *ProtoInfoTCP) toNlData() ([]*nl.RtAttr, error) { } // ProtoInfoSCTP only supports the protocol name. -type ProtoInfoSCTP struct {} +type ProtoInfoSCTP struct{} + // Protocol returns "sctp". -func (*ProtoInfoSCTP) Protocol() string {return "sctp"} +func (*ProtoInfoSCTP) Protocol() string { return "sctp" } // ProtoInfoDCCP only supports the protocol name. -type ProtoInfoDCCP struct {} +type ProtoInfoDCCP struct{} + // Protocol returns "dccp". -func (*ProtoInfoDCCP) Protocol() string {return "dccp"} +func (*ProtoInfoDCCP) Protocol() string { return "dccp" } // The full conntrack flow structure is very complicated and can be found in the file: // http://git.netfilter.org/libnetfilter_conntrack/tree/include/internal/object.h @@ -280,7 +283,7 @@ func (t *IPTuple) toNlData(family uint8) ([]*nl.RtAttr, error) { ctTupleProtoSrcPort := nl.NewRtAttr(nl.CTA_PROTO_SRC_PORT, nl.BEUint16Attr(t.SrcPort)) ctTupleProto.AddChild(ctTupleProtoSrcPort) ctTupleProtoDstPort := nl.NewRtAttr(nl.CTA_PROTO_DST_PORT, nl.BEUint16Attr(t.DstPort)) - ctTupleProto.AddChild(ctTupleProtoDstPort, ) + ctTupleProto.AddChild(ctTupleProtoDstPort) return []*nl.RtAttr{ctTupleIP, ctTupleProto}, nil } @@ -357,7 +360,7 @@ func (s *ConntrackFlow) toNlData() ([]*nl.RtAttr, error) { // // // - + // CTA_TUPLE_ORIG ctTupleOrig := nl.NewRtAttr(unix.NLA_F_NESTED|nl.CTA_TUPLE_ORIG, nil) forwardFlowAttrs, err := s.Forward.toNlData(s.FamilyType) @@ -540,12 +543,12 @@ func parseTimeStamp(r *bytes.Reader, readSize uint16) (tstart, tstop uint64) { func parseProtoInfoTCPState(r *bytes.Reader) (s uint8) { binary.Read(r, binary.BigEndian, &s) - r.Seek(nl.SizeofNfattr - 1, seekCurrent) + r.Seek(nl.SizeofNfattr-1, seekCurrent) return s } // parseProtoInfoTCP reads the entire nested protoinfo structure, but only parses the state attr. -func parseProtoInfoTCP(r *bytes.Reader, attrLen uint16) (*ProtoInfoTCP) { +func parseProtoInfoTCP(r *bytes.Reader, attrLen uint16) *ProtoInfoTCP { p := new(ProtoInfoTCP) bytesRead := 0 for bytesRead < int(attrLen) { @@ -659,7 +662,7 @@ func parseRawData(data []byte) *ConntrackFlow { switch t { case nl.CTA_MARK: s.Mark = parseConnectionMark(reader) - case nl.CTA_LABELS: + case nl.CTA_LABELS: s.Labels = parseConnectionLabels(reader) case nl.CTA_TIMEOUT: s.TimeOut = parseTimeOut(reader) diff --git a/conntrack_test.go b/conntrack_test.go index 6850f3c5..9aa49b72 100644 --- a/conntrack_test.go +++ b/conntrack_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "github.com/vishvananda/netns" "golang.org/x/sys/unix" ) @@ -350,22 +350,22 @@ func TestConntrackTableDelete(t *testing.T) { func TestConntrackFilter(t *testing.T) { var flowList []ConntrackFlow flowList = append(flowList, ConntrackFlow{ - FamilyType: unix.AF_INET, - Forward: IPTuple{ - SrcIP: net.ParseIP("10.0.0.1"), - DstIP: net.ParseIP("20.0.0.1"), - SrcPort: 1000, - DstPort: 2000, - Protocol: 17, - }, - Reverse: IPTuple{ - SrcIP: net.ParseIP("20.0.0.1"), - DstIP: net.ParseIP("192.168.1.1"), - SrcPort: 2000, - DstPort: 1000, - Protocol: 17, - }, + FamilyType: unix.AF_INET, + Forward: IPTuple{ + SrcIP: net.ParseIP("10.0.0.1"), + DstIP: net.ParseIP("20.0.0.1"), + SrcPort: 1000, + DstPort: 2000, + Protocol: 17, }, + Reverse: IPTuple{ + SrcIP: net.ParseIP("20.0.0.1"), + DstIP: net.ParseIP("192.168.1.1"), + SrcPort: 2000, + DstPort: 1000, + Protocol: 17, + }, + }, ConntrackFlow{ FamilyType: unix.AF_INET, Forward: IPTuple{ @@ -1015,23 +1015,23 @@ func TestConntrackUpdateV4(t *testing.T) { flow := ConntrackFlow{ FamilyType: FAMILY_V4, Forward: IPTuple{ - SrcIP: net.IP{234,234,234,234}, - DstIP: net.IP{123,123,123,123}, - SrcPort: 48385, - DstPort: 53, + SrcIP: net.IP{234, 234, 234, 234}, + DstIP: net.IP{123, 123, 123, 123}, + SrcPort: 48385, + DstPort: 53, Protocol: unix.IPPROTO_TCP, }, Reverse: IPTuple{ - SrcIP: net.IP{123,123,123,123}, - DstIP: net.IP{234,234,234,234}, - SrcPort: 53, - DstPort: 48385, + SrcIP: net.IP{123, 123, 123, 123}, + DstIP: net.IP{234, 234, 234, 234}, + SrcPort: 53, + DstPort: 48385, Protocol: unix.IPPROTO_TCP, }, // No point checking equivalence of timeout, but value must // be reasonable to allow for a potentially slow subsequent read. - TimeOut: 100, - Mark: 12, + TimeOut: 100, + Mark: 12, ProtoInfo: &ProtoInfoTCP{ State: nl.TCP_CONNTRACK_SYN_SENT2, }, @@ -1054,8 +1054,8 @@ func TestConntrackUpdateV4(t *testing.T) { filter := ConntrackFilter{ ipNetFilter: map[ConntrackFilterType]*net.IPNet{ - ConntrackOrigSrcIP: NewIPNet(flow.Forward.SrcIP), - ConntrackOrigDstIP: NewIPNet(flow.Forward.DstIP), + ConntrackOrigSrcIP: NewIPNet(flow.Forward.SrcIP), + ConntrackOrigDstIP: NewIPNet(flow.Forward.DstIP), ConntrackReplySrcIP: NewIPNet(flow.Reverse.SrcIP), ConntrackReplyDstIP: NewIPNet(flow.Reverse.DstIP), }, @@ -1063,7 +1063,7 @@ func TestConntrackUpdateV4(t *testing.T) { ConntrackOrigSrcPort: flow.Forward.SrcPort, ConntrackOrigDstPort: flow.Forward.DstPort, }, - protoFilter:unix.IPPROTO_TCP, + protoFilter: unix.IPPROTO_TCP, } var match *ConntrackFlow @@ -1148,23 +1148,23 @@ func TestConntrackUpdateV6(t *testing.T) { flow := ConntrackFlow{ FamilyType: FAMILY_V6, Forward: IPTuple{ - SrcIP: net.ParseIP("2001:db8::68"), - DstIP: net.ParseIP("2001:db9::32"), - SrcPort: 48385, - DstPort: 53, + SrcIP: net.ParseIP("2001:db8::68"), + DstIP: net.ParseIP("2001:db9::32"), + SrcPort: 48385, + DstPort: 53, Protocol: unix.IPPROTO_TCP, }, Reverse: IPTuple{ - SrcIP: net.ParseIP("2001:db9::32"), - DstIP: net.ParseIP("2001:db8::68"), - SrcPort: 53, - DstPort: 48385, + SrcIP: net.ParseIP("2001:db9::32"), + DstIP: net.ParseIP("2001:db8::68"), + SrcPort: 53, + DstPort: 48385, Protocol: unix.IPPROTO_TCP, }, // No point checking equivalence of timeout, but value must // be reasonable to allow for a potentially slow subsequent read. - TimeOut: 100, - Mark: 12, + TimeOut: 100, + Mark: 12, ProtoInfo: &ProtoInfoTCP{ State: nl.TCP_CONNTRACK_SYN_SENT2, }, @@ -1187,8 +1187,8 @@ func TestConntrackUpdateV6(t *testing.T) { filter := ConntrackFilter{ ipNetFilter: map[ConntrackFilterType]*net.IPNet{ - ConntrackOrigSrcIP: NewIPNet(flow.Forward.SrcIP), - ConntrackOrigDstIP: NewIPNet(flow.Forward.DstIP), + ConntrackOrigSrcIP: NewIPNet(flow.Forward.SrcIP), + ConntrackOrigDstIP: NewIPNet(flow.Forward.DstIP), ConntrackReplySrcIP: NewIPNet(flow.Reverse.SrcIP), ConntrackReplyDstIP: NewIPNet(flow.Reverse.DstIP), }, @@ -1196,7 +1196,7 @@ func TestConntrackUpdateV6(t *testing.T) { ConntrackOrigSrcPort: flow.Forward.SrcPort, ConntrackOrigDstPort: flow.Forward.DstPort, }, - protoFilter:unix.IPPROTO_TCP, + protoFilter: unix.IPPROTO_TCP, } var match *ConntrackFlow @@ -1279,23 +1279,23 @@ func TestConntrackCreateV4(t *testing.T) { flow := ConntrackFlow{ FamilyType: FAMILY_V4, Forward: IPTuple{ - SrcIP: net.IP{234,234,234,234}, - DstIP: net.IP{123,123,123,123}, - SrcPort: 48385, - DstPort: 53, + SrcIP: net.IP{234, 234, 234, 234}, + DstIP: net.IP{123, 123, 123, 123}, + SrcPort: 48385, + DstPort: 53, Protocol: unix.IPPROTO_TCP, }, Reverse: IPTuple{ - SrcIP: net.IP{123,123,123,123}, - DstIP: net.IP{234,234,234,234}, - SrcPort: 53, - DstPort: 48385, + SrcIP: net.IP{123, 123, 123, 123}, + DstIP: net.IP{234, 234, 234, 234}, + SrcPort: 53, + DstPort: 48385, Protocol: unix.IPPROTO_TCP, }, // No point checking equivalence of timeout, but value must // be reasonable to allow for a potentially slow subsequent read. - TimeOut: 100, - Mark: 12, + TimeOut: 100, + Mark: 12, ProtoInfo: &ProtoInfoTCP{ State: nl.TCP_CONNTRACK_ESTABLISHED, }, @@ -1313,8 +1313,8 @@ func TestConntrackCreateV4(t *testing.T) { filter := ConntrackFilter{ ipNetFilter: map[ConntrackFilterType]*net.IPNet{ - ConntrackOrigSrcIP: NewIPNet(flow.Forward.SrcIP), - ConntrackOrigDstIP: NewIPNet(flow.Forward.DstIP), + ConntrackOrigSrcIP: NewIPNet(flow.Forward.SrcIP), + ConntrackOrigDstIP: NewIPNet(flow.Forward.DstIP), ConntrackReplySrcIP: NewIPNet(flow.Reverse.SrcIP), ConntrackReplyDstIP: NewIPNet(flow.Reverse.DstIP), }, @@ -1322,7 +1322,7 @@ func TestConntrackCreateV4(t *testing.T) { ConntrackOrigSrcPort: flow.Forward.SrcPort, ConntrackOrigDstPort: flow.Forward.DstPort, }, - protoFilter:unix.IPPROTO_TCP, + protoFilter: unix.IPPROTO_TCP, } var match *ConntrackFlow @@ -1374,23 +1374,23 @@ func TestConntrackCreateV6(t *testing.T) { flow := ConntrackFlow{ FamilyType: FAMILY_V6, Forward: IPTuple{ - SrcIP: net.ParseIP("2001:db8::68"), - DstIP: net.ParseIP("2001:db9::32"), - SrcPort: 48385, - DstPort: 53, + SrcIP: net.ParseIP("2001:db8::68"), + DstIP: net.ParseIP("2001:db9::32"), + SrcPort: 48385, + DstPort: 53, Protocol: unix.IPPROTO_TCP, }, Reverse: IPTuple{ - SrcIP: net.ParseIP("2001:db9::32"), - DstIP: net.ParseIP("2001:db8::68"), - SrcPort: 53, - DstPort: 48385, + SrcIP: net.ParseIP("2001:db9::32"), + DstIP: net.ParseIP("2001:db8::68"), + SrcPort: 53, + DstPort: 48385, Protocol: unix.IPPROTO_TCP, }, // No point checking equivalence of timeout, but value must // be reasonable to allow for a potentially slow subsequent read. - TimeOut: 100, - Mark: 12, + TimeOut: 100, + Mark: 12, ProtoInfo: &ProtoInfoTCP{ State: nl.TCP_CONNTRACK_ESTABLISHED, }, @@ -1408,8 +1408,8 @@ func TestConntrackCreateV6(t *testing.T) { filter := ConntrackFilter{ ipNetFilter: map[ConntrackFilterType]*net.IPNet{ - ConntrackOrigSrcIP: NewIPNet(flow.Forward.SrcIP), - ConntrackOrigDstIP: NewIPNet(flow.Forward.DstIP), + ConntrackOrigSrcIP: NewIPNet(flow.Forward.SrcIP), + ConntrackOrigDstIP: NewIPNet(flow.Forward.DstIP), ConntrackReplySrcIP: NewIPNet(flow.Reverse.SrcIP), ConntrackReplyDstIP: NewIPNet(flow.Reverse.DstIP), }, @@ -1417,7 +1417,7 @@ func TestConntrackCreateV6(t *testing.T) { ConntrackOrigSrcPort: flow.Forward.SrcPort, ConntrackOrigDstPort: flow.Forward.DstPort, }, - protoFilter:unix.IPPROTO_TCP, + protoFilter: unix.IPPROTO_TCP, } var match *ConntrackFlow @@ -1448,43 +1448,43 @@ func TestConntrackFlowToNlData(t *testing.T) { flowV4 := ConntrackFlow{ FamilyType: FAMILY_V4, Forward: IPTuple{ - SrcIP: net.IP{234,234,234,234}, - DstIP: net.IP{123,123,123,123}, - SrcPort: 48385, - DstPort: 53, + SrcIP: net.IP{234, 234, 234, 234}, + DstIP: net.IP{123, 123, 123, 123}, + SrcPort: 48385, + DstPort: 53, Protocol: unix.IPPROTO_TCP, }, Reverse: IPTuple{ - SrcIP: net.IP{123,123,123,123}, - DstIP: net.IP{234,234,234,234}, - SrcPort: 53, - DstPort: 48385, + SrcIP: net.IP{123, 123, 123, 123}, + DstIP: net.IP{234, 234, 234, 234}, + SrcPort: 53, + DstPort: 48385, Protocol: unix.IPPROTO_TCP, }, - Mark: 5, - TimeOut: 10, + Mark: 5, + TimeOut: 10, ProtoInfo: &ProtoInfoTCP{ State: nl.TCP_CONNTRACK_ESTABLISHED, }, } - flowV6 := ConntrackFlow { + flowV6 := ConntrackFlow{ FamilyType: FAMILY_V6, Forward: IPTuple{ - SrcIP: net.ParseIP("2001:db8::68"), - DstIP: net.ParseIP("2001:db9::32"), - SrcPort: 48385, - DstPort: 53, - Protocol: unix.IPPROTO_TCP, + SrcIP: net.ParseIP("2001:db8::68"), + DstIP: net.ParseIP("2001:db9::32"), + SrcPort: 48385, + DstPort: 53, + Protocol: unix.IPPROTO_TCP, }, Reverse: IPTuple{ - SrcIP: net.ParseIP("2001:db9::32"), - DstIP: net.ParseIP("2001:db8::68"), - SrcPort: 53, - DstPort: 48385, + SrcIP: net.ParseIP("2001:db9::32"), + DstIP: net.ParseIP("2001:db8::68"), + SrcPort: 53, + DstPort: 48385, Protocol: unix.IPPROTO_TCP, }, - Mark: 5, - TimeOut: 10, + Mark: 5, + TimeOut: 10, ProtoInfo: &ProtoInfoTCP{ State: nl.TCP_CONNTRACK_ESTABLISHED, }, @@ -1497,7 +1497,7 @@ func TestConntrackFlowToNlData(t *testing.T) { t.Fatalf("Error converting ConntrackFlow to netlink messages: %s", err) } // Mock nfgenmsg header - bytesV4 = append(bytesV4, flowV4.FamilyType,0,0,0) + bytesV4 = append(bytesV4, flowV4.FamilyType, 0, 0, 0) for _, a := range attrsV4 { bytesV4 = append(bytesV4, a.Serialize()...) } @@ -1507,7 +1507,7 @@ func TestConntrackFlowToNlData(t *testing.T) { t.Fatalf("Error converting ConntrackFlow to netlink messages: %s", err) } // Mock nfgenmsg header - bytesV6 = append(bytesV6, flowV6.FamilyType,0,0,0) + bytesV6 = append(bytesV6, flowV6.FamilyType, 0, 0, 0) for _, a := range attrsV6 { bytesV6 = append(bytesV6, a.Serialize()...) } diff --git a/devlink_linux.go b/devlink_linux.go index 45d8ee4b..c0c13b34 100644 --- a/devlink_linux.go +++ b/devlink_linux.go @@ -7,7 +7,7 @@ import ( "strings" "syscall" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "golang.org/x/sys/unix" ) diff --git a/devlink_test.go b/devlink_test.go index cf6961c7..f639b10f 100644 --- a/devlink_test.go +++ b/devlink_test.go @@ -11,7 +11,7 @@ import ( "strconv" "testing" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" ) func TestDevLinkGetDeviceList(t *testing.T) { diff --git a/filter_linux.go b/filter_linux.go index 19306612..ff723d45 100644 --- a/filter_linux.go +++ b/filter_linux.go @@ -9,7 +9,7 @@ import ( "net" "syscall" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "golang.org/x/sys/unix" ) diff --git a/filter_test.go b/filter_test.go index 3a49f1b8..3bc3797e 100644 --- a/filter_test.go +++ b/filter_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "golang.org/x/sys/unix" ) diff --git a/fou_linux.go b/fou_linux.go index 7645a5a5..20f50852 100644 --- a/fou_linux.go +++ b/fou_linux.go @@ -9,7 +9,7 @@ import ( "log" "net" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "golang.org/x/sys/unix" ) diff --git a/genetlink_linux.go b/genetlink_linux.go index 7bdaad97..4877c900 100644 --- a/genetlink_linux.go +++ b/genetlink_linux.go @@ -5,7 +5,7 @@ import ( "fmt" "syscall" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "golang.org/x/sys/unix" ) diff --git a/gtp_linux.go b/gtp_linux.go index 377dcae5..10a05aea 100644 --- a/gtp_linux.go +++ b/gtp_linux.go @@ -7,7 +7,7 @@ import ( "strings" "syscall" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "golang.org/x/sys/unix" ) diff --git a/handle_linux.go b/handle_linux.go index 4cb01168..3597c451 100644 --- a/handle_linux.go +++ b/handle_linux.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "github.com/vishvananda/netns" "golang.org/x/sys/unix" ) diff --git a/handle_test.go b/handle_test.go index c7feb22d..a7f71990 100644 --- a/handle_test.go +++ b/handle_test.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package netlink @@ -13,7 +14,7 @@ import ( "testing" "time" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "github.com/vishvananda/netns" ) diff --git a/ipset_linux.go b/ipset_linux.go index f4c05229..1d42a891 100644 --- a/ipset_linux.go +++ b/ipset_linux.go @@ -6,7 +6,7 @@ import ( "net" "syscall" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "golang.org/x/sys/unix" ) diff --git a/ipset_linux_test.go b/ipset_linux_test.go index 298c3a3a..012bfdd7 100644 --- a/ipset_linux_test.go +++ b/ipset_linux_test.go @@ -6,7 +6,7 @@ import ( "net" "testing" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "golang.org/x/sys/unix" ) diff --git a/link_linux.go b/link_linux.go index dca26162..6b0dee6d 100644 --- a/link_linux.go +++ b/link_linux.go @@ -13,7 +13,7 @@ import ( "syscall" "unsafe" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "github.com/vishvananda/netns" "golang.org/x/sys/unix" ) diff --git a/link_test.go b/link_test.go index eb7bd228..a0440c4a 100644 --- a/link_test.go +++ b/link_test.go @@ -16,7 +16,7 @@ import ( "testing" "time" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "github.com/vishvananda/netns" "golang.org/x/sys/unix" ) diff --git a/neigh_linux.go b/neigh_linux.go index 1c6f2958..4c902c06 100644 --- a/neigh_linux.go +++ b/neigh_linux.go @@ -7,7 +7,7 @@ import ( "syscall" "unsafe" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "github.com/vishvananda/netns" "golang.org/x/sys/unix" ) diff --git a/netlink_linux.go b/netlink_linux.go index 7416e305..c2851753 100644 --- a/netlink_linux.go +++ b/netlink_linux.go @@ -1,6 +1,6 @@ package netlink -import "github.com/vishvananda/netlink/nl" +import "github.com/nsdavidson/netlink/nl" // Family type definitions const ( diff --git a/netlink_test.go b/netlink_test.go index ed0059ae..3bd95e3b 100644 --- a/netlink_test.go +++ b/netlink_test.go @@ -16,7 +16,7 @@ import ( "strings" "testing" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "github.com/vishvananda/netns" "golang.org/x/sys/unix" ) diff --git a/netns_linux.go b/netns_linux.go index 2eb29c7c..802acefe 100644 --- a/netns_linux.go +++ b/netns_linux.go @@ -15,7 +15,7 @@ package netlink import ( "fmt" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "golang.org/x/sys/unix" ) diff --git a/order.go b/order.go index e28e153a..804dd3ae 100644 --- a/order.go +++ b/order.go @@ -3,7 +3,7 @@ package netlink import ( "encoding/binary" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" ) var ( diff --git a/proc_event_linux.go b/proc_event_linux.go index ac8762bd..ecfb6656 100644 --- a/proc_event_linux.go +++ b/proc_event_linux.go @@ -7,7 +7,7 @@ import ( "os" "syscall" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "github.com/vishvananda/netns" "golang.org/x/sys/unix" ) diff --git a/protinfo_linux.go b/protinfo_linux.go index aa51e3b4..04095703 100644 --- a/protinfo_linux.go +++ b/protinfo_linux.go @@ -5,7 +5,7 @@ import ( "fmt" "syscall" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "golang.org/x/sys/unix" ) diff --git a/qdisc_linux.go b/qdisc_linux.go index 22cf0e58..4488f247 100644 --- a/qdisc_linux.go +++ b/qdisc_linux.go @@ -9,7 +9,7 @@ import ( "sync" "syscall" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "golang.org/x/sys/unix" ) diff --git a/rdma_link_linux.go b/rdma_link_linux.go index 9bb75073..761aa90c 100644 --- a/rdma_link_linux.go +++ b/rdma_link_linux.go @@ -7,7 +7,7 @@ import ( "fmt" "net" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "golang.org/x/sys/unix" ) diff --git a/route_linux.go b/route_linux.go index e71a4b12..8cafdea5 100644 --- a/route_linux.go +++ b/route_linux.go @@ -10,7 +10,7 @@ import ( "strings" "syscall" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "github.com/vishvananda/netns" "golang.org/x/sys/unix" ) diff --git a/route_test.go b/route_test.go index 7e5e6b0e..52064e58 100644 --- a/route_test.go +++ b/route_test.go @@ -11,7 +11,7 @@ import ( "testing" "time" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "github.com/vishvananda/netns" "golang.org/x/sys/unix" ) diff --git a/rule_linux.go b/rule_linux.go index dba99147..365f5df3 100644 --- a/rule_linux.go +++ b/rule_linux.go @@ -6,7 +6,7 @@ import ( "fmt" "net" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "golang.org/x/sys/unix" ) diff --git a/socket_linux.go b/socket_linux.go index 82891bc2..e270e0d5 100644 --- a/socket_linux.go +++ b/socket_linux.go @@ -6,7 +6,7 @@ import ( "net" "syscall" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "golang.org/x/sys/unix" ) diff --git a/socket_xdp_linux.go b/socket_xdp_linux.go index c1dd00a8..380505fd 100644 --- a/socket_xdp_linux.go +++ b/socket_xdp_linux.go @@ -5,7 +5,7 @@ import ( "fmt" "syscall" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "golang.org/x/sys/unix" ) diff --git a/vdpa_linux.go b/vdpa_linux.go index c14877a2..5dab4eb8 100644 --- a/vdpa_linux.go +++ b/vdpa_linux.go @@ -8,7 +8,7 @@ import ( "golang.org/x/sys/unix" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" ) type vdpaDevID struct { diff --git a/vdpa_linux_test.go b/vdpa_linux_test.go index 91a488e4..d6dab5a7 100644 --- a/vdpa_linux_test.go +++ b/vdpa_linux_test.go @@ -5,7 +5,7 @@ import ( "syscall" "testing" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" ) // tests in this package require following modules: vdpa, vdpa_sim, vdpa_sim_net diff --git a/xdp_diag.go b/xdp_diag.go index e88825bf..ecad493c 100644 --- a/xdp_diag.go +++ b/xdp_diag.go @@ -1,6 +1,6 @@ package netlink -import "github.com/vishvananda/netlink/nl" +import "github.com/nsdavidson/netlink/nl" const SOCK_ANY_COOKIE = uint64(nl.TCPDIAG_NOCOOKIE)<<32 + uint64(nl.TCPDIAG_NOCOOKIE) diff --git a/xfrm_monitor_linux.go b/xfrm_monitor_linux.go index 985d3a91..5976133b 100644 --- a/xfrm_monitor_linux.go +++ b/xfrm_monitor_linux.go @@ -3,7 +3,7 @@ package netlink import ( "fmt" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "github.com/vishvananda/netns" "golang.org/x/sys/unix" ) diff --git a/xfrm_monitor_linux_test.go b/xfrm_monitor_linux_test.go index 47b6ecd0..b1c4cb94 100644 --- a/xfrm_monitor_linux_test.go +++ b/xfrm_monitor_linux_test.go @@ -4,7 +4,7 @@ import ( "os" "testing" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" ) func TestXfrmMonitorExpire(t *testing.T) { diff --git a/xfrm_policy_linux.go b/xfrm_policy_linux.go index bf143a1b..688716e8 100644 --- a/xfrm_policy_linux.go +++ b/xfrm_policy_linux.go @@ -5,7 +5,7 @@ import ( "fmt" "net" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "golang.org/x/sys/unix" ) diff --git a/xfrm_state_linux.go b/xfrm_state_linux.go index 2f461465..a3c9858b 100644 --- a/xfrm_state_linux.go +++ b/xfrm_state_linux.go @@ -7,7 +7,7 @@ import ( "time" "unsafe" - "github.com/vishvananda/netlink/nl" + "github.com/nsdavidson/netlink/nl" "golang.org/x/sys/unix" ) From dcd2788ba3f0e0def4510976e11a2f1c4e51dd74 Mon Sep 17 00:00:00 2001 From: Nolan Davidson Date: Wed, 2 Oct 2024 21:58:28 -0400 Subject: [PATCH 4/5] use pid from message --- route_linux.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/route_linux.go b/route_linux.go index 8cafdea5..54b9bfab 100644 --- a/route_linux.go +++ b/route_linux.go @@ -1790,7 +1790,7 @@ func routeSubscribeAt(newNs, curNs netns.NsHandle, ch chan<- RouteUpdate, done < Type: m.Header.Type, NlFlags: m.Header.Flags & (unix.NLM_F_REPLACE | unix.NLM_F_EXCL | unix.NLM_F_CREATE | unix.NLM_F_APPEND), Route: route, - SourcePID: from.Pid, + SourcePID: m.Header.Pid, } } } From d73e524db07ed1f88ba983486380c486232e01b1 Mon Sep 17 00:00:00 2001 From: Nolan Davidson Date: Thu, 3 Oct 2024 13:25:16 -0400 Subject: [PATCH 5/5] add from pid --- route.go | 1 + route_linux.go | 1 + 2 files changed, 2 insertions(+) diff --git a/route.go b/route.go index 2ce95709..a9af2094 100644 --- a/route.go +++ b/route.go @@ -164,6 +164,7 @@ type RouteUpdate struct { Type uint16 NlFlags uint16 SourcePID uint32 + FromPID uint32 Route } diff --git a/route_linux.go b/route_linux.go index 54b9bfab..cf7c9b9c 100644 --- a/route_linux.go +++ b/route_linux.go @@ -1791,6 +1791,7 @@ func routeSubscribeAt(newNs, curNs netns.NsHandle, ch chan<- RouteUpdate, done < NlFlags: m.Header.Flags & (unix.NLM_F_REPLACE | unix.NLM_F_EXCL | unix.NLM_F_CREATE | unix.NLM_F_APPEND), Route: route, SourcePID: m.Header.Pid, + FromPID: from.Pid, } } }