@@ -279,6 +279,13 @@ static void bgp_pbr_policyroute_add_to_zebra_unit(struct bgp *bgp,
279
279
280
280
static void bgp_pbr_dump_entry (struct bgp_pbr_filter * bpf , bool add );
281
281
282
+ static void bgp_pbr_val_mask_free (void * arg )
283
+ {
284
+ struct bgp_pbr_val_mask * pbr_val_mask = arg ;
285
+
286
+ XFREE (MTYPE_PBR_VALMASK , pbr_val_mask );
287
+ }
288
+
282
289
static bool bgp_pbr_extract_enumerate_unary_opposite (
283
290
uint8_t unary_operator ,
284
291
struct bgp_pbr_val_mask * and_valmask ,
@@ -2130,17 +2137,6 @@ static void bgp_pbr_policyroute_remove_from_zebra(
2130
2137
bgp , path , bpf , bpof , FLOWSPEC_ICMP_TYPE );
2131
2138
else
2132
2139
bgp_pbr_policyroute_remove_from_zebra_unit (bgp , path , bpf );
2133
- /* flush bpof */
2134
- if (bpof -> tcpflags )
2135
- list_delete_all_node (bpof -> tcpflags );
2136
- if (bpof -> dscp )
2137
- list_delete_all_node (bpof -> dscp );
2138
- if (bpof -> flowlabel )
2139
- list_delete_all_node (bpof -> flowlabel );
2140
- if (bpof -> pkt_len )
2141
- list_delete_all_node (bpof -> pkt_len );
2142
- if (bpof -> fragment )
2143
- list_delete_all_node (bpof -> fragment );
2144
2140
}
2145
2141
2146
2142
static void bgp_pbr_dump_entry (struct bgp_pbr_filter * bpf , bool add )
@@ -2625,19 +2621,6 @@ static void bgp_pbr_policyroute_add_to_zebra(struct bgp *bgp,
2625
2621
bgp , path , bpf , bpof , nh , rate , FLOWSPEC_ICMP_TYPE );
2626
2622
else
2627
2623
bgp_pbr_policyroute_add_to_zebra_unit (bgp , path , bpf , nh , rate );
2628
- /* flush bpof */
2629
- if (bpof -> tcpflags )
2630
- list_delete_all_node (bpof -> tcpflags );
2631
- if (bpof -> dscp )
2632
- list_delete_all_node (bpof -> dscp );
2633
- if (bpof -> pkt_len )
2634
- list_delete_all_node (bpof -> pkt_len );
2635
- if (bpof -> fragment )
2636
- list_delete_all_node (bpof -> fragment );
2637
- if (bpof -> icmp_type )
2638
- list_delete_all_node (bpof -> icmp_type );
2639
- if (bpof -> icmp_code )
2640
- list_delete_all_node (bpof -> icmp_code );
2641
2624
}
2642
2625
2643
2626
static void bgp_pbr_handle_entry (struct bgp * bgp , struct bgp_path_info * path ,
@@ -2703,6 +2686,7 @@ static void bgp_pbr_handle_entry(struct bgp *bgp, struct bgp_path_info *path,
2703
2686
srcp = & range ;
2704
2687
else {
2705
2688
bpof .icmp_type = list_new ();
2689
+ bpof .icmp_type -> del = bgp_pbr_val_mask_free ;
2706
2690
bgp_pbr_extract_enumerate (api -> icmp_type ,
2707
2691
api -> match_icmp_type_num ,
2708
2692
OPERATOR_UNARY_OR ,
@@ -2718,6 +2702,7 @@ static void bgp_pbr_handle_entry(struct bgp *bgp, struct bgp_path_info *path,
2718
2702
dstp = & range_icmp_code ;
2719
2703
else {
2720
2704
bpof .icmp_code = list_new ();
2705
+ bpof .icmp_code -> del = bgp_pbr_val_mask_free ;
2721
2706
bgp_pbr_extract_enumerate (api -> icmp_code ,
2722
2707
api -> match_icmp_code_num ,
2723
2708
OPERATOR_UNARY_OR ,
@@ -2738,6 +2723,7 @@ static void bgp_pbr_handle_entry(struct bgp *bgp, struct bgp_path_info *path,
2738
2723
FLOWSPEC_TCP_FLAGS );
2739
2724
} else if (kind_enum == OPERATOR_UNARY_OR ) {
2740
2725
bpof .tcpflags = list_new ();
2726
+ bpof .tcpflags -> del = bgp_pbr_val_mask_free ;
2741
2727
bgp_pbr_extract_enumerate (api -> tcpflags ,
2742
2728
api -> match_tcpflags_num ,
2743
2729
OPERATOR_UNARY_OR ,
@@ -2755,6 +2741,7 @@ static void bgp_pbr_handle_entry(struct bgp *bgp, struct bgp_path_info *path,
2755
2741
bpf .pkt_len = & pkt_len ;
2756
2742
else {
2757
2743
bpof .pkt_len = list_new ();
2744
+ bpof .pkt_len -> del = bgp_pbr_val_mask_free ;
2758
2745
bgp_pbr_extract_enumerate (api -> packet_length ,
2759
2746
api -> match_packet_length_num ,
2760
2747
OPERATOR_UNARY_OR ,
@@ -2764,12 +2751,14 @@ static void bgp_pbr_handle_entry(struct bgp *bgp, struct bgp_path_info *path,
2764
2751
}
2765
2752
if (api -> match_dscp_num >= 1 ) {
2766
2753
bpof .dscp = list_new ();
2754
+ bpof .dscp -> del = bgp_pbr_val_mask_free ;
2767
2755
bgp_pbr_extract_enumerate (api -> dscp , api -> match_dscp_num ,
2768
2756
OPERATOR_UNARY_OR ,
2769
2757
bpof .dscp , FLOWSPEC_DSCP );
2770
2758
}
2771
2759
if (api -> match_fragment_num ) {
2772
2760
bpof .fragment = list_new ();
2761
+ bpof .fragment -> del = bgp_pbr_val_mask_free ;
2773
2762
bgp_pbr_extract_enumerate (api -> fragment ,
2774
2763
api -> match_fragment_num ,
2775
2764
OPERATOR_UNARY_OR ,
@@ -2785,7 +2774,7 @@ static void bgp_pbr_handle_entry(struct bgp *bgp, struct bgp_path_info *path,
2785
2774
bpf .family = afi2family (api -> afi );
2786
2775
if (!add ) {
2787
2776
bgp_pbr_policyroute_remove_from_zebra (bgp , path , & bpf , & bpof );
2788
- return ;
2777
+ goto flush_bpof ;
2789
2778
}
2790
2779
/* no action for add = true */
2791
2780
for (i = 0 ; i < api -> action_num ; i ++ ) {
@@ -2863,6 +2852,22 @@ static void bgp_pbr_handle_entry(struct bgp *bgp, struct bgp_path_info *path,
2863
2852
if (continue_loop == 0 )
2864
2853
break ;
2865
2854
}
2855
+
2856
+ flush_bpof :
2857
+ if (bpof .tcpflags )
2858
+ list_delete (& bpof .tcpflags );
2859
+ if (bpof .dscp )
2860
+ list_delete (& bpof .dscp );
2861
+ if (bpof .flowlabel )
2862
+ list_delete (& bpof .flowlabel );
2863
+ if (bpof .pkt_len )
2864
+ list_delete (& bpof .pkt_len );
2865
+ if (bpof .fragment )
2866
+ list_delete (& bpof .fragment );
2867
+ if (bpof .icmp_type )
2868
+ list_delete (& bpof .icmp_type );
2869
+ if (bpof .icmp_code )
2870
+ list_delete (& bpof .icmp_code );
2866
2871
}
2867
2872
2868
2873
void bgp_pbr_update_entry (struct bgp * bgp , const struct prefix * p ,
0 commit comments