2021-10-19 12:43:28 +02:00
|
|
|
/* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
* Copyright (c) 2021 Red Hat GmbH
|
|
|
|
* Author: Stefano Brivio <sbrivio@redhat.com>
|
|
|
|
*/
|
|
|
|
|
2022-03-26 00:05:31 +01:00
|
|
|
#ifndef NETLINK_H
|
|
|
|
#define NETLINK_H
|
|
|
|
|
conf: Bind inbound ports with CAP_NET_BIND_SERVICE before isolate_user()
Even if CAP_NET_BIND_SERVICE is granted, we'll lose the capability in
the target user namespace as we isolate the process, which means
we're unable to bind to low ports at that point.
Bind inbound ports, and only those, before isolate_user(). Keep the
handling of outbound ports (for pasta mode only) after the setup of
the namespace, because that's where we'll bind them.
To this end, initialise the netlink socket for the init namespace
before isolate_user() as well, as we actually need to know the
addresses of the upstream interface before binding ports, in case
they're not explicitly passed by the user.
As we now call nl_sock_init() twice, checking its return code from
conf() twice looks a bit heavy: make it exit(), instead, as we
can't do much if we don't have netlink sockets.
While at it:
- move the v4_only && v6_only options check just after the first
option processing loop, as this is more strictly related to
option parsing proper
- update the man page, explaining that CAP_NET_BIND_SERVICE is
*not* the preferred way to bind ports, because passt and pasta
can be abused to allow other processes to make effective usage
of it. Add a note about the recommended sysctl instead
- simplify nl_sock_init_do() now that it's called once for each
case
Reported-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
2022-10-13 18:21:27 +02:00
|
|
|
void nl_sock_init(const struct ctx *c, bool ns);
|
2022-07-22 07:31:13 +02:00
|
|
|
unsigned int nl_get_ext_if(sa_family_t af);
|
2021-10-11 12:01:31 +02:00
|
|
|
void nl_route(int ns, unsigned int ifi, sa_family_t af, void *gw);
|
|
|
|
void nl_addr(int ns, unsigned int ifi, sa_family_t af,
|
2021-10-19 09:01:27 +02:00
|
|
|
void *addr, int *prefix_len, void *addr_l);
|
2021-10-14 13:05:56 +02:00
|
|
|
void nl_link(int ns, unsigned int ifi, void *mac, int up, int mtu);
|
2022-03-26 00:05:31 +01:00
|
|
|
|
|
|
|
#endif /* NETLINK_H */
|