From 4c23f738b57f0dec5cf7f18d1768c57269691a95 Mon Sep 17 00:00:00 2001 From: mpi Date: Tue, 5 May 2015 09:41:43 +0000 Subject: [PATCH] Flag user specified routes with an AF_LINK gateway as RTF_LLINFO. This makes ND6 and ARP layers happy since they both check for this flag, but is was redundant to provide route(8)'s "-llinfo" option when adding a l2 route. RTF_LLINFO is clearly redundant for userland tools, so only allow the kernel to set it. ok benno@, claudio@ --- sys/net/route.h | 4 ++-- sys/net/rtsock.c | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/sys/net/route.h b/sys/net/route.h index 91637f91676..94be6300ec2 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -1,4 +1,4 @@ -/* $OpenBSD: route.h,v 1.105 2015/02/11 23:34:43 mpi Exp $ */ +/* $OpenBSD: route.h,v 1.106 2015/05/05 09:41:43 mpi Exp $ */ /* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */ /* @@ -143,7 +143,7 @@ struct rtentry { /* mask of RTF flags that are allowed to be modified by RTM_CHANGE */ #define RTF_FMASK \ - (RTF_PROTO1 | RTF_PROTO2 | RTF_PROTO3 | RTF_BLACKHOLE | \ + (RTF_LLINFO | RTF_PROTO1 | RTF_PROTO2 | RTF_PROTO3 | RTF_BLACKHOLE | \ RTF_REJECT | RTF_STATIC | RTF_MPLS | RTF_LOCAL | RTF_BROADCAST) /* Routing priorities used by the different routing protocols */ diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index b4ff9fccf1f..c46de81c5a3 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.157 2015/02/11 23:34:43 mpi Exp $ */ +/* $OpenBSD: rtsock.c,v 1.158 2015/05/05 09:41:43 mpi Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -584,6 +584,12 @@ route_output(struct mbuf *m, ...) info.rti_mpls = rtm->rtm_mpls; #endif + if (info.rti_info[RTAX_GATEWAY] != NULL && + info.rti_info[RTAX_GATEWAY]->sa_family == AF_LINK && + (info.rti_flags & RTF_CLONING) == 0) { + info.rti_flags |= RTF_LLINFO; + } + switch (rtm->rtm_type) { case RTM_ADD: if (info.rti_info[RTAX_GATEWAY] == NULL) { -- 2.20.1