Browse Source

Add interface deduplication in interface init function

This was triggering a bug where the TCP server fails to start.
Yann Weber 5 years ago
parent
commit
85c6e39053
1 changed files with 11 additions and 2 deletions
  1. 11
    2
      src/if.c

+ 11
- 2
src/if.c View File

@@ -282,7 +282,7 @@ if_init_all(char *ifs_name[MAX_INTERFACES], int ifs_n,
282 282
 			interface * new_ifs, int *new_ifs_n)
283 283
 {
284 284
 	struct rtnl_handle rth;
285
-	int ret = 0, i, n;
285
+	int ret = 0, i, j, n, dedup;
286 286
 
287 287
 	if (rtnl_open(&rth, 0) < 0) {
288 288
 		error("Cannot open the rtnetlink socket to talk to the kernel's "
@@ -300,7 +300,16 @@ if_init_all(char *ifs_name[MAX_INTERFACES], int ifs_n,
300 300
 		*new_ifs_n = ret;
301 301
 	} else {
302 302
 		for (i = 0, n = 0; i < ifs_n; i++) {
303
-
303
+			dedup = 0;
304
+			for(j=0; j < n; j++) {
305
+				if(strcmp(ifs_name[i], new_ifs[j].dev_name) == 0) {
306
+					dedup = 1;
307
+					break;
308
+				}
309
+			}
310
+			if(dedup) {
311
+				continue;
312
+			}
304 313
 			new_ifs[n].dev_idx = ll_name_to_index(ifs_name[n]);
305 314
 			if (!new_ifs[n].dev_idx) {
306 315
 				error("Cannot initialize the %s interface. "

Loading…
Cancel
Save