aboutgitcodebugslistschat
path: root/udp.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2023-11-07 12:40:13 +1100
committerStefano Brivio <sbrivio@redhat.com>2023-11-07 09:53:35 +0100
commit0d73fa222534954af252a46ed5f7b6e95af21714 (patch)
tree16bd0b8c8c5ae5f0e8fe5e4973f1a8b3ececc47c /udp.c
parentc09d0d0f6085944a7b0e58434148702b2d5f5e9a (diff)
downloadpasst-0d73fa222534954af252a46ed5f7b6e95af21714.tar
passt-0d73fa222534954af252a46ed5f7b6e95af21714.tar.gz
passt-0d73fa222534954af252a46ed5f7b6e95af21714.tar.bz2
passt-0d73fa222534954af252a46ed5f7b6e95af21714.tar.lz
passt-0d73fa222534954af252a46ed5f7b6e95af21714.tar.xz
passt-0d73fa222534954af252a46ed5f7b6e95af21714.tar.zst
passt-0d73fa222534954af252a46ed5f7b6e95af21714.zip
udp: Clean up ref initialisation in udp_sock_init()
udp_sock_init() has a number of paths that initialise uref differently. However some of the fields are initialised the same way in all of them. Move those fields into the original initialiser to save a few lines. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'udp.c')
-rw-r--r--udp.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/udp.c b/udp.c
index cadf393..db35859 100644
--- a/udp.c
+++ b/udp.c
@@ -969,7 +969,8 @@ int udp_tap_handler(struct ctx *c, int af, const void *saddr, const void *daddr,
int udp_sock_init(const struct ctx *c, int ns, sa_family_t af,
const void *addr, const char *ifname, in_port_t port)
{
- union udp_epoll_ref uref = { .u32 = 0 };
+ union udp_epoll_ref uref = { .splice = (c->mode == MODE_PASTA),
+ .orig = true };
int s, r4 = FD_REF_MAX + 1, r6 = FD_REF_MAX + 1;
if (ns) {
@@ -980,8 +981,6 @@ int udp_sock_init(const struct ctx *c, int ns, sa_family_t af,
if ((af == AF_INET || af == AF_UNSPEC) && c->ifi4) {
uref.v6 = 0;
- uref.splice = (c->mode == MODE_PASTA);
- uref.orig = true;
if (!ns) {
r4 = s = sock_l4(c, AF_INET, IPPROTO_UDP, addr,
@@ -1001,8 +1000,6 @@ int udp_sock_init(const struct ctx *c, int ns, sa_family_t af,
if ((af == AF_INET6 || af == AF_UNSPEC) && c->ifi6) {
uref.v6 = 1;
- uref.splice = (c->mode == MODE_PASTA);
- uref.orig = true;
if (!ns) {
r6 = s = sock_l4(c, AF_INET6, IPPROTO_UDP, addr,