Date: Sun, 3 Feb 2002 11:10:02 -0800 (PST) From: Archie Cobbs <archie@dellroad.org> To: freebsd-bugs@FreeBSD.org Subject: Re: kern/31586: netgraph bridges cause connectivity probs from bridge Message-ID: <200202031910.g13JA2j13507@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/31586; it has been noted by GNATS.
From: Archie Cobbs <archie@dellroad.org>
To: freebsd-gnats-submit@FreeBSD.org, michaelb@thus.net
Cc:
Subject: Re: kern/31586: netgraph bridges cause connectivity probs from bridge
Date: Sun, 3 Feb 2002 10:46:56 -0800 (PST)
Here is a candidate patch. There seem to be two strategies:
#1 Check the flags for mbufs going out the 'lower' hook and
compute the checksums for packets that need it.
#2 Temporarily turn off the interface flags advertising hardware
checksums whenever 'lower' is connected.
The patch below implements #2. While #1 might make more sense,
the problem is that it fails in the case of CSUM_FRAGMENT.
To handle CSUM_FRAGMENT in case #1, we would have to implement
IP fragmentation code in ng_ether, yuck... seems much better
to let ip_output() do it.
The only unknown is whether the drivers will freak out when
ifp->if_hwassist is changed to zero and back... it doesn't appear
so; it seems the worst thing that would happen is the chip
recomputing a checksum, but I'm not positive about that.
-Archie
__________________________________________________________________________
Archie Cobbs * Packet Design * http://www.packetdesign.com
Index: sys/netgraph/ng_ether.c
===================================================================
RCS file: /home/ncvs/src/sys/netgraph/ng_ether.c,v
retrieving revision 1.2.2.10
diff -u -r1.2.2.10 ng_ether.c
--- sys/netgraph/ng_ether.c 1 Sep 2001 08:22:29 -0000 1.2.2.10
+++ sys/netgraph/ng_ether.c 2 Feb 2002 21:46:39 -0000
@@ -75,6 +75,7 @@
u_char lowerOrphan; /* whether lower is lower or orphan */
u_char autoSrcAddr; /* always overwrite source address */
u_char promisc; /* promiscuous mode enabled */
+ u_long hwassist; /* hardware checksum capabilities */
};
typedef struct private *priv_p;
@@ -319,6 +320,7 @@
priv->ifp = ifp;
IFP2NG(ifp) = node;
priv->autoSrcAddr = 1;
+ priv->hwassist = ifp->if_hwassist;
/* Try to give the node the same name as the interface */
if (ng_name_node(node, name) != 0) {
@@ -470,6 +472,10 @@
if (*hookptr != NULL)
return (EISCONN);
+ /* If lower hook connected, disable hardware checksum */
+ if (hookptr == &priv->lower)
+ ifp->if_hwassist = 0;
+
/* OK */
*hookptr = hook;
priv->lowerOrphan = orphan;
@@ -685,6 +691,7 @@
{
const priv_p priv = hook->node->private;
+ /* Mark hook not connected */
if (hook == priv->upper)
priv->upper = NULL;
else if (hook == priv->lower) {
@@ -692,8 +699,14 @@
priv->lowerOrphan = 0;
} else
panic("%s: weird hook", __FUNCTION__);
+
+ /* If lower hook disconnected, restore hardware checksum */
+ if (hookptr == &priv->lower)
+ ifp->if_hwassist = priv->hwassist;
+
+ /* Reset node after last disconnect */
if (hook->node->numhooks == 0)
- ng_rmnode(hook->node); /* reset node */
+ ng_rmnode(hook->node);
return (0);
}
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200202031910.g13JA2j13507>
