Wed Jun 28 04:10:47 2017 UTC ()
Drop RTF_LLINFO flag (now it's RTF_LLDATA) from local routes

They don't have llinfo anymore. And also the change fixes unexpected
behavior of ARP proxy.


(ozaki-r)
diff -r1.196 -r1.197 src/sys/net/route.c
diff -r1.30 -r1.31 src/tests/net/arp/t_arp.sh
diff -r1.12 -r1.13 src/tests/net/route/t_route.sh

cvs diff -r1.196 -r1.197 src/sys/net/route.c (expand / switch to unified diff)

--- src/sys/net/route.c 2017/06/22 09:56:48 1.196
+++ src/sys/net/route.c 2017/06/28 04:10:47 1.197
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: route.c,v 1.196 2017/06/22 09:56:48 ozaki-r Exp $ */ 1/* $NetBSD: route.c,v 1.197 2017/06/28 04:10:47 ozaki-r Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Kevin M. Lahey of the Numerical Aerospace Simulation Facility, 8 * by Kevin M. Lahey of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center. 9 * NASA Ames Research Center.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -87,27 +87,27 @@ @@ -87,27 +87,27 @@
87 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 87 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
88 * SUCH DAMAGE. 88 * SUCH DAMAGE.
89 * 89 *
90 * @(#)route.c 8.3 (Berkeley) 1/9/95 90 * @(#)route.c 8.3 (Berkeley) 1/9/95
91 */ 91 */
92 92
93#ifdef _KERNEL_OPT 93#ifdef _KERNEL_OPT
94#include "opt_inet.h" 94#include "opt_inet.h"
95#include "opt_route.h" 95#include "opt_route.h"
96#include "opt_net_mpsafe.h" 96#include "opt_net_mpsafe.h"
97#endif 97#endif
98 98
99#include <sys/cdefs.h> 99#include <sys/cdefs.h>
100__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.196 2017/06/22 09:56:48 ozaki-r Exp $"); 100__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.197 2017/06/28 04:10:47 ozaki-r Exp $");
101 101
102#include <sys/param.h> 102#include <sys/param.h>
103#ifdef RTFLUSH_DEBUG 103#ifdef RTFLUSH_DEBUG
104#include <sys/sysctl.h> 104#include <sys/sysctl.h>
105#endif 105#endif
106#include <sys/systm.h> 106#include <sys/systm.h>
107#include <sys/callout.h> 107#include <sys/callout.h>
108#include <sys/proc.h> 108#include <sys/proc.h>
109#include <sys/mbuf.h> 109#include <sys/mbuf.h>
110#include <sys/socket.h> 110#include <sys/socket.h>
111#include <sys/socketvar.h> 111#include <sys/socketvar.h>
112#include <sys/domain.h> 112#include <sys/domain.h>
113#include <sys/kernel.h> 113#include <sys/kernel.h>
@@ -1584,28 +1584,26 @@ rt_ifa_addlocal(struct ifaddr *ifa) @@ -1584,28 +1584,26 @@ rt_ifa_addlocal(struct ifaddr *ifa)
1584 rt = rtalloc1(ifa->ifa_addr, 0); 1584 rt = rtalloc1(ifa->ifa_addr, 0);
1585#ifdef RT_DEBUG 1585#ifdef RT_DEBUG
1586 if (rt != NULL) 1586 if (rt != NULL)
1587 dump_rt(rt); 1587 dump_rt(rt);
1588#endif 1588#endif
1589 if (rt == NULL || (rt->rt_flags & RTF_HOST) == 0 || 1589 if (rt == NULL || (rt->rt_flags & RTF_HOST) == 0 ||
1590 (rt->rt_ifp->if_flags & IFF_LOOPBACK) == 0) 1590 (rt->rt_ifp->if_flags & IFF_LOOPBACK) == 0)
1591 { 1591 {
1592 struct rt_addrinfo info; 1592 struct rt_addrinfo info;
1593 struct rtentry *nrt; 1593 struct rtentry *nrt;
1594 1594
1595 memset(&info, 0, sizeof(info)); 1595 memset(&info, 0, sizeof(info));
1596 info.rti_flags = RTF_HOST | RTF_LOCAL; 1596 info.rti_flags = RTF_HOST | RTF_LOCAL;
1597 if (!(ifa->ifa_ifp->if_flags & (IFF_LOOPBACK|IFF_POINTOPOINT))) 
1598 info.rti_flags |= RTF_LLDATA; 
1599 info.rti_info[RTAX_DST] = ifa->ifa_addr; 1597 info.rti_info[RTAX_DST] = ifa->ifa_addr;
1600 info.rti_info[RTAX_GATEWAY] = 1598 info.rti_info[RTAX_GATEWAY] =
1601 (const struct sockaddr *)ifa->ifa_ifp->if_sadl; 1599 (const struct sockaddr *)ifa->ifa_ifp->if_sadl;
1602 info.rti_ifa = ifa; 1600 info.rti_ifa = ifa;
1603 nrt = NULL; 1601 nrt = NULL;
1604 e = rtrequest1(RTM_ADD, &info, &nrt); 1602 e = rtrequest1(RTM_ADD, &info, &nrt);
1605 if (nrt && ifa != nrt->rt_ifa) 1603 if (nrt && ifa != nrt->rt_ifa)
1606 rt_replace_ifa(nrt, ifa); 1604 rt_replace_ifa(nrt, ifa);
1607 rt_newaddrmsg(RTM_ADD, ifa, e, nrt); 1605 rt_newaddrmsg(RTM_ADD, ifa, e, nrt);
1608 if (nrt != NULL) { 1606 if (nrt != NULL) {
1609#ifdef RT_DEBUG 1607#ifdef RT_DEBUG
1610 dump_rt(nrt); 1608 dump_rt(nrt);
1611#endif 1609#endif

cvs diff -r1.30 -r1.31 src/tests/net/arp/t_arp.sh (expand / switch to unified diff)

--- src/tests/net/arp/t_arp.sh 2017/06/26 06:59:57 1.30
+++ src/tests/net/arp/t_arp.sh 2017/06/28 04:10:47 1.31
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: t_arp.sh,v 1.30 2017/06/26 06:59:57 ozaki-r Exp $ 1# $NetBSD: t_arp.sh,v 1.31 2017/06/28 04:10:47 ozaki-r Exp $
2# 2#
3# Copyright (c) 2015 The NetBSD Foundation, Inc. 3# Copyright (c) 2015 The NetBSD Foundation, Inc.
4# All rights reserved. 4# All rights reserved.
5# 5#
6# Redistribution and use in source and binary forms, with or without 6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions 7# modification, are permitted provided that the following conditions
8# are met: 8# are met:
9# 1. Redistributions of source code must retain the above copyright 9# 1. Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer. 10# notice, this list of conditions and the following disclaimer.
11# 2. Redistributions in binary form must reproduce the above copyright 11# 2. Redistributions in binary form must reproduce the above copyright
12# notice, this list of conditions and the following disclaimer in the 12# notice, this list of conditions and the following disclaimer in the
13# documentation and/or other materials provided with the distribution. 13# documentation and/or other materials provided with the distribution.
14# 14#
@@ -312,30 +312,32 @@ arp_garp_body() @@ -312,30 +312,32 @@ arp_garp_body()
312arp_cache_overwriting_body() 312arp_cache_overwriting_body()
313{ 313{
314 local bonus=2 314 local bonus=2
315 315
316 rump_server_start $SOCKSRC 316 rump_server_start $SOCKSRC
317 rump_server_start $SOCKDST 317 rump_server_start $SOCKDST
318 318
319 setup_dst_server 319 setup_dst_server
320 setup_src_server 320 setup_src_server
321 321
322 export RUMP_SERVER=$SOCKSRC 322 export RUMP_SERVER=$SOCKSRC
323 323
324 # Cannot overwrite a permanent cache 324 # Cannot overwrite a permanent cache
325 atf_check -s exit:0 rump.arp -s $IP4SRC b2:a0:20:00:00:ff 325 atf_check -s exit:0 rump.arp -s $IP4DST b2:a0:20:00:00:ff
326 $DEBUG && rump.arp -n -a 326 $DEBUG && rump.arp -n -a
327 atf_check -s not-exit:0 -e match:'File exists' \ 327 atf_check -s not-exit:0 -e match:'File exists' \
328 rump.arp -s $IP4SRC b2:a0:20:00:00:fe 328 rump.arp -s $IP4DST b2:a0:20:00:00:fe
 329 # cleanup
 330 atf_check -s exit:0 rump.arp -d $IP4DST
329 331
330 atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 $IP4DST 332 atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 $IP4DST
331 $DEBUG && rump.arp -n -a 333 $DEBUG && rump.arp -n -a
332 # Can overwrite a dynamic cache 334 # Can overwrite a dynamic cache
333 atf_check -s exit:0 -o ignore rump.arp -s $IP4DST b2:a0:20:00:00:00 335 atf_check -s exit:0 -o ignore rump.arp -s $IP4DST b2:a0:20:00:00:00
334 $DEBUG && rump.arp -n -a 336 $DEBUG && rump.arp -n -a
335 atf_check -s exit:0 -o match:'b2:a0:20:00:00:00' rump.arp -n $IP4DST 337 atf_check -s exit:0 -o match:'b2:a0:20:00:00:00' rump.arp -n $IP4DST
336 atf_check -s exit:0 -o match:'permanent' rump.arp -n $IP4DST 338 atf_check -s exit:0 -o match:'permanent' rump.arp -n $IP4DST
337 339
338 atf_check -s exit:0 -o ignore rump.arp -s 10.0.1.10 b2:a0:20:00:00:10 temp 340 atf_check -s exit:0 -o ignore rump.arp -s 10.0.1.10 b2:a0:20:00:00:10 temp
339 $DEBUG && rump.arp -n -a 341 $DEBUG && rump.arp -n -a
340 atf_check -s exit:0 -o match:'b2:a0:20:00:00:10' rump.arp -n 10.0.1.10 342 atf_check -s exit:0 -o match:'b2:a0:20:00:00:10' rump.arp -n 10.0.1.10
341 atf_check -s exit:0 -o not-match:'permanent' rump.arp -n 10.0.1.10 343 atf_check -s exit:0 -o not-match:'permanent' rump.arp -n 10.0.1.10
@@ -373,76 +375,64 @@ test_proxy_arp() @@ -373,76 +375,64 @@ test_proxy_arp()
373 375
374 rump_server_start $SOCKSRC 376 rump_server_start $SOCKSRC
375 rump_server_start $SOCKDST tap 377 rump_server_start $SOCKDST tap
376 378
377 setup_dst_server 379 setup_dst_server
378 setup_src_server 380 setup_src_server
379 381
380 export RUMP_SERVER=$SOCKDST 382 export RUMP_SERVER=$SOCKDST
381 atf_check -s exit:0 -o ignore rump.sysctl -w net.inet.ip.forwarding=1 383 atf_check -s exit:0 -o ignore rump.sysctl -w net.inet.ip.forwarding=1
382 macaddr_dst=$(get_macaddr $SOCKDST shmif0) 384 macaddr_dst=$(get_macaddr $SOCKDST shmif0)
383 385
384 if [ "$type" = "pub" ]; then 386 if [ "$type" = "pub" ]; then
385 opts="pub" 387 opts="pub"
386 title="permanent published" 
387 else 388 else
388 opts="pub proxy" 389 opts="pub proxy"
389 title='permanent published \(proxy only\)' 
390 fi 390 fi
 391 # Always proxy only since migrating to lltable/llentry
 392 title='permanent published \(proxy only\)'
391 393
392 # 394 #
393 # Test#1: First setup an endpoint then create proxy arp entry 395 # Test#1: First setup an endpoint then create proxy arp entry
394 # 396 #
395 export RUMP_SERVER=$SOCKDST 397 export RUMP_SERVER=$SOCKDST
396 atf_check -s exit:0 rump.ifconfig tap1 create 398 atf_check -s exit:0 rump.ifconfig tap1 create
397 atf_check -s exit:0 rump.ifconfig tap1 $IP4DST_PROXYARP1/24 up 399 atf_check -s exit:0 rump.ifconfig tap1 $IP4DST_PROXYARP1/24 up
398 atf_check -s exit:0 rump.ifconfig -w 10 400 atf_check -s exit:0 rump.ifconfig -w 10
399 401
400 # Try to ping (should fail w/o proxy arp) 402 # Try to ping (should fail w/o proxy arp)
401 export RUMP_SERVER=$SOCKSRC 403 export RUMP_SERVER=$SOCKSRC
402 atf_check -s not-exit:0 -o ignore -e ignore \ 404 atf_check -s not-exit:0 -o ignore -e ignore \
403 rump.ping -n -w 1 -c 1 $IP4DST_PROXYARP1 405 rump.ping -n -w 1 -c 1 $IP4DST_PROXYARP1
404 406
405 # Flushing 407 # Flushing
406 extract_new_packets bus1 > ./out 408 extract_new_packets bus1 > ./out
407 409
408 # Set up proxy ARP entry 410 # Set up proxy ARP entry
409 export RUMP_SERVER=$SOCKDST 411 export RUMP_SERVER=$SOCKDST
410 atf_check -s exit:0 -o ignore \ 412 atf_check -s exit:0 -o ignore \
411 rump.arp -s $IP4DST_PROXYARP1 $macaddr_dst $opts 413 rump.arp -s $IP4DST_PROXYARP1 $macaddr_dst $opts
412 atf_check -s exit:0 -o match:"$title" rump.arp -n $IP4DST_PROXYARP1 414 atf_check -s exit:0 -o match:"$title" rump.arp -n $IP4DST_PROXYARP1
413 415
414 # Try to ping 416 # Try to ping
415 export RUMP_SERVER=$SOCKSRC 417 export RUMP_SERVER=$SOCKSRC
416 if [ "$type" = "pub" ]; then 418 atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 $IP4DST_PROXYARP1
417 # XXX fails 
418 atf_check -s not-exit:0 -o ignore -e ignore \ 
419 rump.ping -n -w 1 -c 1 $IP4DST_PROXYARP1 
420 else 
421 atf_check -s exit:0 -o ignore \ 
422 rump.ping -n -w 1 -c 1 $IP4DST_PROXYARP1 
423 fi 
424 419
425 extract_new_packets bus1 > ./out 420 extract_new_packets bus1 > ./out
426 $DEBUG && cat ./out 421 $DEBUG && cat ./out
427 422
428 pkt1=$(make_pkt_str_arprep $IP4DST_PROXYARP1 $macaddr_dst) 423 pkt1=$(make_pkt_str_arprep $IP4DST_PROXYARP1 $macaddr_dst)
429 pkt2=$(make_pkt_str_garp $IP4DST_PROXYARP1 $macaddr_dst) 424 pkt2=$(make_pkt_str_garp $IP4DST_PROXYARP1 $macaddr_dst)
430 if [ "$type" = "pub" ]; then 425 atf_check -s exit:0 -x "cat ./out |grep -q -e '$pkt1' -e '$pkt2'"
431 atf_check -s not-exit:0 -x \ 
432 "cat ./out |grep -q -e '$pkt1' -e '$pkt2'" 
433 else 
434 atf_check -s exit:0 -x "cat ./out |grep -q -e '$pkt1' -e '$pkt2'" 
435 fi 
436 426
437 # 427 #
438 # Test#2: Create proxy arp entry then set up an endpoint 428 # Test#2: Create proxy arp entry then set up an endpoint
439 # 429 #
440 export RUMP_SERVER=$SOCKDST 430 export RUMP_SERVER=$SOCKDST
441 atf_check -s exit:0 -o ignore \ 431 atf_check -s exit:0 -o ignore \
442 rump.arp -s $IP4DST_PROXYARP2 $macaddr_dst $opts 432 rump.arp -s $IP4DST_PROXYARP2 $macaddr_dst $opts
443 atf_check -s exit:0 -o match:"$title" rump.arp -n $IP4DST_PROXYARP2 433 atf_check -s exit:0 -o match:"$title" rump.arp -n $IP4DST_PROXYARP2
444 $DEBUG && rump.netstat -nr -f inet 434 $DEBUG && rump.netstat -nr -f inet
445 435
446 # Try to ping (should fail because no endpoint exists) 436 # Try to ping (should fail because no endpoint exists)
447 export RUMP_SERVER=$SOCKSRC 437 export RUMP_SERVER=$SOCKSRC
448 atf_check -s not-exit:0 -o ignore -e ignore \ 438 atf_check -s not-exit:0 -o ignore -e ignore \

cvs diff -r1.12 -r1.13 src/tests/net/route/t_route.sh (expand / switch to unified diff)

--- src/tests/net/route/t_route.sh 2017/03/24 03:47:25 1.12
+++ src/tests/net/route/t_route.sh 2017/06/28 04:10:47 1.13
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: t_route.sh,v 1.12 2017/03/24 03:47:25 ozaki-r Exp $ 1# $NetBSD: t_route.sh,v 1.13 2017/06/28 04:10:47 ozaki-r Exp $
2# 2#
3# Copyright (c) 2016 Internet Initiative Japan Inc. 3# Copyright (c) 2016 Internet Initiative Japan Inc.
4# All rights reserved. 4# All rights reserved.
5# 5#
6# Redistribution and use in source and binary forms, with or without 6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions 7# modification, are permitted provided that the following conditions
8# are met: 8# are met:
9# 1. Redistributions of source code must retain the above copyright 9# 1. Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer. 10# notice, this list of conditions and the following disclaimer.
11# 2. Redistributions in binary form must reproduce the above copyright 11# 2. Redistributions in binary form must reproduce the above copyright
12# notice, this list of conditions and the following disclaimer in the 12# notice, this list of conditions and the following disclaimer in the
13# documentation and/or other materials provided with the distribution. 13# documentation and/or other materials provided with the distribution.
14# 14#
@@ -224,27 +224,27 @@ test_route_get() @@ -224,27 +224,27 @@ test_route_get()
224 export RUMP_SERVER=$SOCKSRC 224 export RUMP_SERVER=$SOCKSRC
225 $DEBUG && rump.netstat -nr -f inet 225 $DEBUG && rump.netstat -nr -f inet
226 $DEBUG && rump.arp -n -a 226 $DEBUG && rump.arp -n -a
227 227
228 # Make sure an ARP cache to the gateway doesn't exist 228 # Make sure an ARP cache to the gateway doesn't exist
229 rump.arp -d $IP4SRCGW 229 rump.arp -d $IP4SRCGW
230 230
231 # Local 231 # Local
232 cat >./expect <<-EOF 232 cat >./expect <<-EOF
233 route to: 10.0.1.2 233 route to: 10.0.1.2
234destination: 10.0.1.2 234destination: 10.0.1.2
235 local addr: 10.0.1.2 235 local addr: 10.0.1.2
236 interface: lo0 236 interface: lo0
237 flags: <UP,HOST,DONE,LLINFO,LOCAL> 237 flags: <UP,HOST,DONE,LOCAL>
238 recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire 238 recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire
239 EOF 239 EOF
240 rump.route -n get $IP4SRC > ./output 240 rump.route -n get $IP4SRC > ./output
241 $DEBUG && cat ./expect ./output 241 $DEBUG && cat ./expect ./output
242 # XXX: omit the last line because expire is unstable on rump kernel. 242 # XXX: omit the last line because expire is unstable on rump kernel.
243 sed -i '$d' ./output 243 sed -i '$d' ./output
244 atf_check -s exit:0 diff ./expect ./output 244 atf_check -s exit:0 diff ./expect ./output
245 245
246 # Neighbor 246 # Neighbor
247 cat >./expect <<-EOF 247 cat >./expect <<-EOF
248 route to: 10.0.1.1 248 route to: 10.0.1.1
249destination: 10.0.1.0 249destination: 10.0.1.0
250 mask: 255.255.255.0 250 mask: 255.255.255.0
@@ -299,27 +299,27 @@ test_route_get6() @@ -299,27 +299,27 @@ test_route_get6()
299 export RUMP_SERVER=$SOCKSRC 299 export RUMP_SERVER=$SOCKSRC
300 $DEBUG && rump.netstat -nr -f inet 300 $DEBUG && rump.netstat -nr -f inet
301 $DEBUG && rump.ndp -n -a 301 $DEBUG && rump.ndp -n -a
302 302
303 # Make sure an ARP cache to the gateway doesn't exist 303 # Make sure an ARP cache to the gateway doesn't exist
304 rump.ndp -d $IP6SRCGW 304 rump.ndp -d $IP6SRCGW
305 305
306 # Local 306 # Local
307 cat >./expect <<-EOF 307 cat >./expect <<-EOF
308 route to: fc00:0:0:1::2 308 route to: fc00:0:0:1::2
309destination: fc00:0:0:1::2 309destination: fc00:0:0:1::2
310 local addr: fc00:0:0:1::2 310 local addr: fc00:0:0:1::2
311 interface: lo0 311 interface: lo0
312 flags: <UP,HOST,DONE,LLINFO,LOCAL> 312 flags: <UP,HOST,DONE,LOCAL>
313 recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire 313 recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire
314 EOF 314 EOF
315 rump.route -n get -inet6 $IP6SRC > ./output 315 rump.route -n get -inet6 $IP6SRC > ./output
316 $DEBUG && cat ./expect ./output 316 $DEBUG && cat ./expect ./output
317 sed -i '$d' ./output 317 sed -i '$d' ./output
318 atf_check -s exit:0 diff ./expect ./output 318 atf_check -s exit:0 diff ./expect ./output
319 319
320 # Neighbor 320 # Neighbor
321 cat >./expect <<-EOF 321 cat >./expect <<-EOF
322 route to: fc00:0:0:1::1 322 route to: fc00:0:0:1::1
323destination: fc00:0:0:1:: 323destination: fc00:0:0:1::
324 mask: ffff:ffff:ffff:ffff:: 324 mask: ffff:ffff:ffff:ffff::
325 local addr: fc00:0:0:1::2 325 local addr: fc00:0:0:1::2