Commit 280a827a authored by Harald Welte's avatar Harald Welte Committed by Stephen Hemminger

[NETFILTER]: Fix SO_ORIGINAL_DST, broken by earlier endianness fixes.

parent 49448a2f
...@@ -62,6 +62,14 @@ struct ip_conntrack_tuple ...@@ -62,6 +62,14 @@ struct ip_conntrack_tuple
} dst; } dst;
}; };
/* This is optimized opposed to a memset of the whole structure. Everything we
* really care about is the source/destination unions */
#define IP_CT_TUPLE_U_BLANK(tuple) \
do { \
(tuple)->src.u.all = 0; \
(tuple)->dst.u.all = 0; \
} while (0)
enum ip_conntrack_dir enum ip_conntrack_dir
{ {
IP_CT_DIR_ORIGINAL, IP_CT_DIR_ORIGINAL,
......
...@@ -1279,11 +1279,14 @@ getorigdst(struct sock *sk, int optval, void *user, int *len) ...@@ -1279,11 +1279,14 @@ getorigdst(struct sock *sk, int optval, void *user, int *len)
{ {
struct inet_opt *inet = inet_sk(sk); struct inet_opt *inet = inet_sk(sk);
struct ip_conntrack_tuple_hash *h; struct ip_conntrack_tuple_hash *h;
struct ip_conntrack_tuple tuple = { { inet->rcv_saddr, struct ip_conntrack_tuple tuple;
{ .tcp = { inet->sport } } },
{ inet->daddr, IP_CT_TUPLE_U_BLANK(&tuple);
{ .tcp = { inet->dport } }, tuple.src.ip = inet->rcv_saddr;
IPPROTO_TCP } }; tuple.src.u.tcp.port = inet->sport;
tuple.dst.ip = inet->daddr;
tuple.dst.u.tcp.port = inet->dport;
tuple.dst.protonum = IPPROTO_TCP;
/* We only do TCP at the moment: is there a better way? */ /* We only do TCP at the moment: is there a better way? */
if (strcmp(sk->sk_prot->name, "TCP")) { if (strcmp(sk->sk_prot->name, "TCP")) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment