1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (c) 2017 Petr Vorel <pvorel@suse.cz>
4 * Copyright (c) 1997-2015 Red Hat, Inc. All rights reserved.
5 * Copyright (c) 2011-2013 Rich Felker, et al.
6 */
7
8 #include <arpa/inet.h>
9 #include <arpa/nameser.h>
10 #include <assert.h>
11 #include <errno.h>
12 #include <linux/rtnetlink.h>
13 #include <net/if.h>
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <string.h>
17 #include <time.h>
18 #include <stdarg.h>
19
20
21 #define TST_NO_DEFAULT_MAIN
22 #include "tst_test.h"
23
24 #include "tst_net.h"
25
26 #define BASE_IPV4_PREFIX 8
27 #define BASE_IPV6_PREFIX 16
28
29 #define MAX_IPV4_PREFIX 32
30 #define MAX_IPV6_PREFIX 128
31
32 #define DEFAULT_IPV4_UNUSED_PART1 10
33 #define DEFAULT_IPV6_UNUSED_PART1 0xfd
34
35 #define DEFAULT_IPV4_UNUSED_PART2 23
36 #define DEFAULT_IPV6_UNUSED_PART2 0x23
37
38 struct ltp_net_variables {
39 char *ipv4_lbroadcast;
40 char *ipv4_rbroadcast;
41 char *ipv4_lnetmask;
42 char *ipv4_rnetmask;
43 char *ipv4_lnetwork;
44 char *ipv4_rnetwork;
45 char *lhost_ipv4_host;
46 char *rhost_ipv4_host;
47 char *ipv6_lnetmask;
48 char *ipv6_rnetmask;
49 char *ipv6_lnetwork;
50 char *ipv6_rnetwork;
51 char *lhost_ipv6_host;
52 char *rhost_ipv6_host;
53 char *ipv4_net16_unused;
54 char *ipv6_net32_unused;
55 };
56 static struct ltp_net_variables vars;
57
usage(const char * cmd)58 static void usage(const char *cmd)
59 {
60 fprintf(stderr, "USAGE:\n"
61 "%s IP_LHOST[/PREFIX] IP_RHOST[/PREFIX]\n"
62 "%s -h\n\n"
63 "Exported variables:\n"
64 "IPV4_LBROADCAST: IPv4 broadcast of the local host\n"
65 "IPV4_RBROADCAST: IPv4 broadcast of the remote host\n"
66 "IPV4_LNETMASK: IPv4 netmask of the local host\n"
67 "IPV4_RNETMASK: IPv4 netmask of the remote host\n"
68 "IPV4_LNETWORK: IPv4 network part of IPV4_LHOST\n"
69 "IPV4_RNETWORK: IPv4 network part of IPV4_RHOST\n"
70 "LHOST_IPV4_HOST IPv4 host part of IPV4_LHOST\n"
71 "RHOST_IPV4_HOST IPv4 host part of IPV4_RHOST\n"
72 "IPV4_NET16_UNUSED: IPv4 16 bit unused subnet\n"
73 "IPV6_LNETMASK: IPv6 netmask of the local host\n"
74 "IPV6_RNETMASK: IPv6 netmask of the remote host\n"
75 "IPV6_LNETWORK: IPv6 network part of IPV6_LHOST\n"
76 "IPV6_RNETWORK: IPv6 network part of IPV6_LHOST\n"
77 "LHOST_IPV6_HOST: IPv6 unique part of IPV6_LHOST\n"
78 "RHOST_IPV6_HOST: IPv6 unique part of IPV6_RHOST\n"
79 "IPV6_NET32_UNUSED: IPv6 32 bit unused subnet\n\n"
80 "NOTE: Prefixes, ifaces and lhosts are expected to be set by tst_net_iface_prefix.\n"
81 "OPTIONS:\n"
82 "-h this help\n",
83 cmd, cmd);
84 }
85
86 /*
87 * Function prefix2mask is from ipcalc project, ipcalc.c.
88 */
prefix2mask(unsigned int prefix)89 static struct in_addr prefix2mask(unsigned int prefix)
90 {
91 struct in_addr mask;
92
93 memset(&mask, 0x0, sizeof(mask));
94
95 if (prefix)
96 mask.s_addr = htonl(~((1 << (32 - prefix)) - 1));
97 else
98 mask.s_addr = htonl(0);
99
100 return mask;
101 }
102
103 /*
104 * Function calc_network is based on ipcalc project,
105 * calc_network/ipcalc.c.
106 */
calc_network(const struct in_addr * ip,struct in_addr * mask)107 static struct in_addr calc_network(const struct in_addr *ip,
108 struct in_addr *mask)
109 {
110 struct in_addr network;
111
112 memset(&network, 0, sizeof(network));
113
114 network.s_addr = ip->s_addr & mask->s_addr;
115 return network;
116 }
117
is_in_subnet_ipv4(const struct in_addr * network,const struct in_addr * mask,const struct in_addr * ip)118 static int is_in_subnet_ipv4(const struct in_addr *network,
119 const struct in_addr *mask, const struct in_addr *ip)
120 {
121 return (ip->s_addr & mask->s_addr) ==
122 (network->s_addr & mask->s_addr);
123 }
124
is_in_subnet_ipv6(const struct in6_addr * network,const struct in6_addr * mask,const struct in6_addr * ip6)125 static int is_in_subnet_ipv6(const struct in6_addr *network,
126 const struct in6_addr *mask, const struct in6_addr *ip6)
127 {
128 unsigned int i;
129
130 for (i = 0; i < sizeof(struct in6_addr) / sizeof(int); i++) {
131 if (((((int *) ip6)[i] & ((int *) mask)[i])) !=
132 (((int *) network)[i] & ((int *) mask)[i]))
133 return 0;
134 }
135 return 1;
136 }
137
138 /*
139 * Function get_ipv4_netmask uses code from calc_network, which is from
140 * ipcalc project, ipcalc.c.
141 */
get_ipv4_netmask(unsigned int prefix)142 static char *get_ipv4_netmask(unsigned int prefix)
143 {
144 char buf[INET_ADDRSTRLEN];
145 struct in_addr mask = prefix2mask(prefix);
146
147 if (prefix > MAX_IPV4_PREFIX)
148 return NULL;
149
150 if (!inet_ntop(AF_INET, &mask, buf, sizeof(buf)))
151 tst_brk_comment("error calculating IPv4 address");
152
153 return strdup(buf);
154 }
155
156 /*
157 * Function get_ipv4_netmask uses code from ipv6_prefix_to_mask and
158 * ipv6_mask_to_str, which are from ipcalc project, ipcalc.c.
159 */
get_ipv6_netmask(unsigned int prefix)160 static char *get_ipv6_netmask(unsigned int prefix)
161 {
162 struct in6_addr in6;
163 char buf[128];
164 int i, j;
165
166 if (prefix > MAX_IPV6_PREFIX)
167 return NULL;
168
169 memset(&in6, 0x0, sizeof(in6));
170 for (i = prefix, j = 0; i > 0; i -= 8, j++) {
171 if (i >= 8)
172 in6.s6_addr[j] = 0xff;
173 else
174 in6.s6_addr[j] = (unsigned long)(0xffU << (8 - i));
175 }
176
177 if (!inet_ntop(AF_INET6, &in6, buf, sizeof(buf)))
178 tst_brk_comment("error calculating IPv6 address");
179
180 return strdup(buf);
181 }
182
183 /*
184 * Function get_ipv4_broadcast uses code from calc_broadcast, which is from
185 * ipcalc project, ipcalc.c.
186 */
get_ipv4_broadcast(struct in_addr ip,unsigned int prefix)187 static char *get_ipv4_broadcast(struct in_addr ip, unsigned int prefix)
188 {
189 struct in_addr mask = prefix2mask(prefix);
190 struct in_addr broadcast;
191 char buf[INET_ADDRSTRLEN];
192
193 memset(&broadcast, 0, sizeof(broadcast));
194 broadcast.s_addr = (ip.s_addr & mask.s_addr) | ~mask.s_addr;
195
196 if (!inet_ntop(AF_INET, &broadcast, buf, sizeof(buf)))
197 tst_brk_comment("error calculating IPv4 address");
198
199 return strdup(buf);
200 }
201
202 /*
203 * For unused network we use
204 * DEFAULT_IPV4_UNUSED_PART1:DEFAULT_IPV4_UNUSED_PART2 or
205 * {DEFAULT_IPV4_UNUSED_PART1}.XY, when there is a collision with IP.
206 */
get_ipv4_net16_unused(const struct in_addr * ip,unsigned int prefix)207 static char *get_ipv4_net16_unused(const struct in_addr *ip,
208 unsigned int prefix)
209 {
210 struct in_addr mask, network;
211 char buf[132], net_unused[128];
212
213 mask = prefix2mask(prefix);
214 network = calc_network(ip, &mask);
215
216 sprintf(net_unused, "%d.%d", DEFAULT_IPV4_UNUSED_PART1,
217 DEFAULT_IPV4_UNUSED_PART2);
218 sprintf(buf, "%s.0.0", net_unused);
219
220 get_in_addr(buf, &network);
221
222 if (!is_in_subnet_ipv4(ip, &mask, &network))
223 return strdup(net_unused);
224
225 srand(time(NULL));
226
227 /* try to randomize second group */
228 sprintf(net_unused, "%d.%d", DEFAULT_IPV4_UNUSED_PART1,
229 (rand() % 128) + (((ip->s_addr >> 8) & 0xff) < 128 ? 128 : 0));
230 sprintf(buf, "%s.0.0", net_unused);
231
232 get_in_addr(buf, &network);
233
234 if (!is_in_subnet_ipv4(ip, &mask, &network))
235 return strdup(net_unused);
236
237 /* try to randomize first group */
238 sprintf(net_unused, "%d.%d", (rand() % 128) + (((ip->s_addr) & 0xff)
239 < 128 ? 128 : 0), DEFAULT_IPV4_UNUSED_PART2);
240 sprintf(buf, "%s.0.0", net_unused);
241
242 get_in_addr(buf, &network);
243
244 if (!is_in_subnet_ipv4(ip, &mask, &network))
245 return strdup(net_unused);
246
247 return NULL;
248 }
249
250 /*
251 * Function get_ipv6_net32_unused is inspired by ipcalc project,
252 * get_ipv6_info/ipcalc.c.
253 *
254 * For unused network we use DEFAULT_IPV6_UNUSED_PART1:DEFAULT_IPV6_UNUSED_PART2
255 * if no collision with existing IP range.
256 * Otherwise we try to use
257 * {DEFAULT_IPV6_UNUSED_PART1}XY:DEFAULT_IPV6_UNUSED_PART2 or
258 * XY:DEFAULT_IPV6_UNUSED_PART2.
259 */
get_ipv6_net32_unused(const struct in6_addr * ip6,unsigned int prefix)260 static char *get_ipv6_net32_unused(const struct in6_addr *ip6,
261 unsigned int prefix)
262 {
263 int i, j;
264 struct in6_addr mask, network;
265 char buf[130], net_unused[128];
266
267 memset(&mask, 0x0, sizeof(mask));
268
269 if (prefix > 128)
270 return NULL;
271
272
273 for (i = prefix, j = 0; i > 0; i -= 8, j++) {
274 if (i >= 8)
275 mask.s6_addr[j] = 0xff;
276 else
277 mask.s6_addr[j] = (unsigned long)(0xffU << (8 - i));
278 }
279
280 sprintf(net_unused, "%x:%x", 256 * DEFAULT_IPV6_UNUSED_PART1,
281 DEFAULT_IPV6_UNUSED_PART2);
282 sprintf(buf, "%s::", net_unused);
283
284 get_in6_addr(buf, &network);
285
286 if (!is_in_subnet_ipv6(ip6, &mask, &network))
287 return strdup(net_unused);
288
289 srand(time(NULL));
290
291 /* try to randomize second group */
292 sprintf(net_unused, "%x:%x", 256 * DEFAULT_IPV6_UNUSED_PART1 +
293 (rand() % 128) + (ip6->s6_addr[1] < 128 ? 128 : 0),
294 DEFAULT_IPV6_UNUSED_PART2);
295 sprintf(buf, "%s::", net_unused);
296
297 get_in6_addr(buf, &network);
298
299 if (!is_in_subnet_ipv6(ip6, &mask, &network))
300 return strdup(net_unused);
301
302 /* try to randomize first group */
303 sprintf(net_unused, "%x:%x",
304 256 * (rand() % 128) + (256 * ip6->s6_addr[0] < 128 ?
305 128 : 0), DEFAULT_IPV6_UNUSED_PART2);
306 sprintf(buf, "%s::", net_unused);
307
308 get_in6_addr(buf, &network);
309
310 if (!is_in_subnet_ipv6(ip6, &mask, &network))
311 return strdup(net_unused);
312
313 return NULL;
314 }
315
316 /*
317 * Function get_ipv6_network is based on musl libc project,
318 * inet_ntop/inet_ntop.c.
319 */
get_ipv6_network(const unsigned char * a0,unsigned int prefix)320 static char *get_ipv6_network(const unsigned char *a0, unsigned int prefix)
321 {
322 const unsigned char *a = a0;
323 unsigned int i, j, max, best, border = 0;
324 char buf[100];
325 char ret[100];
326 char tmp[100];
327 char *p_ret = ret;
328 char *p_tmp = tmp;
329 size_t offset;
330
331 if (prefix > MAX_IPV6_PREFIX)
332 return NULL;
333
334 if (prefix == MAX_IPV6_PREFIX)
335 return strdup("\0");
336
337 snprintf(buf, sizeof(buf),
338 "%x:%x:%x:%x:%x:%x:%x:%x",
339 256 * a[0] + a[1], 256 * a[2] + a[3],
340 256 * a[4] + a[5], 256 * a[6] + a[7],
341 256 * a[8] + a[9], 256 * a[10] + a[11],
342 256 * a[12] + a[13], 256 * a[14] + a[15]);
343
344 for (i = 0; i < 8; i++) {
345 if (i < prefix >> 4) {
346 border += sprintf(p_tmp, "%x", 256 * a[2 * i] +
347 a[2 * i + 1]);
348 if (i > 0)
349 border++;
350 }
351
352 if (i >= prefix >> 4)
353 break;
354
355 /* ':' only if no leading in host or ending in net */
356 if (i > 0)
357 *p_ret++ = ':';
358
359 offset = sprintf(p_ret, "%x", 256 * a[2 * i] + a[2 * i + 1]);
360 p_ret += offset;
361 }
362
363 *p_ret = '\0';
364
365 /* Find longest /(^0|:)[:0]{2,}/ */
366 for (i = best = 0, max = 2; buf[i]; i++) {
367 if (i && buf[i] != ':')
368 continue;
369 j = strspn(buf + i, ":0");
370
371 if (j > max)
372 best = i, max = j;
373 }
374
375 size_t length = strlen(ret);
376 size_t best_end = best + max - 1;
377
378 if (max > 2 && best < border) {
379 p_ret = ret;
380 /* Replace longest /(^0|:)[:0]{2,}/ with "::" */
381 if (best == 0 && best_end >= border) {
382 /* zeros in whole net part or continue to host */
383 ret[0] = ':';
384 ret[1] = '\0';
385 } else if (best == 0 && best_end < border) {
386 /* zeros on beginning, not whole part */
387 ret[0] = ':';
388 memmove(p_ret + 1, p_ret + best_end, border - best_end
389 + 1);
390 } else if (best > 0 && best_end >= border) {
391 /*
392 * zeros not from beginning to border or continue to
393 * host
394 */
395 ret[best] = ':';
396 ret[best + 1] = '\0';
397 } else {
398 /* zeros somewhere in the middle */
399 ret[best] = ':';
400 memmove(p_ret + best + 1, p_ret + best_end,
401 border - best + 1);
402 }
403 }
404
405 if (length < INET6_ADDRSTRLEN)
406 return strdup(ret);
407
408 return NULL;
409 }
410
411 /*
412 * Strip host part from ip address.
413 */
get_host_from_ip(const char * ip,const char * net)414 static char *get_host_from_ip(const char *ip, const char *net)
415 {
416 if (ip == NULL || net == NULL)
417 return NULL;
418
419 char *result = strstr(ip, net);
420
421 if (!result || result != ip)
422 return NULL;
423
424 char *buf = strdup(ip);
425 unsigned int index = strlen(net);
426 int len;
427
428 /* prefix < 8 (IPv4) or 128 (IPv6) */
429 if (index == strlen(ip))
430 return strdup("\0");
431
432 /* prefix > 0 && prefix < 32 (IPv4) or 128 (IPv6) */
433 if (index > 0 && index < strlen(ip)) {
434 len = strlen(ip) - index - 1;
435 assert(ip[index] == ':' || ip[index] == '.');
436 memmove(buf, buf + index + 1, len);
437 buf[len] = '\0';
438 }
439
440 return buf;
441 }
442
check_prefix_range(unsigned int prefix,int is_ipv6,int is_lhost)443 static void check_prefix_range(unsigned int prefix, int is_ipv6, int is_lhost)
444 {
445 unsigned int base_prefix = is_ipv6 ? BASE_IPV6_PREFIX :
446 BASE_IPV4_PREFIX;
447 unsigned int max_prefix = is_ipv6 ? MAX_IPV6_PREFIX : MAX_IPV4_PREFIX;
448
449 if (prefix < base_prefix || (is_ipv6 && prefix == 128) ||
450 (!is_ipv6 && prefix == 32))
451 tst_res_comment(TWARN,
452 "prefix %d for %s will be unsuitable for some stress tests which need %s variable. To avoid this use prefix >= %d and prefix < %d.",
453 prefix, is_ipv6 ? "IPv6" : "IPv4",
454 is_ipv6 ?
455 (is_lhost ? "IPV6_LNETWORK" : "IPV6_RNETWORK") :
456 (is_lhost ? "IPV4_LNETWORK" : "IPV4_RNETWORK"),
457 base_prefix, max_prefix);
458 }
459
get_ipv4_network(int ip,unsigned int prefix)460 static char *get_ipv4_network(int ip, unsigned int prefix)
461 {
462 char buf[INET_ADDRSTRLEN];
463 char *p_buf = buf;
464 unsigned char byte;
465 unsigned int i;
466
467 ip = htonl(ip);
468
469 if (prefix > MAX_IPV4_PREFIX)
470 return NULL;
471
472 if (prefix == MAX_IPV4_PREFIX)
473 return strdup("\0");
474
475 prefix &= MAX_IPV4_PREFIX - 8;
476
477 for (i = prefix; i > 0; i -= 8) {
478 byte = (ip >> i) & 0xff;
479 sprintf(p_buf, i < prefix ? ".%d" : "%d", byte);
480 p_buf += strlen(p_buf);
481 }
482
483 return strdup(buf);
484 }
485
486 /*
487 * Round down prefix.
488 */
round_down_prefix(unsigned int prefix,int is_ipv6)489 static int round_down_prefix(unsigned int prefix, int is_ipv6)
490 {
491 unsigned int base_prefix = is_ipv6 ? BASE_IPV6_PREFIX :
492 BASE_IPV4_PREFIX;
493
494 return prefix / base_prefix * base_prefix;
495 }
496
get_ipv4_info(const char * lip_str,const char * rip_str,int lprefix,int rprefix)497 static void get_ipv4_info(const char *lip_str, const char *rip_str, int lprefix,
498 int rprefix)
499 {
500 struct in_addr lip, rip;
501 int lprefix_round, rprefix_round;
502
503 lprefix_round = round_down_prefix(lprefix, 0);
504 rprefix_round = round_down_prefix(rprefix, 0);
505
506 get_in_addr(lip_str, &lip);
507 get_in_addr(rip_str, &rip);
508
509 vars.ipv4_lbroadcast = get_ipv4_broadcast(lip, lprefix);
510 vars.ipv4_rbroadcast = get_ipv4_broadcast(rip, rprefix);
511
512 vars.ipv4_lnetmask = get_ipv4_netmask(lprefix);
513 vars.ipv4_rnetmask = get_ipv4_netmask(rprefix);
514
515 vars.ipv4_lnetwork = get_ipv4_network(lip.s_addr, lprefix_round);
516 vars.ipv4_rnetwork = get_ipv4_network(rip.s_addr, rprefix_round);
517
518 vars.lhost_ipv4_host = get_host_from_ip(lip_str, vars.ipv4_lnetwork);
519 vars.rhost_ipv4_host = get_host_from_ip(rip_str, vars.ipv4_rnetwork);
520
521 vars.ipv4_net16_unused = get_ipv4_net16_unused(&lip, lprefix_round);
522 }
523
get_ipv6_info(const char * lip_str,const char * rip_str,int lprefix,int rprefix)524 static void get_ipv6_info(const char *lip_str, const char *rip_str,
525 int lprefix, int rprefix)
526 {
527 struct in6_addr lip, rip;
528 int lprefix_round, rprefix_round;
529
530 lprefix_round = round_down_prefix(lprefix, 1);
531 rprefix_round = round_down_prefix(rprefix, 1);
532
533 get_in6_addr(lip_str, &lip);
534 get_in6_addr(rip_str, &rip);
535
536 vars.ipv6_lnetmask = get_ipv6_netmask(lprefix);
537 vars.ipv6_rnetmask = get_ipv6_netmask(rprefix);
538
539 vars.ipv6_lnetwork = get_ipv6_network(lip.s6_addr, lprefix_round);
540 vars.ipv6_rnetwork = get_ipv6_network(rip.s6_addr, rprefix_round);
541
542 vars.lhost_ipv6_host = get_host_from_ip(lip_str, vars.ipv6_lnetwork);
543 vars.rhost_ipv6_host = get_host_from_ip(rip_str, vars.ipv6_rnetwork);
544
545 vars.ipv6_net32_unused = get_ipv6_net32_unused(&lip, lprefix_round);
546 }
547
print_vars(int is_ipv6)548 static void print_vars(int is_ipv6)
549 {
550 if (is_ipv6) {
551 print_svar("IPV6_LNETMASK", vars.ipv6_lnetmask);
552 print_svar_change("IPV6_RNETMASK", vars.ipv6_rnetmask);
553 print_svar("IPV6_LNETWORK", vars.ipv6_lnetwork);
554 print_svar("IPV6_RNETWORK", vars.ipv6_rnetwork);
555 print_svar("LHOST_IPV6_HOST", vars.lhost_ipv6_host);
556 print_svar("RHOST_IPV6_HOST", vars.rhost_ipv6_host);
557 print_svar("IPV6_NET32_UNUSED", vars.ipv6_net32_unused);
558 } else {
559 print_svar("IPV4_LBROADCAST", vars.ipv4_lbroadcast);
560 print_svar_change("IPV4_RBROADCAST", vars.ipv4_rbroadcast);
561 print_svar("IPV4_LNETMASK", vars.ipv4_lnetmask);
562 print_svar_change("IPV4_RNETMASK", vars.ipv4_rnetmask);
563 print_svar("IPV4_LNETWORK", vars.ipv4_lnetwork);
564 print_svar("IPV4_RNETWORK", vars.ipv4_rnetwork);
565 print_svar("LHOST_IPV4_HOST", vars.lhost_ipv4_host);
566 print_svar("RHOST_IPV4_HOST", vars.rhost_ipv4_host);
567 print_svar("IPV4_NET16_UNUSED", vars.ipv4_net16_unused);
568 }
569 }
570
main(int argc,char * argv[])571 int main(int argc, char *argv[])
572 {
573 char *lip_str = NULL, *rip_str = NULL;
574 int is_ipv6, lprefix, rprefix, tmp;
575 struct in_addr ip;
576 struct in6_addr ip6;
577
578 int is_usage = argc > 1 && (!strcmp(argv[1], "-h") ||
579 !strcmp(argv[1], "--help"));
580 if (argc < 3 || is_usage) {
581 usage(argv[0]);
582 exit(is_usage ? EXIT_SUCCESS : EXIT_FAILURE);
583 }
584
585 lip_str = argv[1];
586 rip_str = argv[2];
587
588 is_ipv6 = !!strchr(lip_str, ':');
589 lprefix = get_prefix(lip_str, is_ipv6);
590 rprefix = get_prefix(rip_str, is_ipv6);
591
592 if (is_ipv6)
593 get_in6_addr(lip_str, &ip6);
594 else
595 get_in_addr(lip_str, &ip);
596
597 tmp = !!strchr(rip_str, ':');
598 if (tmp)
599 get_in6_addr(rip_str, &ip6);
600 else
601 get_in_addr(rip_str, &ip);
602
603 if (is_ipv6 != tmp)
604 tst_brk_comment("mixed IPv4 and IPv6 addresses ('%s', '%s')",
605 lip_str, rip_str);
606
607 check_prefix_range(lprefix, is_ipv6, 1);
608 check_prefix_range(rprefix, is_ipv6, 0);
609
610 if (!strcmp(lip_str, rip_str))
611 tst_brk_comment("IP addresses cannot be the same ('%s', '%s')",
612 lip_str, rip_str);
613
614 if (is_ipv6)
615 get_ipv6_info(lip_str, rip_str, lprefix, rprefix);
616 else
617 get_ipv4_info(lip_str, rip_str, lprefix, rprefix);
618
619 print_vars(is_ipv6);
620
621 exit(EXIT_SUCCESS);
622 }
623