diff options
Diffstat (limited to 'bgpd/bgp_flowspec_util.c')
-rw-r--r-- | bgpd/bgp_flowspec_util.c | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/bgpd/bgp_flowspec_util.c b/bgpd/bgp_flowspec_util.c index 66426ab3..31e14d41 100644 --- a/bgpd/bgp_flowspec_util.c +++ b/bgpd/bgp_flowspec_util.c @@ -305,14 +305,14 @@ int bgp_flowspec_op_decode(enum bgp_flowspec_util_nlri_t type, break; mval->value = value; if (op[5] == 1) - mval->compare_operator |= - OPERATOR_COMPARE_LESS_THAN; + SET_FLAG(mval->compare_operator, + OPERATOR_COMPARE_LESS_THAN); if (op[6] == 1) - mval->compare_operator |= - OPERATOR_COMPARE_GREATER_THAN; + SET_FLAG(mval->compare_operator, + OPERATOR_COMPARE_GREATER_THAN); if (op[7] == 1) - mval->compare_operator |= - OPERATOR_COMPARE_EQUAL_TO; + SET_FLAG(mval->compare_operator, + OPERATOR_COMPARE_EQUAL_TO); if (op[1] == 1) mval->unary_operator = OPERATOR_UNARY_AND; else @@ -413,16 +413,16 @@ int bgp_flowspec_bitmask_decode(enum bgp_flowspec_util_nlri_t type, mval->value = value; if (op[6] == 1) { /* different from */ - mval->compare_operator |= - OPERATOR_COMPARE_LESS_THAN; - mval->compare_operator |= - OPERATOR_COMPARE_GREATER_THAN; + SET_FLAG(mval->compare_operator, + OPERATOR_COMPARE_LESS_THAN); + SET_FLAG(mval->compare_operator, + OPERATOR_COMPARE_GREATER_THAN); } else - mval->compare_operator |= - OPERATOR_COMPARE_EQUAL_TO; + SET_FLAG(mval->compare_operator, + OPERATOR_COMPARE_EQUAL_TO); if (op[7] == 1) - mval->compare_operator |= - OPERATOR_COMPARE_EXACT_MATCH; + SET_FLAG(mval->compare_operator, + OPERATOR_COMPARE_EXACT_MATCH); if (op[1] == 1) mval->unary_operator = OPERATOR_UNARY_AND; @@ -467,11 +467,11 @@ int bgp_flowspec_match_rules_fill(uint8_t *nlri_content, int len, case FLOWSPEC_SRC_PREFIX: bitmask = 0; if (type == FLOWSPEC_DEST_PREFIX) { - bitmask |= PREFIX_DST_PRESENT; + SET_FLAG(bitmask, PREFIX_DST_PRESENT); prefix = &bpem->dst_prefix; prefix_offset = &bpem->dst_prefix_offset; } else { - bitmask |= PREFIX_SRC_PRESENT; + SET_FLAG(bitmask, PREFIX_SRC_PRESENT); prefix = &bpem->src_prefix; prefix_offset = &bpem->src_prefix_offset; } @@ -491,14 +491,16 @@ int bgp_flowspec_match_rules_fill(uint8_t *nlri_content, int len, */ if (prefix->family == AF_INET && prefix->u.prefix4.s_addr == INADDR_ANY) - bpem->match_bitmask_iprule |= bitmask; + SET_FLAG(bpem->match_bitmask_iprule, + bitmask); else if (prefix->family == AF_INET6 && !memcmp(&prefix->u.prefix6, &in6addr_any, sizeof(struct in6_addr))) - bpem->match_bitmask_iprule |= bitmask; + SET_FLAG(bpem->match_bitmask_iprule, + bitmask); else - bpem->match_bitmask |= bitmask; + SET_FLAG(bpem->match_bitmask, bitmask); } offset += ret; break; @@ -640,8 +642,8 @@ int bgp_flowspec_match_rules_fill(uint8_t *nlri_content, int len, || bpem->match_dst_port_num || bpem->match_protocol_num || bpem->match_bitmask || bpem->match_flowlabel_num) bpem->type = BGP_PBR_IPSET; - else if ((bpem->match_bitmask_iprule & PREFIX_SRC_PRESENT) || - (bpem->match_bitmask_iprule & PREFIX_DST_PRESENT)) + else if (CHECK_FLAG(bpem->match_bitmask_iprule, PREFIX_SRC_PRESENT) || + CHECK_FLAG(bpem->match_bitmask_iprule, PREFIX_DST_PRESENT)) /* the extracted policy rule may not need an * iptables/ipset filtering. check this may not be * a standard ip rule : permit any to any ( eg) |