MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rule_find_less_specific

Function rule_find_less_specific

dpdk/lib/lpm/rte_lpm6.c:1141–1176  ·  view source on GitHub ↗

* Find a less specific rule */

Source from the content-addressed store, hash-verified

1139 * Find a less specific rule
1140 */
1141static int
1142rule_find_less_specific(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth,
1143 struct rte_lpm6_rule *rule)
1144{
1145 int ret;
1146 uint32_t next_hop;
1147 uint8_t mask;
1148 struct rte_lpm6_rule_key rule_key;
1149
1150 if (depth == 1)
1151 return 0;
1152
1153 rule_key_init(&rule_key, ip, depth);
1154
1155 while (depth > 1) {
1156 depth--;
1157
1158 /* each iteration zero one more bit of the key */
1159 mask = depth & 7; /* depth % BYTE_SIZE */
1160 if (mask > 0)
1161 mask = depth_to_mask_1b(mask);
1162
1163 rule_key.depth = depth;
1164 rule_key.ip[depth >> 3] &= mask;
1165
1166 ret = rule_find_with_key(lpm, &rule_key, &next_hop);
1167 if (ret) {
1168 rule->depth = depth;
1169 ip6_copy_addr(rule->ip, rule_key.ip);
1170 rule->next_hop = next_hop;
1171 return 1;
1172 }
1173 }
1174
1175 return 0;
1176}
1177
1178/*
1179 * Find range of tbl8 cells occupied by a rule

Callers 1

rte_lpm6_deleteFunction · 0.70

Calls 4

rule_key_initFunction · 0.70
depth_to_mask_1bFunction · 0.70
rule_find_with_keyFunction · 0.70
ip6_copy_addrFunction · 0.70

Tested by

no test coverage detected