Skip to content

Commit 82a26d2

Browse files
dslicencdonaldsharp
authored andcommitted
pbrd: adjust/remove the rule correctly when dst and/or src removed
When the last match criteria was removed (dst-ip or src-ip), we were not deleting the rule correctly for ipv6. This fix retains the needed src-ip/dst-ip during the pbr_send_pbr_map process so the appropriate information is available for the rule delete. Signed-off-by: Don Slice <[email protected]>
1 parent 01e375b commit 82a26d2

File tree

5 files changed

+13
-17
lines changed

5 files changed

+13
-17
lines changed

pbrd/pbr_map.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -527,13 +527,6 @@ void pbr_map_check(struct pbr_map_sequence *pbrms)
527527
__PRETTY_FUNCTION__, pbrm->name, pbrms->seqno, pbrms->reason);
528528

529529
if (pbrms->reason == PBR_MAP_VALID_SEQUENCE_NUMBER) {
530-
if (pbrms->installed) {
531-
install = false;
532-
for (ALL_LIST_ELEMENTS_RO(pbrm->incoming, inode, pmi)) {
533-
pbr_send_pbr_map(pbrms, pmi, install);
534-
}
535-
install = true;
536-
}
537530
install = true;
538531
DEBUGD(&pbr_dbg_map, "%s: Installing %s(%u) reason: %" PRIu64,
539532
__PRETTY_FUNCTION__, pbrm->name, pbrms->seqno,

pbrd/pbr_map.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ struct pbr_map_sequence {
8484
struct prefix *src;
8585
struct prefix *dst;
8686

87+
/*
88+
* Family of the src/dst. Needed when deleting since we clear them
89+
*/
90+
unsigned char family;
91+
8792
/*
8893
* The nexthop group we auto create
8994
* for when the user specifies a individual

pbrd/pbr_vty.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ DEFPY(pbr_map_match_src, pbr_map_match_src_cmd,
9595
{
9696
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
9797

98+
pbrms->family = prefix->family;
99+
98100
if (!no) {
99101
if (prefix_same(pbrms->src, prefix))
100102
return CMD_SUCCESS;
@@ -122,6 +124,8 @@ DEFPY(pbr_map_match_dst, pbr_map_match_dst_cmd,
122124
{
123125
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
124126

127+
pbrms->family = prefix->family;
128+
125129
if (!no) {
126130
if (prefix_same(pbrms->dst, prefix))
127131
return CMD_SUCCESS;

pbrd/pbr_zebra.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ void pbr_send_rnh(struct nexthop *nhop, bool reg)
455455

456456
static void pbr_encode_pbr_map_sequence_prefix(struct stream *s,
457457
struct prefix *p,
458-
u_char family)
458+
unsigned char family)
459459
{
460460
struct prefix any;
461461

@@ -474,14 +474,11 @@ static void pbr_encode_pbr_map_sequence(struct stream *s,
474474
struct pbr_map_sequence *pbrms,
475475
struct interface *ifp)
476476
{
477-
u_char family;
477+
unsigned char family;
478478

479479
family = AF_INET;
480-
if (pbrms->src)
481-
family = pbrms->src->family;
482-
483-
if (pbrms->dst)
484-
family = pbrms->dst->family;
480+
if (pbrms->family)
481+
family = pbrms->family;
485482

486483
stream_putl(s, pbrms->seqno);
487484
stream_putl(s, pbrms->ruleno);

zebra/rule_netlink.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ static int netlink_rule_update(int cmd, struct zebra_pbr_rule *rule)
7777
req.frh.family = family;
7878
req.frh.action = FR_ACT_TO_TBL;
7979

80-
if (cmd == RTM_NEWRULE)
81-
req.n.nlmsg_flags |= NLM_F_CREATE | NLM_F_EXCL;
82-
8380
/* rule's pref # */
8481
addattr32(&req.n, sizeof(req), FRA_PRIORITY, rule->priority);
8582

0 commit comments

Comments
 (0)