Skip to content

Commit

Permalink
Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
Browse files Browse the repository at this point in the history
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@
  • Loading branch information
mpieuchot committed Jan 16, 2018
1 parent c10e397 commit beb8b0d
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 41 deletions.
4 changes: 2 additions & 2 deletions sbin/ifconfig/brconfig.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: brconfig.h,v 1.11 2016/09/02 10:01:36 goda Exp $ */
/* $OpenBSD: brconfig.h,v 1.12 2018/01/16 10:33:55 mpi Exp $ */

/*
* Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org>
Expand Down Expand Up @@ -70,7 +70,7 @@ void switch_datapathid(const char *, int);
void switch_portno(const char *, const char *);

#define IFFBITS \
"\024\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6NOTRAILERS" \
"\024\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6STATICARP" \
"\7RUNNING\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX" \
"\15LINK0\16LINK1\17LINK2\20MULTICAST" \
"\23INET6_NOPRIVACY\24MPLS\25WOL\26AUTOCONF6"
Expand Down
12 changes: 8 additions & 4 deletions sbin/ifconfig/ifconfig.8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.\" $OpenBSD: ifconfig.8,v 1.291 2017/11/30 07:41:01 jmc Exp $
.\" $OpenBSD: ifconfig.8,v 1.292 2018/01/16 10:33:55 mpi Exp $
.\" $NetBSD: ifconfig.8,v 1.11 1996/01/04 21:27:29 pk Exp $
.\" $FreeBSD: ifconfig.8,v 1.16 1998/02/01 07:03:29 steve Exp $
.\"
Expand Down Expand Up @@ -31,7 +31,7 @@
.\"
.\" @(#)ifconfig.8 8.4 (Berkeley) 6/1/94
.\"
.Dd $Mdocdate: November 30 2017 $
.Dd $Mdocdate: January 16 2018 $
.Dt IFCONFIG 8
.Os
.Sh NAME
Expand Down Expand Up @@ -147,8 +147,6 @@ Use of this option is discouraged in favour of
Enable the use of the Address Resolution Protocol (ARP)
in mapping
between network level addresses and link level addresses (default).
This is currently implemented for mapping between
DARPA Internet addresses and Ethernet addresses.
.It Cm -arp
Disable the use of ARP.
.It Cm broadcast Ar addr
Expand Down Expand Up @@ -454,6 +452,12 @@ and
.Xr pf.conf 5 .
.It Cm -rtlabel
Clear the route label.
.It Cm staticarp
If ARP is enabled, the host will only reply to requests for its addresses,
and will never send any requests.
.It Cm -staticarp
If ARP is enabled, the host will perform normally,
sending out requests and listening for replies.
.It Cm up
Mark an interface
.Dq up .
Expand Down
4 changes: 3 additions & 1 deletion sbin/ifconfig/ifconfig.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: ifconfig.c,v 1.352 2018/01/09 10:02:02 mpi Exp $ */
/* $OpenBSD: ifconfig.c,v 1.353 2018/01/16 10:33:55 mpi Exp $ */
/* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */

/*
Expand Down Expand Up @@ -397,6 +397,8 @@ const struct cmd {
{ "rtlabel", NEXTARG, 0, setifrtlabel },
{ "-rtlabel", -1, 0, setifrtlabel },
{ "rdomain", NEXTARG, 0, setrdomain },
{ "staticarp", IFF_STATICARP, 0, setifflags },
{ "-staticarp", -IFF_STATICARP, 0, setifflags },
{ "mpls", IFXF_MPLS, 0, setifxflags },
{ "-mpls", -IFXF_MPLS, 0, setifxflags },
{ "mplslabel", NEXTARG, 0, setmpelabel },
Expand Down
4 changes: 2 additions & 2 deletions sbin/route/route.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: route.c,v 1.206 2017/10/18 07:31:31 mpi Exp $ */
/* $OpenBSD: route.c,v 1.207 2018/01/16 10:33:55 mpi Exp $ */
/* $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $ */

/*
Expand Down Expand Up @@ -1268,7 +1268,7 @@ char routeflags[] =
"\020PROTO1\021CLONED\022CACHED\023MPATH\025MPLS\026LOCAL\027BROADCAST"
"\030CONNECTED\031BFD";
char ifnetflags[] =
"\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5PTP\6NOTRAILERS\7RUNNING\010NOARP\011PPROMISC"
"\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5PTP\6STATICARP\7RUNNING\010NOARP\011PPROMISC"
"\012ALLMULTI\013OACTIVE\014SIMPLEX\015LINK0\016LINK1\017LINK2\020MULTICAST";
char addrnames[] =
"\1DST\2GATEWAY\3NETMASK\4GENMASK\5IFP\6IFA\7AUTHOR\010BRD\011SRC\012SRCMASK\013LABEL\014BFD\015DNS\016STATIC\017SEARCH";
Expand Down
55 changes: 32 additions & 23 deletions sys/net/if.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: if.h,v 1.189 2017/12/21 01:11:47 dlg Exp $ */
/* $OpenBSD: if.h,v 1.190 2018/01/16 10:33:55 mpi Exp $ */
/* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */

/*
Expand Down Expand Up @@ -184,34 +184,43 @@ struct if_status_description {
*/
#define IFDESCRSIZE 64

