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
 			interface * new_ifs, int *new_ifs_n)
282
 			interface * new_ifs, int *new_ifs_n)
283
 {
283
 {
284
 	struct rtnl_handle rth;
284
 	struct rtnl_handle rth;
285
-	int ret = 0, i, j, n, dedup;
285
+	int ret = 0, i, n;
286
 
286
 
287
 	if (rtnl_open(&rth, 0) < 0) {
287
 	if (rtnl_open(&rth, 0) < 0) {
288
 		error("Cannot open the rtnetlink socket to talk to the kernel's "
288
 		error("Cannot open the rtnetlink socket to talk to the kernel's "
300
 		*new_ifs_n = ret;
300
 		*new_ifs_n = ret;
301
 	} else {
301
 	} else {
302
 		for (i = 0, n = 0; i < ifs_n; i++) {
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
 			new_ifs[n].dev_idx = ll_name_to_index(ifs_name[n]);
303
 			new_ifs[n].dev_idx = ll_name_to_index(ifs_name[n]);
314
 			if (!new_ifs[n].dev_idx) {
304
 			if (!new_ifs[n].dev_idx) {
315
 				error("Cannot initialize the %s interface. "
305
 				error("Cannot initialize the %s interface. "

+ 12
- 1
src/netsukuku.c View File

120
 
120
 
121
 	if (file_exist(server_opt.ext_map_file) &&
121
 	if (file_exist(server_opt.ext_map_file) &&
122
 		(me.ext_map = load_extmap(server_opt.ext_map_file, &me.cur_quadg)))
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
 	else
124
 	else
125
 		me.ext_map = init_extmap(FAMILY_LVLS, 0);
125
 		me.ext_map = init_extmap(FAMILY_LVLS, 0);
126
 
126
 
387
 parse_options(int argc, char **argv)
387
 parse_options(int argc, char **argv)
388
 {
388
 {
389
 	int c, saved_argc = argc;
389
 	int c, saved_argc = argc;
390
+	int if_n, if_dup;
390
 	optind = 0;
391
 	optind = 0;
391
 
392
 
392
 	while (1) {
393
 	while (1) {
489
                     	if(server_opt.ifs_n+1 >= MAX_INTERFACES)
490
                     	if(server_opt.ifs_n+1 >= MAX_INTERFACES)
490
                             fatal("The maximum number of interfaces is %d",
491
                             fatal("The maximum number of interfaces is %d",
491
 							MAX_INTERFACES);
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
 			server_opt.ifs[server_opt.ifs_n++]=xstrndup(optarg, IFNAMSIZ-1);
503
 			server_opt.ifs[server_opt.ifs_n++]=xstrndup(optarg, IFNAMSIZ-1);
493
 			break;
504
 			break;
494
 		case 'D':
505
 		case 'D':

Loading…
Cancel
Save