Date: Thu, 1 Feb 2007 16:59:37 GMT From: Paolo Pisati <piso@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 113845 for review Message-ID: <200702011659.l11Gxbe0073139@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=113845 Change 113845 by piso@piso_newluxor on 2007/02/01 16:59:07 Teach mbuf to LibAliasUnaliasOut(). Affected files ... .. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.c#51 edit .. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.h#12 edit Differences ... ==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.c#51 (text+ko) ==== @@ -167,7 +167,7 @@ #define PULLUP_ICMPHDR(pip, ptr) do { \ struct mbuf *m; \ - pip = ptr; \ + pip = (struct ip *)ptr; \ m = m_pullup((ptr), (pip->ip_hl << 2) + sizeof(struct icmp)); \ (pip) = mtod(m, struct ip *); \ } while (0) @@ -183,10 +183,10 @@ } while (0) #else -#define PULLUP_IPHDR(pip, ptr) pip = ptr +#define PULLUP_IPHDR(pip, ptr) pip = (struct ip *)ptr #define PULLUP_UDPHDR(pip, ptr) pip = ptr #define PULLUP_TCPHDR(pip, ptr) pip = ptr -#define PULLUP_ICMPHDR(pip, ptr) pip = ptr +#define PULLUP_ICMPHDR(pip, ptr) pip = (struct ip *)ptr #define PULLUP_ICMPIP64(pip, ptr, ic) pip = ptr #endif @@ -1533,9 +1533,15 @@ } int +#ifdef _KERNEL +LibAliasUnaliasOut(struct libalias *la, struct mbuf *ptr, /* valid IP packet */ + int maxpacketsize /* for error checking */ +) +#else LibAliasUnaliasOut(struct libalias *la, char *ptr, /* valid IP packet */ int maxpacketsize /* for error checking */ ) +#endif { struct ip *pip; struct icmp *ic; @@ -1545,13 +1551,19 @@ int iresult = PKT_ALIAS_IGNORED; LIBALIAS_LOCK(la); - pip = (struct ip *)ptr; + PULLUP_IPHDR(pip, ptr); + if (pip == NULL) + goto getout; /* Defense against mangled packets */ if (ntohs(pip->ip_len) > maxpacketsize || (pip->ip_hl << 2) > maxpacketsize) goto getout; + /* Let's make enough space for any of the protocols header below */ + PULLUP_ICMPHDR(pip, ptr); + if (pip == NULL) + goto getout; ud = (struct udphdr *)ip_next(pip); tc = (struct tcphdr *)ip_next(pip); ic = (struct icmp *)ip_next(pip); ==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.h#12 (text+ko) ==== @@ -149,12 +149,13 @@ int LibAliasIn (struct libalias *, struct mbuf *_ptr, int _maxpacketsize); int LibAliasOut(struct libalias *, struct mbuf *_ptr, int _maxpacketsize); int LibAliasOutTry(struct libalias *, struct mbuf *_ptr, int _maxpacketsize, int _create); +int LibAliasUnaliasOut(struct libalias *, struct mbuf *_ptr, int _maxpacketsize); #else int LibAliasIn (struct libalias *, char *_ptr, int _maxpacketsize); int LibAliasOut(struct libalias *, char *_ptr, int _maxpacketsize); int LibAliasOutTry(struct libalias *, char *_ptr, int _maxpacketsize, int _create); +int LibAliasUnaliasOut(struct libalias *, char *_ptr, int _maxpacketsize); #endif -int LibAliasUnaliasOut(struct libalias *, char *_ptr, int _maxpacketsize); /* Port and address redirection functions. */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200702011659.l11Gxbe0073139>