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

Nsd/add other source ip #1024

Closed
Closed
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 addr_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
4 changes: 2 additions & 2 deletions bridge_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"errors"
"fmt"

"github.com/vishvananda/netlink/nl"
"github.com/nsdavidson/netlink/nl"
"golang.org/x/sys/unix"
)

Expand Down Expand Up @@ -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())
}

Expand Down
2 changes: 1 addition & 1 deletion chain_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package netlink
import (
"errors"

"github.com/vishvananda/netlink/nl"
"github.com/nsdavidson/netlink/nl"
"golang.org/x/sys/unix"
)

Expand Down
2 changes: 1 addition & 1 deletion class_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"
"syscall"

"github.com/vishvananda/netlink/nl"
"github.com/nsdavidson/netlink/nl"
"golang.org/x/sys/unix"
)

Expand Down
27 changes: 15 additions & 12 deletions conntrack_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"
"time"

"github.com/vishvananda/netlink/nl"
"github.com/nsdavidson/netlink/nl"
"golang.org/x/sys/unix"
)

Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -357,7 +360,7 @@ func (s *ConntrackFlow) toNlData() ([]*nl.RtAttr, error) {
// <len, CTA_TIMEOUT>
// <BEuint64>
// <len, NLA_F_NESTED|CTA_PROTOINFO>

// CTA_TUPLE_ORIG
ctTupleOrig := nl.NewRtAttr(unix.NLA_F_NESTED|nl.CTA_TUPLE_ORIG, nil)
forwardFlowAttrs, err := s.Forward.toNlData(s.FamilyType)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down
Loading
Loading