From cbabf5aa1cddff4754adec4d5e78a4aa3391c46a Mon Sep 17 00:00:00 2001 From: Satoshi Fujimoto Date: Tue, 20 Jun 2017 14:23:09 +0900 Subject: 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 --- packet/bgp/bgp.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'packet') 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 } -- cgit v1.2.3