Use sk_mark for IPv6 routing lookups
authorBrian Haley <brian.haley@hp.com>
Mon, 5 Oct 2009 08:24:16 +0000 (08:24 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 7 Oct 2009 08:10:45 +0000 (01:10 -0700)
Atis Elsts wrote:
> Not sure if there is need to fill the mark from skb in tunnel xmit functions. In any case, it's not done for GRE or IPIP tunnels at the moment.

Ok, I'll just drop that part, I'm not sure what should be done in this case.

> Also, in this patch you are doing that for SIT (v6-in-v4) tunnels only, and not doing it for v4-in-v6 or v6-in-v6 tunnels. Any reason for that?

I just sent that patch out too quickly, here's a better one with the updates.

Add support for IPv6 route lookups using sk_mark.

Signed-off-by: Brian Haley <brian.haley@hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/af_inet6.c
net/ipv6/datagram.c
net/ipv6/inet6_connection_sock.c
net/ipv6/ipv6_sockglue.c
net/ipv6/syncookies.c
net/ipv6/tcp_ipv6.c
net/ipv6/udp.c

index e127a32f9540fecfaee5de6332ca1be64ce6541f..da36497ae6478b25ee7f8f59e9e0c95a21515eeb 100644 (file)
@@ -654,6 +654,7 @@ int inet6_sk_rebuild_header(struct sock *sk)
                ipv6_addr_copy(&fl.fl6_src, &np->saddr);
                fl.fl6_flowlabel = np->flow_label;
                fl.oif = sk->sk_bound_dev_if;
+               fl.mark = sk->sk_mark;
                fl.fl_ip_dport = inet->dport;
                fl.fl_ip_sport = inet->sport;
                security_sk_classify_flow(sk, &fl);
index e2bdc6d83a43364dbc0989c22eed43b13c88750f..a615b4dea6c4b8427572fedf2d4fe5554eb3977e 100644 (file)
@@ -147,6 +147,7 @@ ipv4_connected:
        ipv6_addr_copy(&fl.fl6_dst, &np->daddr);
        ipv6_addr_copy(&fl.fl6_src, &np->saddr);
        fl.oif = sk->sk_bound_dev_if;
+       fl.mark = sk->sk_mark;
        fl.fl_ip_dport = inet->dport;
        fl.fl_ip_sport = inet->sport;
 
index cc4797dd8325f7dd3f33a40957105321c0d3d324..a9f4a21b31ea3f619616f5c47d4ddee821a2608e 100644 (file)
@@ -194,6 +194,7 @@ int inet6_csk_xmit(struct sk_buff *skb, int ipfragok)
        fl.fl6_flowlabel = np->flow_label;
        IP6_ECN_flow_xmit(sk, fl.fl6_flowlabel);
        fl.oif = sk->sk_bound_dev_if;
+       fl.mark = sk->sk_mark;
        fl.fl_ip_sport = inet->sport;
        fl.fl_ip_dport = inet->dport;
        security_sk_classify_flow(sk, &fl);
index 14f54eb5a7fc89e1ab9b3d2c7a83e84a54378dbe..dc0f7366073daaf63ae7e4e3e1ae989830b54d6f 100644 (file)
@@ -424,6 +424,7 @@ sticky_done:
 
                fl.fl6_flowlabel = 0;
                fl.oif = sk->sk_bound_dev_if;
+               fl.mark = sk->sk_mark;
 
                if (optlen == 0)
                        goto update;
index 6b6ae913b5d415bcf801a1ed0f21422d04b7f8a4..cbe55e5d9f96e0d3efb3794cb39be71aa9a9aeaa 100644 (file)
@@ -252,6 +252,7 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
                }
                ipv6_addr_copy(&fl.fl6_src, &ireq6->loc_addr);
                fl.oif = sk->sk_bound_dev_if;
+               fl.mark = sk->sk_mark;
                fl.fl_ip_dport = inet_rsk(req)->rmt_port;
                fl.fl_ip_sport = inet_sk(sk)->sport;
                security_req_classify_flow(req, &fl);
index 21d100b68b190dd7d88510f6924713567e20bded..321aafd40dcb9cf4ca3a8e115c4aa530bad8ffdd 100644 (file)
@@ -243,6 +243,7 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
        ipv6_addr_copy(&fl.fl6_src,
                       (saddr ? saddr : &np->saddr));
        fl.oif = sk->sk_bound_dev_if;
+       fl.mark = sk->sk_mark;
        fl.fl_ip_dport = usin->sin6_port;
        fl.fl_ip_sport = inet->sport;
 
@@ -383,6 +384,7 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
                        ipv6_addr_copy(&fl.fl6_dst, &np->daddr);
                        ipv6_addr_copy(&fl.fl6_src, &np->saddr);
                        fl.oif = sk->sk_bound_dev_if;
+                       fl.mark = sk->sk_mark;
                        fl.fl_ip_dport = inet->dport;
                        fl.fl_ip_sport = inet->sport;
                        security_skb_classify_flow(skb, &fl);
@@ -477,6 +479,7 @@ static int tcp_v6_send_synack(struct sock *sk, struct request_sock *req)
        ipv6_addr_copy(&fl.fl6_src, &treq->loc_addr);
        fl.fl6_flowlabel = 0;
        fl.oif = treq->iif;
+       fl.mark = sk->sk_mark;
        fl.fl_ip_dport = inet_rsk(req)->rmt_port;
        fl.fl_ip_sport = inet_rsk(req)->loc_port;
        security_req_classify_flow(req, &fl);
@@ -1345,6 +1348,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
                }
                ipv6_addr_copy(&fl.fl6_src, &treq->loc_addr);
                fl.oif = sk->sk_bound_dev_if;
+               fl.mark = sk->sk_mark;
                fl.fl_ip_dport = inet_rsk(req)->rmt_port;
                fl.fl_ip_sport = inet_rsk(req)->loc_port;
                security_req_classify_flow(req, &fl);
index 3a60f12b34ed053da8cf4261952d6d35ff879f28..3842c557d6fa28ff91972c2045b938c868bed9b5 100644 (file)
@@ -879,6 +879,8 @@ do_udp_sendmsg:
        if (!fl.oif)
                fl.oif = np->sticky_pktinfo.ipi6_ifindex;
 
+       fl.mark = sk->sk_mark;
+
        if (msg->msg_controllen) {
                opt = &opt_space;
                memset(opt, 0, sizeof(struct ipv6_txoptions));