Browse Source

Solves #3 : fixing interface deduplication

Moving it in the parse_options function.
Yann Weber 5 years ago
parent
commit
679665b305
2 changed files with 13 additions and 12 deletions
  1. 1
    11
      src/if.c
  2. 12
    1
      src/netsukuku.c

+ 1
- 11
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, j, n, dedup;
285
+	int ret = 0, i, n;
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,16 +300,6 @@ 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
-			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
-			}
313 303
 			new_ifs[n].dev_idx = ll_name_to_index(ifs_name[n]);
314 304
 			if (!new_ifs[n].dev_idx) {
315 305
 				error("Cannot initialize the %s interface. "

+ 12
- 1
src/netsukuku.c View File

@@ -120,7 +120,7 @@ ntk_load_maps(void)
120 120
 
121 121
 	if (file_exist(server_opt.ext_map_file) &&
122 122
 		(me.ext_map = load_extmap(server_opt.ext_map_file, &me.cur_quadg)))
123
-		debug(DBG_NORMAL, "External map loaded");
123
+		debug(DBG_NORMAL, "External map loaded from '%s'", server_opt.ext_map_file);
124 124
 	else
125 125
 		me.ext_map = init_extmap(FAMILY_LVLS, 0);
126 126
 
@@ -387,6 +387,7 @@ void
387 387
 parse_options(int argc, char **argv)
388 388
 {
389 389
 	int c, saved_argc = argc;
390
+	int if_n, if_dup;
390 391
 	optind = 0;
391 392
 
392 393
 	while (1) {
@@ -489,6 +490,16 @@ parse_options(int argc, char **argv)
489 490
                     	if(server_opt.ifs_n+1 >= MAX_INTERFACES)
490 491
                             fatal("The maximum number of interfaces is %d",
491 492
 							MAX_INTERFACES);
493
+			if_dup = 0;
494
+			printf("IF COUNT : %d\n", server_opt.ifs_n);
495
+			for(if_n = 0; if_n < server_opt.ifs_n; if_n++) {
496
+				if(strncmp(server_opt.ifs[if_n], optarg, IFNAMSIZ-1) == 0) {
497
+					if_dup = 1;
498
+					printf("DEDUP !!!\n");
499
+					break;
500
+				}
501
+			}
502
+			if(if_dup) { break; }
492 503
 			server_opt.ifs[server_opt.ifs_n++]=xstrndup(optarg, IFNAMSIZ-1);
493 504
 			break;
494 505
 		case 'D':

Loading…
Cancel
Save