diff options
author | Satoshi Fujimoto <satoshi.fujimoto7@gmail.com> | 2017-06-20 14:23:09 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-07-10 15:39:14 +0900 |
commit | cbabf5aa1cddff4754adec4d5e78a4aa3391c46a (patch) | |
tree | da89b70975b8cf4379070d8b14708c763a43a107 /packet/bgp | |
parent | e56172a206153653b22703f76efc59b5d6ae5510 (diff) |
flowspec: Set AND to correct operand for TCP Flags
Currently, if TCP Flags field is specified from CLI command,
GoBGP sets 'AND' bit to the invalid operand.
RFC 5575 says it represents the previous term is logically ANDed or not,
and "It should be unset in the first operator byte of a sequence".
This patch fixes this to comply with RFC5575.
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Diffstat (limited to 'packet/bgp')
-rw-r--r-- | packet/bgp/bgp.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/packet/bgp/bgp.go b/packet/bgp/bgp.go index 91a6b05f..7ccebf88 100644 --- a/packet/bgp/bgp.go +++ b/packet/bgp/bgp.go @@ -2845,9 +2845,8 @@ func parseTcpFlagCmd(myCmd string) ([][2]int, error) { } case TCPFlagOpNameMap[TCP_FLAG_OP_AND], TCPFlagOpNameMap[TCP_FLAG_OP_OR]: if bit := TCPFlagOpValueMap[myCmdChar]; bit&TCPFlagOp(operatorValue[0]) == 0 { - operatorValue[0] |= int(bit) tcpOperatorsFlagsValues = append(tcpOperatorsFlagsValues, operatorValue) - operatorValue[0] = 0 + operatorValue[0] = int(bit) operatorValue[1] = 0 index++ } else { @@ -3543,9 +3542,9 @@ func formatFlag(op int, value int) string { } } if op&TCP_FLAG_OP_AND > 0 { - retString = fmt.Sprintf("%s%s", retString, TCPFlagOpNameMap[TCP_FLAG_OP_AND]) + retString = fmt.Sprintf("%s%s", TCPFlagOpNameMap[TCP_FLAG_OP_AND], retString) } else { // default is or - retString = fmt.Sprintf("%s%s", retString, TCPFlagOpNameMap[TCP_FLAG_OP_OR]) + retString = fmt.Sprintf("%s%s", TCPFlagOpNameMap[TCP_FLAG_OP_OR], retString) } return retString } |