#define IFF_UP 0x1 /* interface is up */
#define IFF_BROADCAST 0x2 /* broadcast address valid */
#define IFF_DEBUG 0x4 /* turn on debugging */
#define IFF_LOOPBACK 0x8 /* is a loopback net */
#define IFF_POINTOPOINT 0x10 /* interface is point-to-point link */
#define IFF_NOTRAILERS 0x20 /* avoid use of trailers */
#define IFF_RUNNING 0x40 /* resources allocated */
#define IFF_NOARP 0x80 /* no address resolution protocol */
#define IFF_PROMISC 0x100 /* receive all packets */
#define IFF_ALLMULTI 0x200 /* receive all multicast packets */
#define IFF_OACTIVE 0x400 /* transmission in progress */
#define IFF_SIMPLEX 0x800 /* can't hear own transmissions */
#define IFF_LINK0 0x1000 /* per link layer defined bit */
#define IFF_LINK1 0x2000 /* per link layer defined bit */
#define IFF_LINK2 0x4000 /* per link layer defined bit */
#define IFF_MULTICAST 0x8000 /* supports multicast */
/*
* Interface flags can be either owned by the stack or the driver. The
* symbols below document who is toggling which flag.
*
* I immutable after creation
* N written by the stack (upon user request)
* d written by the driver
* c for userland compatibility only
*/
#define IFF_UP 0x1 /* [N] interface is up */
#define IFF_BROADCAST 0x2 /* [I] broadcast address valid */
#define IFF_DEBUG 0x4 /* [N] turn on debugging */
#define IFF_LOOPBACK 0x8 /* [I] is a loopback net */
#define IFF_POINTOPOINT 0x10 /* [I] is point-to-point link */
#define IFF_STATICARP 0x20 /* [N] only static ARP */
#define IFF_RUNNING 0x40 /* [d] resources allocated */
#define IFF_NOARP 0x80 /* [N] no address resolution protocol */
#define IFF_PROMISC 0x100 /* [N] receive all packets */
#define IFF_ALLMULTI 0x200 /* [d] receive all multicast packets */
#define IFF_OACTIVE 0x400 /* [c] transmission in progress */
#define IFF_SIMPLEX 0x800 /* [I] can't hear own transmissions */
#define IFF_LINK0 0x1000 /* [N] per link layer defined bit */
#define IFF_LINK1 0x2000 /* [N] per link layer defined bit */
#define IFF_LINK2 0x4000 /* [N] per link layer defined bit */
#define IFF_MULTICAST 0x8000 /* [I] supports multicast */

/* flags set internally only: */
#define IFF_CANTCHANGE \
(IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)

#define IFXF_MPSAFE 0x1 /* if_start is mpsafe */
#define IFXF_CLONED 0x2 /* pseudo interface */
#define IFXF_INET6_NOPRIVACY 0x4 /* don't autoconf privacy */
#define IFXF_MPLS 0x8 /* supports MPLS */
#define IFXF_WOL 0x10 /* wake on lan enabled */
#define IFXF_AUTOCONF6 0x20 /* v6 autoconf enabled */
#define IFXF_MPSAFE 0x1 /* [I] if_start is mpsafe */
#define IFXF_CLONED 0x2 /* [I] pseudo interface */
#define IFXF_INET6_NOPRIVACY 0x4 /* [N] don't autoconf privacy */
#define IFXF_MPLS 0x8 /* [N] supports MPLS */
#define IFXF_WOL 0x10 /* [N] wake on lan enabled */
#define IFXF_AUTOCONF6 0x20 /* [N] v6 autoconf enabled */

#define IFXF_CANTCHANGE \
(IFXF_MPSAFE|IFXF_CLONED)
Expand Down
4 changes: 2 additions & 2 deletions sys/netinet/if_ether.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: if_ether.c,v 1.232 2018/01/15 13:48:31 bluhm Exp $ */
/* $OpenBSD: if_ether.c,v 1.233 2018/01/16 10:33:55 mpi Exp $ */
/* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */

/*
Expand Down Expand Up @@ -356,7 +356,7 @@ arpresolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m,
return (0);
}

if (ifp->if_flags & IFF_NOARP)
if (ifp->if_flags & (IFF_NOARP|IFF_STATICARP))
goto bad;

/*
Expand Down
9 changes: 2 additions & 7 deletions usr.sbin/route6d/route6d.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: route6d.c,v 1.92 2017/08/23 11:25:07 jca Exp $ */
/* $OpenBSD: route6d.c,v 1.93 2018/01/16 10:33:55 mpi Exp $ */
/* $KAME: route6d.c,v 1.111 2006/10/25 06:38:13 jinmei Exp $ */

/*
Expand Down Expand Up @@ -2334,12 +2334,7 @@ do { \
IFFLAG("DEBUG", IFF_DEBUG);
IFFLAG("LOOPBACK", IFF_LOOPBACK);
IFFLAG("POINTOPOINT", IFF_POINTOPOINT);
#ifdef IFF_NOTRAILERS
IFFLAG("NOTRAILERS", IFF_NOTRAILERS);
#endif
#ifdef IFF_SMART
IFFLAG("SMART", IFF_SMART);
#endif
IFFLAG("STATICARP", IFF_STATICARP);
IFFLAG("RUNNING", IFF_RUNNING);
IFFLAG("NOARP", IFF_NOARP);
IFFLAG("PROMISC", IFF_PROMISC);
Expand Down

0 comments on commit beb8b0d

Please sign in to comment.