eff3bcb245
nl_addr() can perform three quite different operations based on the 'op' parameter, each of which uses a different subset of the parameters. Split them up into a function for each operation. This does use more lines of code, but the overlap wasn't that great, and the separated logic is much easier to follow. It's also clearer in the callers what we expect the netlink operations to do, and what information it uses. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> [sbrivio: Minor formatting fixes in pasta_ns_conf()] Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
27 lines
853 B
C
27 lines
853 B
C
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
* Copyright (c) 2021 Red Hat GmbH
|
|
* Author: Stefano Brivio <sbrivio@redhat.com>
|
|
*/
|
|
|
|
#ifndef NETLINK_H
|
|
#define NETLINK_H
|
|
|
|
enum nl_op {
|
|
NL_GET,
|
|
NL_SET,
|
|
NL_DUP,
|
|
};
|
|
|
|
void nl_sock_init(const struct ctx *c, bool ns);
|
|
unsigned int nl_get_ext_if(sa_family_t af);
|
|
void nl_route(enum nl_op op, unsigned int ifi, unsigned int ifi_ns,
|
|
sa_family_t af, void *gw);
|
|
void nl_addr_get(unsigned int ifi, sa_family_t af, void *addr,
|
|
int *prefix_len, void *addr_l);
|
|
void nl_addr_set(unsigned int ifi, sa_family_t af, void *addr, int prefix_len);
|
|
void nl_addr_dup(unsigned int ifi, unsigned int ifi_ns, sa_family_t af);
|
|
void nl_link_get_mac(int ns, unsigned int ifi, void *mac);
|
|
void nl_link_set_mac(int ns, unsigned int ifi, void *mac);
|
|
void nl_link_up(int ns, unsigned int ifi, int mtu);
|
|
|
|
#endif /* NETLINK_H */
|