diff options
author | David Smith <dsmith@redhat.com> | 2010-03-26 13:24:38 -0500 |
---|---|---|
committer | David Smith <dsmith@redhat.com> | 2010-03-26 13:24:38 -0500 |
commit | 961479c253ded0d1a7331e8d064ffbc0ca3358d7 (patch) | |
tree | 21b11aca671c8d74c5584fec7dbd4b255b81b832 /tapset/tcp.stp | |
parent | fc80eab8cc1cbebad78df914a885cb74cbd91f22 (diff) | |
download | systemtap-steved-961479c253ded0d1a7331e8d064ffbc0ca3358d7.tar.gz systemtap-steved-961479c253ded0d1a7331e8d064ffbc0ca3358d7.tar.xz systemtap-steved-961479c253ded0d1a7331e8d064ffbc0ca3358d7.zip |
PR 9871/11338 fix in tcpmib.stp by removing embedded-C and using @defined.
* tapset/tcpmib.stp (tcpmib_get_state): Changed from embedded-C to script
code.
(tcpmib_local_addr): Instead of an embedded-C function, now calls
function from ip.stp/tcp.stp.
(tcpmib_remote_addr): Ditto.
(tcpmib_local_port): Ditto.
(tcpmib_remote_port): Ditto.
(tcpmib.OutRsts.A): Used '@defined' instead of a kernel version check.
* tapset/ip.stp (__ip_sock_saddr): Used '@defined' instead of a kernel
version check. Added RHEL4 support.
(__ip_sock_daddr): Ditto.
* tapset/tcp.stp (__tcp_sock_dport): Ditto.
(__tcp_sock_sport): Ditto.
Diffstat (limited to 'tapset/tcp.stp')
-rw-r--r-- | tapset/tcp.stp | 54 |
1 files changed, 32 insertions, 22 deletions
diff --git a/tapset/tcp.stp b/tapset/tcp.stp index 094161c9..cf6c36d8 100644 --- a/tapset/tcp.stp +++ b/tapset/tcp.stp @@ -1,7 +1,7 @@ // TCP tapset // Copyright (C) 2006 IBM Corp. // Copyright (C) 2006 Intel Corporation. -// Copyright (C) 2007 Red Hat, Inc. +// Copyright (C) 2007,2010 Red Hat, Inc. // // This file is part of systemtap, and is free software. You can // redistribute it and/or modify it under the terms of the GNU General @@ -75,12 +75,13 @@ function tcp_ts_get_info_state:long(sock:long) %} /* return the TCP destination port for a given sock */ -function __tcp_sock_dport:long (sock:long){ -%(kernel_v < "2.6.33" %? - return @cast(sock, "inet_sock")->dport -%: - return @cast(sock, "inet_sock")->inet_dport -%) +function __tcp_sock_dport:long (sock:long) +{ + return (@defined(@cast(sock, "inet_sock")->inet_dport) + ? @cast(sock, "inet_sock")->inet_dport # kernel >= 2.6.33 + : (@defined(@cast(sock, "inet_sock")->dport) + ? @cast(sock, "inet_sock", "kernel")->dport # kernel >= 2.6.11 + : @cast(sock, "inet_sock", "kernel<net/ip.h>")->inet->dport)) } /* returns the TCP header for recent (<2.6.21) kernel */ @@ -98,7 +99,8 @@ function __get_skb_tcphdr_new:long(skb:long) %} /* returns the TCP header for a given sk_buff structure */ -function __get_skb_tcphdr:long(skb:long){ +function __get_skb_tcphdr:long(skb:long) +{ %( kernel_v < "2.6.21" %? tcphdr = @cast(skb, "sk_buff")->h->raw return tcphdr @@ -108,52 +110,60 @@ function __get_skb_tcphdr:long(skb:long){ } /* returns TCP URG flag for a given sk_buff structure */ -function __tcp_skb_urg:long (tcphdr){ +function __tcp_skb_urg:long (tcphdr:long) +{ return @cast(tcphdr, "tcphdr")->urg } /* returns TCP ACK flag for a given sk_buff structure */ -function __tcp_skb_ack:long (tcphdr){ +function __tcp_skb_ack:long (tcphdr:long) +{ return @cast(tcphdr, "tcphdr")->ack } /* returns TCP PSH flag for a given sk_buff structure */ -function __tcp_skb_psh:long (tcphdr){ +function __tcp_skb_psh:long (tcphdr:long) +{ return @cast(tcphdr, "tcphdr")->psh } /* returns TCP RST flag for a given sk_buff structure */ -function __tcp_skb_rst:long (tcphdr){ +function __tcp_skb_rst:long (tcphdr:long) +{ return @cast(tcphdr, "tcphdr")->rst } /* returns TCP SYN flag for a given sk_buff structure */ -function __tcp_skb_syn:long (tcphdr){ +function __tcp_skb_syn:long (tcphdr:long) +{ return @cast(tcphdr, "tcphdr")->syn } /* returns TCP FIN flag for a given sk_buff structure */ -function __tcp_skb_fin:long (tcphdr){ +function __tcp_skb_fin:long (tcphdr:long) +{ return @cast(tcphdr, "tcphdr")->fin } /* returns TCP source port for a given sk_buff structure */ -function __tcp_skb_sport:long (tcphdr){ +function __tcp_skb_sport:long (tcphdr:long) +{ return ntohs(@cast(tcphdr, "tcphdr")->source) } /* returns TCP destination port for a given sk_buff structure */ -function __tcp_skb_dport:long (tcphdr){ +function __tcp_skb_dport:long (tcphdr:long){ return @cast(tcphdr, "tcphdr")->dest } /* return the TCP source port for a given sock */ -function __tcp_sock_sport:long (sock:long){ -%(kernel_v < "2.6.33" %? - return @cast(sock, "inet_sock")->sport -%: - return @cast(sock, "inet_sock")->inet_sport -%) +function __tcp_sock_sport:long (sock:long) +{ + return (@defined(@cast(sock, "inet_sock")->inet_sport) + ? @cast(sock, "inet_sock")->inet_sport # kernel >= 2.6.33 + : (@defined(@cast(sock, "inet_sock")->sport) + ? @cast(sock, "inet_sock", "kernel")->sport # kernel >= 2.6.11 + : @cast(sock, "inet_sock", "kernel<net/ip.h>")->inet->sport)) } global sockstate[13], sockstate_init_p |