net: Use sk_mark for routing lookup in more places
authorAtis Elsts <atis@mikrotik.com>
Thu, 1 Oct 2009 22:16:49 +0000 (15:16 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 1 Oct 2009 22:16:49 +0000 (15:16 -0700)
This patch against v2.6.31 adds support for route lookup using sk_mark in some
more places. The benefits from this patch are the following.
First, SO_MARK option now has effect on UDP sockets too.
Second, ip_queue_xmit() and inet_sk_rebuild_header() could fail to do routing
lookup correctly if TCP sockets with SO_MARK were used.

Signed-off-by: Atis Elsts <atis@mikrotik.com>
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
net/ipv4/af_inet.c
net/ipv4/ip_output.c
net/ipv4/udp.c

index 58c4b0f7c4aae333e5767e331b84bebbe4845bd0..57737b8d1711a9348ca7000963eb4e65f3680db7 100644 (file)
@@ -1119,6 +1119,7 @@ int inet_sk_rebuild_header(struct sock *sk)
 {
        struct flowi fl = {
                .oif = sk->sk_bound_dev_if,
+               .mark = sk->sk_mark,
                .nl_u = {
                        .ip4_u = {
                                .daddr  = daddr,
index 9fe5d7b81580fe8b8768b03e4fff05f9059d14c6..f9895180f4818cf73f55bd1183c07dfbf852477e 100644 (file)
@@ -335,6 +335,7 @@ int ip_queue_xmit(struct sk_buff *skb, int ipfragok)
 
                {
                        struct flowi fl = { .oif = sk->sk_bound_dev_if,
+                                           .mark = sk->sk_mark,
                                            .nl_u = { .ip4_u =
                                                      { .daddr = daddr,
                                                        .saddr = inet->saddr,
index 3326aff65906e9c943fd5d035845a664af6dae48..6ec6a8a4a224236acae5393d997727c7804c07cb 100644 (file)
@@ -696,6 +696,7 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
 
        if (rt == NULL) {
                struct flowi fl = { .oif = ipc.oif,
+                                   .mark = sk->sk_mark,
                                    .nl_u = { .ip4_u =
                                              { .daddr = faddr,
                                                .saddr = saddr,