From a736847cb3801f83fcd1f9b01be1d26fb1f1dfd9 Mon Sep 17 00:00:00 2001 From: Ralf Corsepius Date: Sat, 21 May 2005 16:31:28 +0000 Subject: Partial update from FreeBSD. --- cpukit/libnetworking/netinet/ip_icmp.c | 11 ++-- cpukit/libnetworking/sys/mbuf.h | 91 +++++++++++++++------------------- 2 files changed, 45 insertions(+), 57 deletions(-) (limited to 'cpukit') diff --git a/cpukit/libnetworking/netinet/ip_icmp.c b/cpukit/libnetworking/netinet/ip_icmp.c index 39020162b5..11e954dc9b 100644 --- a/cpukit/libnetworking/netinet/ip_icmp.c +++ b/cpukit/libnetworking/netinet/ip_icmp.c @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * @(#)ip_icmp.c 8.2 (Berkeley) 1/4/94 - * $FreeBSD: src/sys/netinet/ip_icmp.c,v 1.98 2005/01/07 01:45:44 imp Exp $ + * $FreeBSD: src/sys/netinet/ip_icmp.c,v 1.101 2005/05/04 13:23:54 andre Exp $ */ /* @@ -95,7 +95,6 @@ int icmpprintfs = 0; static void icmp_reflect(struct mbuf *); static void icmp_send(struct mbuf *, struct mbuf *); -static int ip_next_mtu(int, int); extern struct protosw inetsw[]; @@ -692,20 +691,19 @@ iptime() return (htonl(t)); } -#if 1 /* * Return the next larger or smaller MTU plateau (table from RFC 1191) * given current value MTU. If DIR is less than zero, a larger plateau * is returned; otherwise, a smaller value is returned. */ -static int +int ip_next_mtu(mtu, dir) int mtu; int dir; { static int mtutab[] = { - 65535, 32000, 17914, 8166, 4352, 2002, 1492, 1006, 508, 296, - 68, 0 + 65535, 32000, 17914, 8166, 4352, 2002, 1492, 1280, 1006, 508, + 296, 68, 0 }; int i; @@ -730,4 +728,3 @@ ip_next_mtu(mtu, dir) } } } -#endif diff --git a/cpukit/libnetworking/sys/mbuf.h b/cpukit/libnetworking/sys/mbuf.h index 7275da2fdd..e88aed3628 100644 --- a/cpukit/libnetworking/sys/mbuf.h +++ b/cpukit/libnetworking/sys/mbuf.h @@ -127,20 +127,28 @@ struct mbuf { #define m_pktdat M_dat.MH.MH_dat.MH_databuf #define m_dat M_dat.M_databuf -/* mbuf flags */ +/* + * mbuf flags. + */ #define M_EXT 0x0001 /* has associated external storage */ #define M_PKTHDR 0x0002 /* start of record */ #define M_EOR 0x0004 /* end of record */ #define M_PROTO1 0x0008 /* protocol-specific */ -/* mbuf pkthdr flags, also in m_flags */ +/* + * mbuf pkthdr flags (also stored in m_flags). + */ #define M_BCAST 0x0100 /* send/received as link-level broadcast */ #define M_MCAST 0x0200 /* send/received as link-level multicast */ -/* flags copied when copying m_pkthdr */ +/* + * Flags copied when copying m_pkthdr. + */ #define M_COPYFLAGS (M_PKTHDR|M_EOR|M_PROTO1|M_BCAST|M_MCAST) -/* mbuf types */ +/* + * mbuf types. + */ #define MT_FREE 0 /* should be on free list */ #define MT_DATA 1 /* dynamic (data) allocation */ #define MT_HEADER 2 /* packet header */ @@ -157,6 +165,21 @@ struct mbuf { #define MT_CONTROL 14 /* extra-data protocol message */ #define MT_OOBDATA 15 /* expedited data */ +/* + * General mbuf allocator statistics structure. + */ +struct mbstat { + u_long m_mbufs; /* mbufs obtained from page pool */ + u_long m_clusters; /* clusters obtained from page pool */ + u_long m_spare; /* spare field */ + u_long m_clfree; /* free clusters */ + u_long m_drops; /* times failed to find space */ + u_long m_wait; /* times waited for space */ + u_long m_drain; /* times drained protocols for space */ + u_short m_mtypes[256]; /* type specific mbuf allocations */ +}; + + /* flags to m_get/MGET */ #define M_DONTWAIT M_NOWAIT #define M_WAIT M_WAITOK @@ -316,14 +339,17 @@ union mcluster { * Set the m_data pointer of a newly-allocated mbuf (m_get/MGET) to place * an object of the specified size at the end of the mbuf, longword aligned. */ -#define M_ALIGN(m, len) \ - { (m)->m_data += (MLEN - (len)) &~ (sizeof(long) - 1); } +#define M_ALIGN(m, len) do { \ + (m)->m_data += (MLEN - (len)) & ~(sizeof(long) - 1); \ +} while (0) + /* * As above, for mbufs allocated with m_gethdr/MGETHDR * or initialized by M_COPY_PKTHDR. */ -#define MH_ALIGN(m, len) \ - { (m)->m_data += (MHLEN - (len)) &~ (sizeof(long) - 1); } +#define MH_ALIGN(m, len) do { \ + (m)->m_data += (MHLEN - (len)) & ~(sizeof(long) - 1); \ +} while (0) /* * Compute the amount of space available @@ -359,32 +385,21 @@ union mcluster { (m)->m_pkthdr.len += (plen); \ } -/* change mbuf to new type */ +/* + * Change mbuf to new type. + * This is a relatively expensive operation and should be avoided. + */ #define MCHTYPE(m, t) { \ MBUFLOCK(mbstat.m_mtypes[(m)->m_type]--; mbstat.m_mtypes[t]++;) \ (m)->m_type = t;\ } -/* length to m_copy to copy all */ +/* Length to m_copy to copy all. */ #define M_COPYALL 1000000000 -/* compatibility with 4.3 */ +/* Compatibility with 4.3. */ #define m_copy(m, o, l) m_copym((m), (o), (l), M_DONTWAIT) -/* - * Mbuf statistics. - */ -struct mbstat { - u_long m_mbufs; /* mbufs obtained from page pool */ - u_long m_clusters; /* clusters obtained from page pool */ - u_long m_spare; /* spare field */ - u_long m_clfree; /* free clusters */ - u_long m_drops; /* times failed to find space */ - u_long m_wait; /* times waited for space */ - u_long m_drain; /* times drained protocols for space */ - u_short m_mtypes[256]; /* type specific mbuf allocations */ -}; - #ifdef _KERNEL extern struct mbuf *mbutl; /* virtual address of mclusters */ extern char *mclrefcnt; /* cluster reference counts */ @@ -397,7 +412,6 @@ extern int max_linkhdr; /* largest link-level header */ extern int max_protohdr; /* largest protocol header */ extern int max_hdr; /* largest link+protocol header */ extern int max_datalen; /* MHLEN - max_hdr */ -extern int mbtypes[]; /* XXX */ struct mbuf *m_copym(struct mbuf *, int, int, int); struct mbuf *m_copypacket(struct mbuf *, int); @@ -421,29 +435,6 @@ int m_copydata(const struct mbuf *, int, int, caddr_t); void m_freem(struct mbuf *); void m_reclaim(void); -#ifdef MBTYPES -int mbtypes[] = { /* XXX */ - M_FREE, /* MT_FREE 0 should be on free list */ - M_MBUF, /* MT_DATA 1 dynamic (data) allocation */ - M_MBUF, /* MT_HEADER 2 packet header */ - M_SOCKET, /* MT_SOCKET 3 socket structure */ - M_PCB, /* MT_PCB 4 protocol control block */ - M_RTABLE, /* MT_RTABLE 5 routing tables */ - M_HTABLE, /* MT_HTABLE 6 IMP host tables */ - 0, /* MT_ATABLE 7 address resolution tables */ - M_MBUF, /* MT_SONAME 8 socket name */ - 0, /* 9 */ - M_SOOPTS, /* MT_SOOPTS 10 socket options */ - M_FTABLE, /* MT_FTABLE 11 fragment reassembly header */ - M_MBUF, /* MT_RIGHTS 12 access rights */ - M_IFADDR, /* MT_IFADDR 13 interface address */ - M_MBUF, /* MT_CONTROL 14 extra-data protocol message */ - M_MBUF, /* MT_OOBDATA 15 expedited data */ -#ifdef DATAKIT - 25, 26, 27, 28, 29, 30, 31, 32 /* datakit ugliness */ -#endif -}; -#endif -#endif +#endif /* _KERNEL */ #endif /* !_SYS_MBUF_H_ */ -- cgit v1.2.3