PERFORCE change 113802 for review
Paolo Pisati
piso at FreeBSD.org
Thu Feb 1 00:46:54 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=113802
Change 113802 by piso at piso_newluxor on 2007/02/01 00:46:42
Teach mbuf to TcpAlias[In|Out].
Affected files ...
.. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.c#49 edit
Differences ...
==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.c#49 (text+ko) ====
@@ -158,9 +158,17 @@
(pip) = mtod(m, struct ip *); \
} while (0)
+#define PULLUP_TCPHDR(pip, ptr) do { \
+ struct mbuf *m; \
+ pip = ptr; \
+ m = m_pullup((ptr), (pip->ip_hl << 2) + sizeof(struct tcphdr)); \
+ (pip) = mtod(m, struct ip *); \
+} while (0)
+
#else
#define PULLUP_IPHDR(pip, ptr) pip = ptr
#define PULLUP_UDPHDR(pip, ptr) pip = ptr
+#define PULLUP_TCPHDR(pip, ptr) pip = ptr
#endif
static __inline int
@@ -291,7 +299,7 @@
static int UdpAliasOut(struct libalias *, void *, int create);
static int TcpAliasIn(struct libalias *, void *);
-static int TcpAliasOut(struct libalias *, struct ip *, int, int create);
+static int TcpAliasOut(struct libalias *, void *, int, int create);
static int
@@ -910,14 +918,11 @@
struct ip *pip;
struct tcphdr *tc;
struct alias_link *lnk;
-#ifdef _KERNEL
- // XXX - m_pullup()
- pip = ptr;
-#else
- pip = ptr;
-#endif
LIBALIAS_LOCK_ASSERT(la);
+ PULLUP_TCPHDR(pip, ptr);
+ if (pip == NULL)
+ return (PKT_ALIAS_IGNORED);
tc = (struct tcphdr *)ip_next(pip);
lnk = FindUdpTcpIn(la, pip->ip_src, pip->ip_dst,
@@ -948,8 +953,9 @@
.maxpktsize = 0
};
- /* Walk out chain. */
+ /* XXX broken - Walk out chain. */
error = find_handler(IN, TCP, la, pip, &ad);
+ // XXX m_pullup()
alias_address = GetAliasAddress(lnk);
original_address = GetOriginalAddress(lnk);
@@ -1032,17 +1038,21 @@
}
static int
-TcpAliasOut(struct libalias *la, struct ip *pip, int maxpacketsize, int create)
+TcpAliasOut(struct libalias *la, void *ptr, int maxpacketsize, int create)
{
int proxy_type, error;
u_short dest_port, src_port;
u_short proxy_server_port;
struct in_addr dest_address;
struct in_addr proxy_server_address;
+ struct ip *pip;
struct tcphdr *tc;
struct alias_link *lnk;
LIBALIAS_LOCK_ASSERT(la);
+ PULLUP_TCPHDR(pip, ptr);
+ if (pip == NULL)
+ return (PKT_ALIAS_IGNORED);
tc = (struct tcphdr *)ip_next(pip);
dest_port = tc->th_dport;
src_port = tc->th_sport;
@@ -1099,8 +1109,10 @@
if (proxy_type != 0) {
SetProxyPort(lnk, dest_port);
SetProxyAddress(lnk, dest_address);
+ // XXX broken
ProxyModify(la, lnk, pip, maxpacketsize, proxy_type,
src_port);
+ // XXX m_pullup()
tc = (struct tcphdr *)ip_next(pip);
}
/* Get alias address and port */
@@ -1110,8 +1122,9 @@
/* Monitor TCP connection state */
TcpMonitorOut(lnk, tc->th_flags);
- /* Walk out chain. */
+ /* XXX broken - Walk out chain. */
error = find_handler(OUT, TCP, la, pip, &ad);
+ // XXX m_pullup()
/* Adjust TCP checksum since source port is being aliased */
/* and source address is being altered */
@@ -1341,7 +1354,7 @@
iresult = UdpAliasIn(la, ptr);
break;
case IPPROTO_TCP:
- iresult = TcpAliasIn(la, pip);
+ iresult = TcpAliasIn(la, ptr);
break;
case IPPROTO_GRE: {
int error;
@@ -1492,7 +1505,7 @@
iresult = UdpAliasOut(la, ptr, create);
break;
case IPPROTO_TCP:
- iresult = TcpAliasOut(la, pip, maxpacketsize, create);
+ iresult = TcpAliasOut(la, ptr, maxpacketsize, create);
break;
case IPPROTO_GRE: {
int error;
More information about the p4-projects
mailing list