Date: Fri, 16 Aug 2002 13:37:57 +0300 (EEST) From: Iasen Kostov <ikostov@otel.net> To: Julian Elischer <julian@elischer.org> Cc: Maxim Sobolev <sobomax@FreeBSD.org>, <hackers@FreeBSD.org>, <net@FreeBSD.org> Subject: Re: Increasing size of if_flags field in the ifnet structure [patch for review] Message-ID: <20020816133655.U18061-200000@shadowhand.OTEL.net> In-Reply-To: <20020816131654.H18061-100000@shadowhand.OTEL.net>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Ops here is the patch (not enough sleep again :().
On Fri, 16 Aug 2002, Iasen Kostov wrote:
> Please take a look at this patch. It implement 1 more flag to if_flags
> and ofcourse it increases size of this flag field by using if_ipending
> which is unused.
>
> On Thu, 15 Aug 2002, Julian Elischer wrote:
>
> > you cannot break ABIs in 4.x
> > in 5.x it will probably be ok until (say) 5.1 or something.
> >
> >
> > On Thu, 15 Aug 2002, Maxim Sobolev wrote:
> >
> > > Folks,
> > >
> > > When implementing ability to switch interface into promisc mode using
> > > ifconfig(8) I've stumbled into the problem with already exhausted
> > > space in the `short if_flags' field in the ifnet structure. I need to
> > > allocate one new flag, while we already have 16 IFF_* flags, and even
> > > one additional flag which is implemented using currently free
> > > if_ipending field of the said structure. Attached patch is aimed at
> > > increasing size of if_flags to 32 bits, as well as to clean-up
> > > if_ipending abuse. Granted, it will break backward ABI compatibility,
> > > but IMO it is not a big problem.
> > >
> > > Comments and suggestions are greatly appreciated. Thanks!
> > >
> > > -Maxim
> >
> >
> > To Unsubscribe: send mail to majordomo@FreeBSD.org
> > with "unsubscribe freebsd-net" in the body of the message
> >
>
>
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-net" in the body of the message
>
[-- Attachment #2 --]
--- sys/net/if.c Sun Apr 28 08:40:25 2002
+++ sys/net/if.my.c Sat Jun 8 20:52:12 2002
@@ -952,6 +952,7 @@
struct ifstat *ifs;
int error;
short oif_flags;
+ int flagslong;
switch (cmd) {
@@ -980,7 +981,8 @@
switch (cmd) {
case SIOCGIFFLAGS:
- ifr->ifr_flags = ifp->if_flags;
+ flagslong = ifp->if_flags & 0x0000ffff;
+ ifr->ifr_flagslong = flagslong | ifp->if_ipending;
break;
case SIOCGIFCAP:
@@ -1004,6 +1006,7 @@
error = suser(p);
if (error)
return (error);
+ ifp->if_ipending = ifr->ifr_flagslong & 0xffff0000;
ifr->ifr_prevflags = ifp->if_flags;
if (ifp->if_flags & IFF_SMART) {
/* Smart drivers twiddle their own routes */
--- sys/net/if.h Sun Feb 10 01:02:39 2002
+++ sys/net/if.my.h Sat Jun 8 20:52:20 2002
@@ -139,6 +139,7 @@
* IFF flags, so we have an easier time when we want to merge them.
*/
#define IFF_POLLING 0x10000 /* Interface is in polling mode. */
+#define IFF_NOROUTE 0x20000 /* Interface doesn't need host route. */
/* flags set internally only: */
#define IFF_CANTCHANGE \
@@ -224,6 +225,7 @@
struct sockaddr ifru_dstaddr;
struct sockaddr ifru_broadaddr;
short ifru_flags[2];
+ int ifru_flagslong;
int ifru_metric;
int ifru_mtu;
int ifru_phys;
@@ -236,6 +238,7 @@
#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
#define ifr_flags ifr_ifru.ifru_flags[0] /* flags */
#define ifr_prevflags ifr_ifru.ifru_flags[1] /* flags */
+#define ifr_flagslong ifr_ifru.ifru_flagslong /* long flags (int) */
#define ifr_metric ifr_ifru.ifru_metric /* metric */
#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
#define ifr_phys ifr_ifru.ifru_phys /* physical wire */
--- sbin/ifconfig/ifconfig.c Wed Apr 3 14:48:48 2002
+++ sbin/ifconfig/ifconfig.my.c Sat Jun 8 21:05:00 2002
@@ -205,6 +205,8 @@
{ "-alias", -IFF_UP, notealias },
{ "delete", -IFF_UP, notealias },
{ "remove", -IFF_UP, notealias },
+ { "noroute", IFF_NOROUTE, setifflags },
+ { "-noroute", -IFF_NOROUTE, setifflags },
#ifdef notdef
#define EN_SWABIPS 0x1000
{ "swabips", EN_SWABIPS, setifflags },
@@ -1028,14 +1030,14 @@
exit(1);
}
strncpy(my_ifr.ifr_name, name, sizeof (my_ifr.ifr_name));
- flags = my_ifr.ifr_flags;
+ flags = my_ifr.ifr_flagslong;
if (value < 0) {
value = -value;
flags &= ~value;
} else
flags |= value;
- my_ifr.ifr_flags = flags;
+ my_ifr.ifr_flagslong = flags;
if (ioctl(s, SIOCSIFFLAGS, (caddr_t)&my_ifr) < 0)
Perror(vname);
}
--- sys/netinet/in.c Sat Jun 8 21:21:12 2002
+++ sys/netinet/in.my.c Sat Jun 8 20:53:06 2002
@@ -739,15 +739,16 @@
* XXX: This is ugly ! There should be a way for the caller to
* say that they don't want a host route.
*/
- if (ia->ia_addr.sin_addr.s_addr != INADDR_ANY ||
- ia->ia_netmask != IN_CLASSA_NET ||
- ia->ia_dstaddr.sin_addr.s_addr != htonl(IN_CLASSA_HOST)) {
- if ((error = rtinit(&ia->ia_ifa, (int)RTM_ADD, flags)) != 0) {
- ia->ia_addr = oldaddr;
- return (error);
- }
- ia->ia_flags |= IFA_ROUTE;
- }
+ if (!(ifp->if_ipending & IFF_NOROUTE))
+ if (ia->ia_addr.sin_addr.s_addr != INADDR_ANY ||
+ ia->ia_netmask != IN_CLASSA_NET ||
+ ia->ia_dstaddr.sin_addr.s_addr != htonl(IN_CLASSA_HOST)) {
+ if ((error = rtinit(&ia->ia_ifa, (int)RTM_ADD, flags)) != 0) {
+ ia->ia_addr = oldaddr;
+ return (error);
+ }
+ ia->ia_flags |= IFA_ROUTE;
+ }
/*
* If the interface supports multicast, join the "all hosts"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020816133655.U18061-200000>
