@@ -55,6 +55,21 @@ struct ipv6_packet {
} __packed;
extern struct ipv6_packet pkt_v6;
+static inline char *loopback_addr_str(int family)
+{
+ switch (family) {
+ case AF_INET:
+ return "127.0.0.1";
+ case AF_INET6:
+ return "::1";
+ case AF_VSOCK:
+ return "1"; /* VMADDR_CID_LOCAL */
+ default:
+ fprintf(stderr, "unsupported address family %d", family);
+ return NULL;
+ }
+}
+
int settimeo(int fd, int timeout_ms);
int start_server_str(int family, int type, const char *addr_str, __u16 port,
const struct network_helper_opts *opts);
@@ -221,7 +221,7 @@ static int start_servers(struct migrate_reuseport_test_case *test_case,
prog_fd = bpf_program__fd(skel->progs.migrate_reuseport);
make_sockaddr(test_case->family,
- test_case->family == AF_INET ? "127.0.0.1" : "::1", 0,
+ loopback_addr_str(test_case->family), 0,
&test_case->addr, &test_case->addrlen);
for (i = 0; i < NR_SERVERS; i++) {