summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sbin/ipfw/ipfw.c12
-rw-r--r--sys/netinet/ip_dummynet.c15
2 files changed, 16 insertions, 11 deletions
diff --git a/sbin/ipfw/ipfw.c b/sbin/ipfw/ipfw.c
index 75cb893..aa79185 100644
--- a/sbin/ipfw/ipfw.c
+++ b/sbin/ipfw/ipfw.c
@@ -611,17 +611,17 @@ list(ac, av)
{
const int unit = do_pipe ? sizeof(*pipes) : sizeof(*rules);
const int ocmd = do_pipe ? IP_DUMMYNET_GET : IP_FW_GET;
- int nalloc = 0;
+ int nalloc = unit;
+ nbytes = nalloc ;
- while (num >= nalloc) {
+ while (nbytes >= nalloc) {
nalloc = nalloc * 2 + 200;
- nbytes = nalloc * unit;
+ nbytes = nalloc ;
if ((data = realloc(data, nbytes)) == NULL)
err(EX_OSERR, "realloc");
if (getsockopt(s, IPPROTO_IP, ocmd, data, &nbytes) < 0)
err(EX_OSERR, "getsockopt(IP_%s_GET)",
do_pipe ? "DUMMYNET" : "FW");
- num = nbytes / unit;
}
}
@@ -643,7 +643,7 @@ list(ac, av)
char buf[30] ;
char prefix[80] ;
- if ( (p->fs.flags_fs & DN_IS_PIPE) == 0)
+ if ( p->next != (struct dn_pipe *)DN_IS_PIPE )
break ;
l = sizeof(*p) + p->fs.rq_elements * sizeof(*q) ;
next = (void *)p + l ;
@@ -674,7 +674,7 @@ list(ac, av)
for ( ; nbytes >= sizeof(*fs) ; fs = (struct dn_flow_set *)next ) {
char prefix[80] ;
- if ( (fs->flags_fs & DN_IS_QUEUE) == 0)
+ if ( fs->next != (struct dn_flow_set *)DN_IS_QUEUE )
break ;
l = sizeof(*fs) + fs->rq_elements * sizeof(*q) ;
next = (void *)fs + l ;
diff --git a/sys/netinet/ip_dummynet.c b/sys/netinet/ip_dummynet.c
index 830d9bf..39492b9 100644
--- a/sys/netinet/ip_dummynet.c
+++ b/sys/netinet/ip_dummynet.c
@@ -1675,9 +1675,14 @@ dummynet_get(struct sockopt *sopt)
*/
bcopy(p, bp, sizeof( *p ) );
pipe_bp->delay = (pipe_bp->delay * 1000) / hz ;
- pipe_bp->fs.flags_fs |= DN_IS_PIPE ;
- /* cleanup pointers */
- pipe_bp->next = NULL ;
+ /*
+ * XXX the following is a hack based on ->next being the
+ * first field in dn_pipe and dn_flow_set. The correct
+ * solution would be to move the dn_flow_set to the beginning
+ * of struct dn_pipe.
+ */
+ pipe_bp->next = (struct dn_pipe *)DN_IS_PIPE ;
+ /* clean pointers */
pipe_bp->head = pipe_bp->tail = NULL ;
pipe_bp->fs.next = NULL ;
pipe_bp->fs.pipe = NULL ;
@@ -1689,8 +1694,8 @@ dummynet_get(struct sockopt *sopt)
for (set = all_flow_sets ; set ; set = set->next ) {
struct dn_flow_set *fs_bp = (struct dn_flow_set *)bp ;
bcopy(set, bp, sizeof( *set ) );
- fs_bp->flags_fs |= DN_IS_QUEUE ;
- fs_bp->next = NULL ;
+ /* XXX same hack as above */
+ fs_bp->next = (struct dn_flow_set *)DN_IS_QUEUE ;
fs_bp->pipe = NULL ;
fs_bp->rq = NULL ;
bp += sizeof( *set ) ;
OpenPOWER on IntegriCloud