Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net Userland may not change the IFF_CANTCHANGE flags, ho...
details: https://anonhg.NetBSD.org/src/rev/36e127f1b567
branches: trunk
changeset: 770668:36e127f1b567
user: dyoung <dyoung%NetBSD.org@localhost>
date: Fri Oct 28 20:11:58 2011 +0000
description:
Userland may not change the IFF_CANTCHANGE flags, however, the kernel
may, so make sure if_flags_set() takes care of them. Fixes a regression
in ifpromisc().
diffstat:
sys/net/if.c | 18 ++++++++++++++----
1 files changed, 14 insertions(+), 4 deletions(-)
diffs (45 lines):
diff -r ef931eb9ab53 -r 36e127f1b567 sys/net/if.c
--- a/sys/net/if.c Fri Oct 28 16:42:52 2011 +0000
+++ b/sys/net/if.c Fri Oct 28 20:11:58 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.255 2011/10/25 22:26:18 dyoung Exp $ */
+/* $NetBSD: if.c,v 1.256 2011/10/28 20:11:58 dyoung Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.255 2011/10/25 22:26:18 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.256 2011/10/28 20:11:58 dyoung Exp $");
#include "opt_inet.h"
@@ -2154,14 +2154,24 @@
if_flags_set(ifnet_t *ifp, const short flags)
{
int rc;
- struct ifreq ifr;
if (ifp->if_setflags != NULL)
rc = (*ifp->if_setflags)(ifp, flags);
else {
+ short cantflags;
+ struct ifreq ifr;
+
memset(&ifr, 0, sizeof(ifr));
- ifr.ifr_flags = flags;
+
+ cantflags = (ifp->if_flags ^ flags) & IFF_CANTCHANGE;
+ if (cantflags != 0)
+ ifp->if_flags ^= cantflags;
+
+ ifr.ifr_flags = flags & ~IFF_CANTCHANGE;
rc = (*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, &ifr);
+
+ if (rc != 0 && cantflags != 0)
+ ifp->if_flags ^= cantflags;
}
return rc;
Home |
Main Index |
Thread Index |
Old Index