From patchwork Mon Oct 5 13:46:34 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atis Elsts X-Patchwork-Id: 35015 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id BB141B7B9C for ; Tue, 6 Oct 2009 00:48:52 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751722AbZJENrR (ORCPT ); Mon, 5 Oct 2009 09:47:17 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751118AbZJENrQ (ORCPT ); Mon, 5 Oct 2009 09:47:16 -0400 Received: from bute.mt.lv ([159.148.172.196]:43452 "EHLO bute.mt.lv" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750810AbZJENrQ (ORCPT ); Mon, 5 Oct 2009 09:47:16 -0400 Received: from atis-desktop.local (unknown [10.0.0.128]) by bute.mt.lv (Postfix) with ESMTP id 91FDBE0125; Mon, 5 Oct 2009 16:46:33 +0300 (EEST) From: Atis Elsts To: netdev@vger.kernel.org Subject: [PATCH] Add sk_mark route lookup support for IPv4 listening sockets, and for IPv4 multicast forwarding Date: Mon, 5 Oct 2009 16:46:34 +0300 User-Agent: KMail/1.9.10 Cc: David Miller , panther@balabit.hu, eric.dumazet@gmail.com, brian.haley@hp.com, zenczykowski@gmail.com MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200910051646.34770.atis@mikrotik.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This is followup to my previous route lookup patch, it adds sk_mark based routing lookup support in even more places. Now it is possible to have e.g. TCP server listening to connection requests in a specific routing table specified by SO_MARK socket option. Also, correct me if I'm wrong, but syncookie route lookup still seems to be broken in more than one way. The sk_bound_dev_if interface from socket is not used; and route lookup is done in init_net, instead of using sock_net(sk). cookie_v6_check() in net/ipv6/syncookies.c probably needs a patch as well. Add support for route lookup using sk_mark on IPv4 listening sockets, and for IPv4 multicast forwarding Signed-off-by: Atis Elsts --- net/ipv4/inet_connection_sock.c | 1 + net/ipv4/ipmr.c | 2 ++ net/ipv4/syncookies.c | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index 4351ca2..9139e8f 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -358,6 +358,7 @@ struct dst_entry *inet_csk_route_req(struct sock *sk, const struct inet_request_sock *ireq = inet_rsk(req); struct ip_options *opt = inet_rsk(req)->opt; struct flowi fl = { .oif = sk->sk_bound_dev_if, + .mark = sk->sk_mark, .nl_u = { .ip4_u = { .daddr = ((opt && opt->srr) ? opt->faddr : diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index 630a56d..66c58e4 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c @@ -1238,6 +1238,7 @@ static void ipmr_queue_xmit(struct sk_buff *skb, struct mfc_cache *c, int vifi) if (vif->flags&VIFF_TUNNEL) { struct flowi fl = { .oif = vif->link, + .mark = skb->mark, .nl_u = { .ip4_u = { .daddr = vif->remote, .saddr = vif->local, @@ -1248,6 +1249,7 @@ static void ipmr_queue_xmit(struct sk_buff *skb, struct mfc_cache *c, int vifi) encap = sizeof(struct iphdr); } else { struct flowi fl = { .oif = vif->link, + .mark = skb->mark, .nl_u = { .ip4_u = { .daddr = iph->daddr, .tos = RT_TOS(iph->tos) } }, diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c index a6e0e07..5ec678a 100644 --- a/net/ipv4/syncookies.c +++ b/net/ipv4/syncookies.c @@ -333,7 +333,8 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb, * no easy way to do this. */ { - struct flowi fl = { .nl_u = { .ip4_u = + struct flowi fl = { .mark = sk->sk_mark, + .nl_u = { .ip4_u = { .daddr = ((opt && opt->srr) ? opt->faddr : ireq->rmt_addr),