From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751359AbdH3GGI (ORCPT ); Wed, 30 Aug 2017 02:06:08 -0400 Received: from fallback11.m.smailru.net ([94.100.179.26]:53516 "EHLO fallback.mail.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750803AbdH3GGG (ORCPT ); Wed, 30 Aug 2017 02:06:06 -0400 Date: Wed, 30 Aug 2017 09:04:35 +0300 From: Andrii Vladyka To: gerrit@erg.abdn.ac.uk Cc: davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org (open list), dccp@vger.kernel.org Subject: [PATCH] net: dccp: Add handling of IPV6_PKTOPTIONS to dccp_v6_do_rcv() Message-ID: <20170830090435.58406d1b@dev> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/yNhO8aNFP.q9o_53kE9NWpe" X-7FA49CB5: 0D63561A33F958A50ADE8609F71016A09FABAA3562DC35F15D82DB2A0D7E0C13725E5C173C3A84C341E1C46B3B046460FA4D252D7C9B20EB2686C055BC15B7FBC4224003CC836476C0CAF46E325F83A50BF2EBBBDD9D6B0F2EF91E2201DEA5EC574AF45C6390F7469DAA53EE0834AAEE X-Mailru-Sender: 3DEE44A10DFADB60C2BCF497652D6EF83A2D341D3A96482172D24C83C18AFA35FA0A40D2F7BCE703F1F2485B0B92A2F6928A2593B14EC4C3A05B717206AB936FEAB4BC95F72C04283CDA0F3B3F5B9367 X-Mras: OK X-7FA49CB5: 0D63561A33F958A5A96E576112F0092D25CEFC0A495CA23B4EF221F343FD43CC462275124DF8B9C910FF24F588AC80D2BD9CCCA9EDD067B1EDA766A37F9254B7 X-Mailru-Sender: A5480F10D64C90054EBC784E05B222901F764C5CF9262FC4058B3351368DE920982BB9711DD006F12B6532038C16E532FB559BB5D741EB969AF4A27358EA235A0F2DC73CC0BFB1A30DA7A0AF5A3A8387 X-Mras: OK Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --MP_/yNhO8aNFP.q9o_53kE9NWpe Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Add handling of IPV6_PKTOPTIONS to dccp_v6_do_rcv() in net/dccp/ipv6.c, similar to the handling in net/ipv6/tcp_ipv6.c Signed-off-by: Andrii Vladyka --MP_/yNhO8aNFP.q9o_53kE9NWpe Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=dccp.patch diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index 1b58eac..fdff10b 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -30,6 +31,7 @@ #include #include #include +#include #include "dccp.h" #include "ipv6.h" @@ -597,19 +599,13 @@ static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb) --ANK (980728) */ if (np->rxopt.all) - /* - * FIXME: Add handling of IPV6_PKTOPTIONS skb. See the comments below - * (wrt ipv6_pktopions) and net/ipv6/tcp_ipv6.c for an example. - */ opt_skb = skb_clone(skb, GFP_ATOMIC); if (sk->sk_state == DCCP_OPEN) { /* Fast path */ if (dccp_rcv_established(sk, skb, dccp_hdr(skb), skb->len)) goto reset; - if (opt_skb) { - /* XXX This is where we would goto ipv6_pktoptions. */ - __kfree_skb(opt_skb); - } + if (opt_skb) + goto ipv6_pktoptions; return 0; } @@ -640,10 +636,8 @@ static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb) if (dccp_rcv_state_process(sk, skb, dccp_hdr(skb), skb->len)) goto reset; - if (opt_skb) { - /* XXX This is where we would goto ipv6_pktoptions. */ - __kfree_skb(opt_skb); - } + if (opt_skb) + goto ipv6_pktoptions; return 0; reset: @@ -653,6 +647,36 @@ static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb) __kfree_skb(opt_skb); kfree_skb(skb); return 0; + +/* + * Handling IPV6_PKTOPTIONS skb the similar + * way it's done for net/ipv6/tcp_ipv6.c + */ +ipv6_pktoptions: + if (!((1 << sk->sk_state) & (DCCPF_CLOSED | DCCPF_LISTEN))) { + if (np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo) + np->mcast_oif = inet6_iif(opt_skb); + if (np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim) + np->mcast_hops = ipv6_hdr(opt_skb)->hop_limit; + if (np->rxopt.bits.rxflow || np->rxopt.bits.rxtclass) + np->rcv_flowinfo = ip6_flowinfo(ipv6_hdr(opt_skb)); + if (np->repflow) + np->flow_label = ip6_flowlabel(ipv6_hdr(opt_skb)); + if (ipv6_opt_accepted(sk, opt_skb, + &DCCP_SKB_CB(opt_skb)->header.h6)) { + skb_set_owner_r(opt_skb, sk); + memmove(IP6CB(opt_skb), + &DCCP_SKB_CB(opt_skb)->header.h6, + sizeof(struct inet6_skb_parm)); + opt_skb = xchg(&np->pktoptions, opt_skb); + } else { + __kfree_skb(opt_skb); + opt_skb = xchg(&np->pktoptions, NULL); + } + } + + kfree_skb(opt_skb); + return 0; } static int dccp_v6_rcv(struct sk_buff *skb) --MP_/yNhO8aNFP.q9o_53kE9NWpe--