From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1aTcsU-0006mY-Bp for mharc-grub-devel@gnu.org; Wed, 10 Feb 2016 17:04:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTcsS-0006m0-E9 for grub-devel@gnu.org; Wed, 10 Feb 2016 17:04:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aTcsP-0000aF-7J for grub-devel@gnu.org; Wed, 10 Feb 2016 17:04:48 -0500 Received: from 66-220-144-178.intmgw.facebook.com ([66.220.144.178]:38062 helo=mx-out.facebook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTcsP-0000aB-1A for grub-devel@gnu.org; Wed, 10 Feb 2016 17:04:45 -0500 Received: from facebook.com (2401:db00:2040:5012:face:0:9:0) by mx-out.facebook.com (10.103.99.97) with ESMTP id 0d883618d03c11e5917f0002c9931860-e36e9270 for ; Wed, 10 Feb 2016 13:20:04 -0800 Received: by devbig041.ash4.facebook.com (Postfix, from userid 8730) id E3F294540BF0; Wed, 10 Feb 2016 13:21:10 -0800 (PST) From: Josef Bacik To: grub-devel@gnu.org, kernel-team@fb.com Subject: [PATCH 12/14] icmp6: use default interface as the route interface Date: Wed, 10 Feb 2016 13:21:06 -0800 Message-Id: <1455139268-3241273-13-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 1.8.1 In-Reply-To: <1455139268-3241273-1-git-send-email-jbacik@fb.com> References: <1455139268-3241273-1-git-send-email-jbacik@fb.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 66.220.144.178 Cc: Josef Bacik X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Feb 2016 22:04:49 -0000 As it stands now if we do dhcp and slaac we'll use the slaac interface for any routes advertised on the local network as those will be the first interfaces we find. However if we have a default interface, ie the one set up from the pxe dhcp packet, we would prefer to use this one. So when getting RA's, check to see if our default interface is a v6 interface and matches the card we got the RA on, and if so use that as the route interface. This allows us to get traffic from the dhcp interface instead of through the slaac interface. Signed-off-by: Josef Bacik --- grub-core/net/icmp6.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/grub-core/net/icmp6.c b/grub-core/net/icmp6.c index 2cbd95d..f02e9cd 100644 --- a/grub-core/net/icmp6.c +++ b/grub-core/net/icmp6.c @@ -19,6 +19,7 @@ #include #include #include +#include struct icmp_header { @@ -361,6 +362,7 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *nb, if (grub_be_to_cpu16 (radv->router_lifetime) > 0) { struct grub_net_route *route; + const char *default_inf = grub_env_get ("net_default_interface"); FOR_NET_ROUTES (route) { @@ -369,6 +371,24 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *nb, } if (route == NULL) default_route = 1; + + /* If we have a default interface and it's on the same card as we're + getting this advertisement on then we want to make sure we use + that interface as the route interface. */ + if (default_inf) + { + FOR_NET_NETWORK_LEVEL_INTERFACES (inf) + { + if (grub_strcmp(default_inf, inf->name)) + continue; + if (inf->card == card && inf != orig_inf + && inf->address.type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6 + && grub_net_hwaddr_cmp(&inf->hwaddress, + &orig_inf->hwaddress) == 0) + route_inf = inf; + break; + } + } } for (ptr = (grub_uint8_t *) nb->data; ptr < nb->tail; -- 1.8.1