diff --git a/fixtures/net/ip_vs b/fixtures/net/ip_vs index d7620b271..68380dc34 100644 --- a/fixtures/net/ip_vs +++ b/fixtures/net/ip_vs @@ -16,3 +16,6 @@ TCP [2620:0000:0000:0000:0000:0000:0000:0001]:0050 sh -> [2620:0000:0000:0000:0000:0000:0000:0002]:0050 Route 1 0 0 -> [2620:0000:0000:0000:0000:0000:0000:0003]:0050 Route 1 0 0 -> [2620:0000:0000:0000:0000:0000:0000:0004]:0050 Route 1 1 1 +FWM 10001000 wlc + -> C0A8321A:0CEA Route 0 0 1 + -> C0A83215:0CEA Route 0 0 2 diff --git a/ipvs.go b/ipvs.go index 0e61dba80..696d114e7 100644 --- a/ipvs.go +++ b/ipvs.go @@ -33,6 +33,8 @@ type IPVSBackendStatus struct { LocalAddress net.IP // The local (virtual) port. LocalPort uint16 + // The local firewall mark + LocalMark string // The transport protocol (TCP, UDP). Proto string // The remote (real) IP address. @@ -142,6 +144,7 @@ func parseIPVSBackendStatus(file io.Reader) ([]IPVSBackendStatus, error) { status []IPVSBackendStatus scanner = bufio.NewScanner(file) proto string + localMark string localAddress net.IP localPort uint16 err error @@ -160,10 +163,19 @@ func parseIPVSBackendStatus(file io.Reader) ([]IPVSBackendStatus, error) { continue } proto = fields[0] + localMark = "" localAddress, localPort, err = parseIPPort(fields[1]) if err != nil { return nil, err } + case fields[0] == "FWM": + if len(fields) < 2 { + continue + } + proto = fields[0] + localMark = fields[1] + localAddress = nil + localPort = 0 case fields[0] == "->": if len(fields) < 6 { continue @@ -187,6 +199,7 @@ func parseIPVSBackendStatus(file io.Reader) ([]IPVSBackendStatus, error) { status = append(status, IPVSBackendStatus{ LocalAddress: localAddress, LocalPort: localPort, + LocalMark: localMark, RemoteAddress: remoteAddress, RemotePort: remotePort, Proto: proto, diff --git a/ipvs_test.go b/ipvs_test.go index 24ca92f46..4ba5a6bc1 100644 --- a/ipvs_test.go +++ b/ipvs_test.go @@ -123,6 +123,23 @@ var ( Weight: 1, ActiveConn: 1, InactConn: 1, + { + LocalMark: "10001000", + RemoteAddress: net.ParseIP("192.168.50.26"), + RemotePort: 3306, + Proto: "FWM", + Weight: 0, + ActiveConn: 0, + InactConn: 1, + }, + { + LocalMark: "10001000", + RemoteAddress: net.ParseIP("192.168.50.21"), + RemotePort: 3306, + Proto: "FWM", + Weight: 0, + ActiveConn: 0, + InactConn: 2, }, } )