All of lore.kernel.org
 help / color / mirror / Atom feed
* RFC: libnetfilter_queue: nfq_udp_get_payload_len() gives wrong answer
@ 2019-12-08  3:49 Duncan Roe
  2019-12-09 21:12 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 4+ messages in thread
From: Duncan Roe @ 2019-12-08  3:49 UTC (permalink / raw)
  To: Netfilter Development

nfq_udp_get_payload() correctly returns a pointer to the first data byte in a
UDP message, e.g. to "A" in the message "ASD\n".

BUT nfq_udp_get_payload_len() returns 12 for the length of the above message,
i.e. combined lengths of payload and UDP header.

I plan to do an update of the documentation in src/extra/udp.c so I can document
this behaviour then.

OR

Should I change the behaviour of nfq_udp_get_payload_len() to what one would
expect? (e.g. return 4 in the example above)

OR

Should there be a new function, say nfq_udp_get_payload_len2(), to give the
expected answer?

AND, should the new or updated function guard against returning a -ve result?
(which, being unsigned, would become a large +ve result)

Any opinions?

Cheers ... Duncan.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: RFC: libnetfilter_queue: nfq_udp_get_payload_len() gives wrong answer
  2019-12-08  3:49 RFC: libnetfilter_queue: nfq_udp_get_payload_len() gives wrong answer Duncan Roe
@ 2019-12-09 21:12 ` Pablo Neira Ayuso
  2019-12-09 23:52   ` [PATCH libnetfilter_queue] src: Fix value returned by nfq_udp_get_payload_len() Duncan Roe
  0 siblings, 1 reply; 4+ messages in thread
From: Pablo Neira Ayuso @ 2019-12-09 21:12 UTC (permalink / raw)
  To: Netfilter Development

On Sun, Dec 08, 2019 at 02:49:30PM +1100, Duncan Roe wrote:
[...]
> Should I change the behaviour of nfq_udp_get_payload_len() to what one would
> expect? (e.g. return 4 in the example above)

This option, just fix it, please.

Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH libnetfilter_queue] src: Fix value returned by nfq_udp_get_payload_len()
  2019-12-09 21:12 ` Pablo Neira Ayuso
@ 2019-12-09 23:52   ` Duncan Roe
  2019-12-11 21:59     ` Pablo Neira Ayuso
  0 siblings, 1 reply; 4+ messages in thread
From: Duncan Roe @ 2019-12-09 23:52 UTC (permalink / raw)
  To: pablo; +Cc: netfilter-devel

Updated:

 src/extra/udp.c: Remember to subtract the UDP header length

Signed-off-by: Duncan Roe <duncan_roe@optusnet.com.au>
---
 src/extra/udp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/extra/udp.c b/src/extra/udp.c
index fed23e2..eb301f2 100644
--- a/src/extra/udp.c
+++ b/src/extra/udp.c
@@ -78,7 +78,7 @@ void *nfq_udp_get_payload(struct udphdr *udph, struct pkt_buff *pktb)
 EXPORT_SYMBOL
 unsigned int nfq_udp_get_payload_len(struct udphdr *udph, struct pkt_buff *pktb)
 {
-	return pktb->tail - pktb->transport_header;
+	return pktb->tail - pktb->transport_header - sizeof(struct udphdr);
 }
 
 /**
-- 
2.14.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH libnetfilter_queue] src: Fix value returned by nfq_udp_get_payload_len()
  2019-12-09 23:52   ` [PATCH libnetfilter_queue] src: Fix value returned by nfq_udp_get_payload_len() Duncan Roe
@ 2019-12-11 21:59     ` Pablo Neira Ayuso
  0 siblings, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2019-12-11 21:59 UTC (permalink / raw)
  To: Duncan Roe; +Cc: netfilter-devel

Applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-12-11 21:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-08  3:49 RFC: libnetfilter_queue: nfq_udp_get_payload_len() gives wrong answer Duncan Roe
2019-12-09 21:12 ` Pablo Neira Ayuso
2019-12-09 23:52   ` [PATCH libnetfilter_queue] src: Fix value returned by nfq_udp_get_payload_len() Duncan Roe
2019-12-11 21:59     ` Pablo Neira Ayuso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.