@@ -77,7 +77,7 @@ void fini(struct bpftuner *tuner)
7777 bpftuner_bpf_fini (tuner );
7878}
7979
80- static int set_gc_thresh3 (struct bpftuner * tuner , struct tbl_stats * stats )
80+ static int increase_thresh (struct bpftuner * tuner , struct tbl_stats * stats )
8181{
8282 char * tbl_name = stats -> family == AF_INET ? "arp_cache" : "ndisc_cache" ;
8383 /* Open raw socket for the NETLINK_ROUTE protocol */
@@ -89,6 +89,8 @@ static int set_gc_thresh3(struct bpftuner *tuner, struct tbl_stats *stats)
8989 .ndtm_family = stats -> family ,
9090 };
9191 struct nl_msg * m = NULL , * parms = NULL ;
92+ int new_gc_thresh1 = 0 ;
93+ int new_gc_thresh2 = 0 ;
9294 int new_gc_thresh3 = 0 ;
9395 int ret ;
9496
@@ -120,7 +122,19 @@ static int set_gc_thresh3(struct bpftuner *tuner, struct tbl_stats *stats)
120122 NLA_PUT_STRING (m , NDTA_NAME , tbl_name );
121123
122124 new_gc_thresh3 = BPFTUNE_GROW_BY_DELTA (stats -> max );
125+
126+ if (new_gc_thresh3 >= MAX_THRESH3 ) {
127+ new_gc_thresh3 = MAX_THRESH3 ;
128+ new_gc_thresh2 = MAX_THRESH2 ;
129+ new_gc_thresh1 = MAX_THRESH1 ;
130+ }
131+ else {
132+ new_gc_thresh2 = BPFTUNE_GROW_BY_DELTA (stats -> thresh2 );
133+ new_gc_thresh1 = BPFTUNE_GROW_BY_DELTA (stats -> thresh1 );
134+ }
123135 NLA_PUT_U32 (m , NDTA_THRESH3 , new_gc_thresh3 );
136+ NLA_PUT_U32 (m , NDTA_THRESH2 , new_gc_thresh2 );
137+ NLA_PUT_U32 (m , NDTA_THRESH1 , new_gc_thresh1 );
124138
125139 parms = nlmsg_alloc ();
126140 if (!parms ) {
@@ -152,8 +166,10 @@ static int set_gc_thresh3(struct bpftuner *tuner, struct tbl_stats *stats)
152166 stats -> dev , strerror (- ret ));
153167 } else {
154168 bpftuner_tunable_update (tuner , tunable , NEIGH_TABLE_FULL , 0 ,
155- "updated gc_thresh3 for %s table, dev '%s' (ifindex %d) from %ld to %ld\n" ,
169+ "updated thresholds for %s table, dev '%s' (ifindex %d) thresh1: %ld to %ld, thresh2: %ld to %ld, thresh3: %ld to %ld\n" ,
156170 tbl_name , stats -> dev , stats -> ifindex ,
171+ stats -> thresh1 , new_gc_thresh1 ,
172+ stats -> thresh2 , new_gc_thresh2 ,
157173 stats -> max , new_gc_thresh3 );
158174 }
159175 return ret ;
@@ -169,7 +185,7 @@ void event_handler(struct bpftuner *tuner,
169185 case NEIGH_TABLE_FULL :
170186 if (bpftune_cap_add ())
171187 return ;
172- set_gc_thresh3 (tuner , stats );
188+ increase_thresh (tuner , stats );
173189 bpftune_cap_drop ();
174190 break ;
175191 default :
0 commit comments