ifconfig_netlink.c (85e0016a9730b6540d729bfe41ddc33eaedfee69) ifconfig_netlink.c (bbad5525fabfc8dd75032dc9aaa2cc1d33e62461)
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2022 Alexander V. Chernikov <melifaro@FreeBSD.org>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 109 unchanged lines hidden (view full) ---

118 if (snl_init(ss, NETLINK_ROUTE))
119 return;
120 }
121
122 err(1, "unable to open netlink socket");
123}
124
125int
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2022 Alexander V. Chernikov <melifaro@FreeBSD.org>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 109 unchanged lines hidden (view full) ---

118 if (snl_init(ss, NETLINK_ROUTE))
119 return;
120 }
121
122 err(1, "unable to open netlink socket");
123}
124
125int
126ifconfig_wrapper_nl(if_ctx *ctx, int iscreate,
126ifconfig_nl(if_ctx *ctx, int iscreate,
127 const struct afswtch *uafp)
128{
129 struct snl_state ss = {};
130
131 nl_init_socket(&ss);
132 ctx->io_ss = &ss;
133
127 const struct afswtch *uafp)
128{
129 struct snl_state ss = {};
130
131 nl_init_socket(&ss);
132 ctx->io_ss = &ss;
133
134 int error = ifconfig(ctx, iscreate, uafp);
134 int error = ifconfig_ioctl(ctx, iscreate, uafp);
135
136 snl_free(&ss);
135
136 snl_free(&ss);
137 ctx->io_ss = NULL;
137
138 return (error);
139}
140
141struct ifa {
142 struct ifa *next;
143 uint32_t idx;
144 struct snl_parsed_addr addr;

--- 297 unchanged lines hidden (view full) ---

442
443 if (args->namesonly) {
444 if (num++ != 0)
445 printf(" ");
446 fputs(iface->link.ifla_ifname, stdout);
447 } else if (args->argc == 0)
448 status_nl(ctx, iface);
449 else
138
139 return (error);
140}
141
142struct ifa {
143 struct ifa *next;
144 uint32_t idx;
145 struct snl_parsed_addr addr;

--- 297 unchanged lines hidden (view full) ---

443
444 if (args->namesonly) {
445 if (num++ != 0)
446 printf(" ");
447 fputs(iface->link.ifla_ifname, stdout);
448 } else if (args->argc == 0)
449 status_nl(ctx, iface);
450 else
450 ifconfig(ctx, 0, args->afp);
451 ifconfig_ioctl(ctx, 0, args->afp);
451 }
452 if (args->namesonly)
453 printf("\n");
454
455 close(ctx->io_s);
456 snl_free(&ss);
457}
458
452 }
453 if (args->namesonly)
454 printf("\n");
455
456 close(ctx->io_s);
457 snl_free(&ss);
458}
459