mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-29 08:08:37 +00:00
Fix behaviour of "ipfw pipe show" -- previous code gave
ambiguous data to the userland program (kernel operation was safe, anyways).
This commit is contained in:
parent
42b0434934
commit
8a0b95d610
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=61657
@ -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 ;
|
||||
|
@ -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 ) ;
|
||||
|
Loading…
Reference in New Issue
Block a user