summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/net/bridge.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/sys/net/bridge.c b/sys/net/bridge.c
index 0ab2cba..88f54f9 100644
--- a/sys/net/bridge.c
+++ b/sys/net/bridge.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998-2000 Luigi Rizzo
+ * Copyright (c) 1998-2001 Luigi Rizzo
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -181,9 +181,11 @@ bdg_promisc_off(int clear_used)
ret = ifpromisc(ifp, 0);
splx(s);
ifp2sc[ifp->if_index].flags &= ~(IFF_BDG_PROMISC|IFF_MUTE) ;
- if (clear_used)
+ if (clear_used) {
ifp2sc[ifp->if_index].flags &= ~(IFF_USED) ;
- printf(">> now %s%d promisc ON if_flags 0x%x bdg_flags 0x%x\n",
+ bdg_stats.s[ifp->if_index].name[0] = '\0';
+ }
+ printf(">> now %s%d promisc OFF if_flags 0x%x bdg_flags 0x%x\n",
ifp->if_name, ifp->if_unit,
ifp->if_flags, ifp2sc[ifp->if_index].flags);
}
@@ -286,14 +288,16 @@ parse_bdg_cfg()
if (!strncmp(beg, buf, l)) { /* XXX not correct for >10 if! */
b->cluster_id = htons(cluster) ;
b->flags |= IFF_USED ;
- sprintf(bdg_stats.s[ifp->if_index].name+l,
- ":%d", cluster);
+ sprintf(bdg_stats.s[ifp->if_index].name,
+ "%s%d:%d", ifp->if_name, ifp->if_unit, cluster);
DDB(printf("--++ found %s\n",
bdg_stats.s[ifp->if_index].name);)
break ;
}
}
+ if (*p == '\0')
+ break ;
}
}
@@ -700,10 +704,13 @@ bdg_forward(struct mbuf **m0, struct ether_header *const eh, struct ifnet *dst)
*/
if (canfree == 0 ) {
/*
- * Need to make a copy (and for good measure, make sure that
- * the header is contiguous). The original is still in *m0
+ * Need to make a copy. The original is still in *m0.
+ * Make sure that, in the copy, the first mbuf contains
+ * both the ethernet and the ip header. The reason is,
+ * some code up in the stack treats the IP header as rw so
+ * we do not want to share it into a cluster.
*/
- int needed = min(MHLEN, max_protohdr) ;
+ int needed = min(MHLEN, 14+max_protohdr) ;
needed = min(needed, (*m0)->m_len ) ;
m = m_copypacket( (*m0), M_DONTWAIT);
@@ -711,7 +718,8 @@ bdg_forward(struct mbuf **m0, struct ether_header *const eh, struct ifnet *dst)
printf("-- bdg: m_copypacket failed.\n") ;
return ENOBUFS ;
}
- if (m->m_len < needed && (m = m_pullup(m, needed)) == NULL) {
+ m = m_pullup(m, needed) ;
+ if (m == NULL) {
printf("-- bdg: pullup failed.\n") ;
return ENOBUFS ;
}
@@ -802,11 +810,12 @@ forward:
* but better than having packets corrupt!
*/
if (canfree == 0 ) {
- int needed = min(MHLEN, max_protohdr) ;
+ int needed = min(MHLEN, 14+ max_protohdr) ;
needed = min(needed, (*m0)->m_len ) ;
- if ((*m0)->m_len < needed && (*m0 = m_pullup(*m0, needed)) == NULL) {
- printf("-- bdg: pullup failed.\n") ;
+ *m0 = m_pullup(*m0, needed) ;
+ if ( *m0 == NULL) {
+ printf("-- bdg: pullup(2) failed.\n") ;
return ENOBUFS ;
}
}
@@ -816,9 +825,9 @@ forward:
m = *m0 ;
*m0 = NULL ; /* original is gone */
} else
- m = m_dup(*m0, M_DONTWAIT); /* XXX m_copypacket should work */
+ m = m_copypacket(*m0, M_DONTWAIT);
if (m == NULL) {
- printf("bdg_forward: sorry, m_dup failed!\n");
+ printf("bdg_forward: sorry, m_copypacket failed!\n");
return ENOBUFS ; /* the original is still there... */
}
/*
OpenPOWER on IntegriCloud