From patchwork Wed Mar 25 02:24:49 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlad Yasevich X-Patchwork-Id: 25038 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 1F882DDFB0 for ; Wed, 25 Mar 2009 13:25:08 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756868AbZCYCZB (ORCPT ); Tue, 24 Mar 2009 22:25:01 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756787AbZCYCY7 (ORCPT ); Tue, 24 Mar 2009 22:24:59 -0400 Received: from g5t0009.atlanta.hp.com ([15.192.0.46]:5797 "EHLO g5t0009.atlanta.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754435AbZCYCY6 (ORCPT ); Tue, 24 Mar 2009 22:24:58 -0400 Received: from smtp2.fc.hp.com (smtp.cnd.hp.com [15.11.136.114]) by g5t0009.atlanta.hp.com (Postfix) with ESMTP id 8478C304A1; Wed, 25 Mar 2009 02:24:57 +0000 (UTC) Received: from localhost.localdomain (squirrel.fc.hp.com [15.11.146.57]) by smtp2.fc.hp.com (Postfix) with ESMTP id 602B82BD6CB; Wed, 25 Mar 2009 02:01:11 +0000 (UTC) From: Vlad Yasevich To: davem@davemloft.net Cc: netdev@vger.kernel.org, Vlad Yasevich Subject: [PATCH v2 2/4] ipv6: Allow ipv4 wildcard binds after ipv6 address binds Date: Tue, 24 Mar 2009 22:24:49 -0400 Message-Id: <1237947891-26825-3-git-send-email-vladislav.yasevich@hp.com> X-Mailer: git-send-email 1.5.4.3 In-Reply-To: <1237947891-26825-1-git-send-email-vladislav.yasevich@hp.com> References: <1237947891-26825-1-git-send-email-vladislav.yasevich@hp.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The IPv4 wildcard (0.0.0.0) address does not intersect in any way with explicit IPv6 addresses. These two should be permitted, but the IPv4 conflict code checks the ipv6only bit as part of the test. Since binding to an explicit IPv6 address restricts the socket to only that IPv6 address, the side-effect is that the socket behaves as v6-only. By explicitely setting ipv6only in this case, allows the 2 binds to succeed. Signed-off-by: Vlad Yasevich --- net/ipv6/af_inet6.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index 7f092fa..9b6a37d 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -346,8 +346,11 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) goto out; } - if (addr_type != IPV6_ADDR_ANY) + if (addr_type != IPV6_ADDR_ANY) { sk->sk_userlocks |= SOCK_BINDADDR_LOCK; + if (addr_type != IPV6_ADDR_MAPPED) + np->ipv6only = 1; + } if (snum) sk->sk_userlocks |= SOCK_BINDPORT_LOCK; inet->sport = htons(inet->num);