From 1e35b91c6a05730e9e88d1009d59362113cd128f Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Sat, 29 Aug 2015 10:31:39 +0200 Subject: [PATCH] udp6: set the destination port unconditionally. Even if the caller provides the destination address, still the port must depend on the passed 'event' value for correct delivery. Signed-off-by: Richard Cochran --- udp6.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/udp6.c b/udp6.c index fdf5799..10ff166 100644 --- a/udp6.c +++ b/udp6.c @@ -223,9 +223,6 @@ static int udp6_send(struct transport *t, struct fdarray *fda, int event, addr_buf.sin6.sin6_family = AF_INET6; addr_buf.sin6.sin6_addr = peer ? mc6_addr[MC_PDELAY] : mc6_addr[MC_PRIMARY]; - addr_buf.sin6.sin6_port = htons(event ? EVENT_PORT : - GENERAL_PORT); - if (is_link_local(&addr_buf.sin6.sin6_addr)) addr_buf.sin6.sin6_scope_id = udp6->index; @@ -233,6 +230,8 @@ static int udp6_send(struct transport *t, struct fdarray *fda, int event, addr = &addr_buf; } + addr->sin6.sin6_port = htons(event ? EVENT_PORT : GENERAL_PORT); + len += 2; /* Extend the payload by two, for UDP checksum corrections. */ cnt = sendto(fd, buf, len, 0, &addr->sa, sizeof(addr->sin6));