PERFORCE change 113687 for review
Paolo Pisati
piso at FreeBSD.org
Tue Jan 30 01:43:07 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=113687
Change 113687 by piso at piso_newluxor on 2007/01/30 01:43:01
In TcpMonitorIn() and TcpMonitorOut() we don't need any pointer to the ip or tcp header:
pass down the tcp flags field and axe an ip_next() usage.
Affected files ...
.. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.c#39 edit
Differences ...
==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.c#39 (text+ko) ====
@@ -170,48 +170,42 @@
*/
/* Local prototypes */
-static void TcpMonitorIn(struct ip *, struct alias_link *);
+static void TcpMonitorIn(struct alias_link *, u_char th_flags);
-static void TcpMonitorOut(struct ip *, struct alias_link *);
+static void TcpMonitorOut(struct alias_link *, u_char th_flags);
static void
-TcpMonitorIn(struct ip *pip, struct alias_link *lnk)
+TcpMonitorIn(struct alias_link *lnk, u_char th_flags)
{
- struct tcphdr *tc;
- tc = (struct tcphdr *)ip_next(pip);
-
switch (GetStateIn(lnk)) {
case ALIAS_TCP_STATE_NOT_CONNECTED:
- if (tc->th_flags & TH_RST)
+ if (th_flags & TH_RST)
SetStateIn(lnk, ALIAS_TCP_STATE_DISCONNECTED);
- else if (tc->th_flags & TH_SYN)
+ else if (th_flags & TH_SYN)
SetStateIn(lnk, ALIAS_TCP_STATE_CONNECTED);
break;
case ALIAS_TCP_STATE_CONNECTED:
- if (tc->th_flags & (TH_FIN | TH_RST))
+ if (th_flags & (TH_FIN | TH_RST))
SetStateIn(lnk, ALIAS_TCP_STATE_DISCONNECTED);
break;
}
}
static void
-TcpMonitorOut(struct ip *pip, struct alias_link *lnk)
+TcpMonitorOut(struct alias_link *lnk, u_char th_flags)
{
- struct tcphdr *tc;
-
- tc = (struct tcphdr *)ip_next(pip);
switch (GetStateOut(lnk)) {
case ALIAS_TCP_STATE_NOT_CONNECTED:
- if (tc->th_flags & TH_RST)
+ if (th_flags & TH_RST)
SetStateOut(lnk, ALIAS_TCP_STATE_DISCONNECTED);
- else if (tc->th_flags & TH_SYN)
+ else if (th_flags & TH_SYN)
SetStateOut(lnk, ALIAS_TCP_STATE_CONNECTED);
break;
case ALIAS_TCP_STATE_CONNECTED:
- if (tc->th_flags & (TH_FIN | TH_RST))
+ if (th_flags & (TH_FIN | TH_RST))
SetStateOut(lnk, ALIAS_TCP_STATE_DISCONNECTED);
break;
}
@@ -954,7 +948,7 @@
ADJUST_CHECKSUM(accumulate, pip->ip_sum);
/* Monitor TCP connection state */
- TcpMonitorIn(pip, lnk);
+ TcpMonitorIn(lnk, tc->th_flags);
return (PKT_ALIAS_OK);
}
@@ -1038,7 +1032,7 @@
alias_address = GetAliasAddress(lnk);
/* Monitor TCP connection state */
- TcpMonitorOut(pip, lnk);
+ TcpMonitorOut(lnk, tc->th_flags);
/* Walk out chain. */
error = find_handler(OUT, TCP, la, pip, &ad);
More information about the p4-projects
mailing list