From patchwork Mon Jan 13 16:44:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: FX Le Bail X-Patchwork-Id: 310254 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.180.67]) by ozlabs.org (Postfix) with ESMTP id 82D312C0092 for ; Tue, 14 Jan 2014 04:04:08 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755832AbaAMREE (ORCPT ); Mon, 13 Jan 2014 12:04:04 -0500 Received: from smtp06.smtpout.orange.fr ([80.12.242.128]:55673 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754861AbaAMRD1 (ORCPT ); Mon, 13 Jan 2014 12:03:27 -0500 Received: from localhost.localdomain ([86.214.30.166]) by mwinf5d29 with ME id DV3G1n0033b2xSm03V3MPw; Mon, 13 Jan 2014 18:03:26 +0100 From: Francois-Xavier Le Bail To: netdev@vger.kernel.org Cc: Hannes Frederic Sowa , "David S. Miller" , Alexey Kuznetsov , James Morris , Hideaki Yoshifuji , Patrick McHardy , Francois-Xavier Le Bail Subject: [PATCH net-next] IPv6: add a function to check for a valid anycast source address Date: Mon, 13 Jan 2014 17:44:22 +0100 Message-Id: <1389631462-4289-1-git-send-email-fx.lebail@yahoo.com> X-Mailer: git-send-email 1.7.10.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org - Add ipv6_chk_acast_addr_src() to check if an anycast address is link-local on given interface or is global (on any interface). Signed-off-by: Francois-Xavier Le Bail --- include/net/addrconf.h | 5 +++-- net/ipv6/anycast.c | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) -- 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/include/net/addrconf.h b/include/net/addrconf.h index 66c4a44..50e39a8 100644 --- a/include/net/addrconf.h +++ b/include/net/addrconf.h @@ -205,8 +205,9 @@ void ipv6_sock_ac_close(struct sock *sk); int ipv6_dev_ac_inc(struct net_device *dev, const struct in6_addr *addr); int __ipv6_dev_ac_dec(struct inet6_dev *idev, const struct in6_addr *addr); bool ipv6_chk_acast_addr(struct net *net, struct net_device *dev, - const struct in6_addr *addr); - + const struct in6_addr *addr); +bool ipv6_chk_acast_addr_src(struct net *net, struct net_device *dev, + const struct in6_addr *addr); /* Device notifier */ int register_inet6addr_notifier(struct notifier_block *nb); diff --git a/net/ipv6/anycast.c b/net/ipv6/anycast.c index 5a80f15..4f2c62a 100644 --- a/net/ipv6/anycast.c +++ b/net/ipv6/anycast.c @@ -383,6 +383,17 @@ bool ipv6_chk_acast_addr(struct net *net, struct net_device *dev, return found; } +/* check if address is link-local on given interface + * or is global (on any interface) + */ +bool ipv6_chk_acast_addr_src(struct net *net, struct net_device *dev, + const struct in6_addr *addr) +{ + if (ipv6_addr_type(addr) & IPV6_ADDR_LINKLOCAL) + return ipv6_chk_acast_dev(dev, addr); + else + return ipv6_chk_acast_addr(net, NULL, addr); +} #ifdef CONFIG_PROC_FS struct ac6_iter_state {