ip_dummynet.c (206428) | ip_dummynet.c (206845) |
---|---|
1/*- 2 * Copyright (c) 1998-2002,2010 Luigi Rizzo, Universita` di Pisa 3 * Portions Copyright (c) 2000 Akamba Corp. 4 * All rights reserved 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1998-2002,2010 Luigi Rizzo, Universita` di Pisa 3 * Portions Copyright (c) 2000 Akamba Corp. 4 * All rights reserved 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> |
29__FBSDID("$FreeBSD: head/sys/netinet/ipfw/ip_dummynet.c 206428 2010-04-09 18:02:19Z luigi $"); | 29__FBSDID("$FreeBSD: head/sys/netinet/ipfw/ip_dummynet.c 206845 2010-04-19 16:17:30Z luigi $"); |
30 31/* 32 * Configuration and internal object management for dummynet. 33 */ 34 35#include "opt_inet6.h" 36 37#include <sys/param.h> --- 1504 unchanged lines hidden (view full) --- 1542 return EINVAL; 1543 } 1544 i = pf->link_nr; 1545 if (i <= 0 || i >= DN_MAX_ID) 1546 return EINVAL; 1547 /* XXX other sanity checks */ 1548 DN_BH_WLOCK(); 1549 for (; i < 2*DN_MAX_ID; i += DN_MAX_ID) { | 30 31/* 32 * Configuration and internal object management for dummynet. 33 */ 34 35#include "opt_inet6.h" 36 37#include <sys/param.h> --- 1504 unchanged lines hidden (view full) --- 1542 return EINVAL; 1543 } 1544 i = pf->link_nr; 1545 if (i <= 0 || i >= DN_MAX_ID) 1546 return EINVAL; 1547 /* XXX other sanity checks */ 1548 DN_BH_WLOCK(); 1549 for (; i < 2*DN_MAX_ID; i += DN_MAX_ID) { |
1550 s = locate_scheduler(i); | 1550 s = locate_scheduler(i); |
1551 | 1551 |
1552 if (s == NULL) { | 1552 if (s == NULL) { |
1553 err = EINVAL; 1554 break; | 1553 err = EINVAL; 1554 break; |
1555 } 1556 dn_cfg.id++; 1557 /* 1558 * If we had a profile and the new one does not fit, 1559 * or it is deleted, then we need to free memory. 1560 */ 1561 if (s->profile && (pf->samples_no == 0 || 1562 s->profile->oid.len < pf->oid.len)) { 1563 free(s->profile, M_DUMMYNET); 1564 s->profile = NULL; 1565 } | 1555 } 1556 dn_cfg.id++; 1557 /* 1558 * If we had a profile and the new one does not fit, 1559 * or it is deleted, then we need to free memory. 1560 */ 1561 if (s->profile && (pf->samples_no == 0 || 1562 s->profile->oid.len < pf->oid.len)) { 1563 free(s->profile, M_DUMMYNET); 1564 s->profile = NULL; 1565 } |
1566 if (pf->samples_no == 0) 1567 continue; | 1566 if (pf->samples_no == 0) 1567 continue; |
1568 /* | 1568 /* |
1569 * new profile, possibly allocate memory | 1569 * new profile, possibly allocate memory |
1570 * and copy data. 1571 */ | 1570 * and copy data. 1571 */ |
1572 if (s->profile == NULL) 1573 s->profile = malloc(pf->oid.len, 1574 M_DUMMYNET, M_NOWAIT | M_ZERO); 1575 if (s->profile == NULL) { 1576 D("no memory for profile %d", i); 1577 err = ENOMEM; 1578 break; 1579 } --- 57 unchanged lines hidden (view full) --- 1637 } 1638 l -= o->len; 1639 next = (struct dn_id *)((char *)o + o->len); 1640 err = 0; 1641 switch (o->type) { 1642 default: 1643 D("cmd %d not implemented", o->type); 1644 break; | 1572 if (s->profile == NULL) 1573 s->profile = malloc(pf->oid.len, 1574 M_DUMMYNET, M_NOWAIT | M_ZERO); 1575 if (s->profile == NULL) { 1576 D("no memory for profile %d", i); 1577 err = ENOMEM; 1578 break; 1579 } --- 57 unchanged lines hidden (view full) --- 1637 } 1638 l -= o->len; 1639 next = (struct dn_id *)((char *)o + o->len); 1640 err = 0; 1641 switch (o->type) { 1642 default: 1643 D("cmd %d not implemented", o->type); 1644 break; |
1645#ifdef EMULATE_SYSCTL | 1645 1646#ifdef EMULATE_SYSCTL |
1646 /* sysctl emulation. 1647 * if we recognize the command, jump to the correct 1648 * handler and return 1649 */ 1650 case DN_SYSCTL_SET: 1651 err = kesysctl_emu_set(p, l); 1652 return err; 1653#endif | 1647 /* sysctl emulation. 1648 * if we recognize the command, jump to the correct 1649 * handler and return 1650 */ 1651 case DN_SYSCTL_SET: 1652 err = kesysctl_emu_set(p, l); 1653 return err; 1654#endif |
1655 |
|
1654 case DN_CMD_CONFIG: /* simply a header */ 1655 break; 1656 1657 case DN_CMD_DELETE: 1658 /* the argument is in the first uintptr_t after o */ 1659 a = (uintptr_t *)(o+1); 1660 if (o->len < sizeof(*o) + sizeof(*a)) { 1661 err = EINVAL; --- 649 unchanged lines hidden --- | 1656 case DN_CMD_CONFIG: /* simply a header */ 1657 break; 1658 1659 case DN_CMD_DELETE: 1660 /* the argument is in the first uintptr_t after o */ 1661 a = (uintptr_t *)(o+1); 1662 if (o->len < sizeof(*o) + sizeof(*a)) { 1663 err = EINVAL; --- 649 unchanged lines hidden --- |