diff options
Diffstat (limited to 'tapset/tcpmib.stp')
-rw-r--r-- | tapset/tcpmib.stp | 80 |
1 files changed, 24 insertions, 56 deletions
diff --git a/tapset/tcpmib.stp b/tapset/tcpmib.stp index 6a9b8145..45b94cc6 100644 --- a/tapset/tcpmib.stp +++ b/tapset/tcpmib.stp @@ -1,5 +1,7 @@ /* * Copyright (C) 2009 IBM Corp. + * Copyright (C) 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 * Public License (GPL); either version 2, or (at your option) any @@ -13,7 +15,6 @@ %{ #include <net/sock.h> #include <linux/tcp.h> -#include <net/tcp_states.h> #include <linux/skbuff.h> #include <net/route.h> %} @@ -43,83 +44,57 @@ global RetransSegs * */ function tcpmib_get_state:long (sk:long) -%{ /* pure */ - struct sock *sk = (struct sock *)(long)THIS->sk; - THIS->__retvalue = kread(&(sk->sk_state)); - CATCH_DEREF_FAULT(); -%} +{ + return @cast(sk, "sock", "kernel")->__sk_common->skc_state; +} /** * sfunction tcpmib_local_addr - Get the source address. * - * Returns the saddr from a struct inet_sock. + * Returns the saddr from a struct inet_sock in host order. * @sk: Pointer to a struct inet_sock. * */ function tcpmib_local_addr:long(sk:long) -%{ /* pure */ - struct inet_sock *inet = (struct inet_sock *) (long) THIS->sk; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) - THIS->__retvalue = ntohl(kread(&(inet->inet_saddr))); -#else - THIS->__retvalue = ntohl(kread(&(inet->saddr))); -#endif - CATCH_DEREF_FAULT(); -%} +{ + return ntohl(__ip_sock_saddr(sk)) +} /** * sfunction tcpmib_remote_addr - Get the remote address. * - * Returns the daddr from a struct inet_sock. + * Returns the daddr from a struct inet_sock in host order. * @sk: Pointer to a struct inet_sock. * */ function tcpmib_remote_addr:long(sk:long) -%{ /* pure */ - struct inet_sock *inet = (struct inet_sock *) (long) THIS->sk; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) - THIS->__retvalue = ntohl(kread(&(inet->inet_daddr))); -#else - THIS->__retvalue = ntohl(kread(&(inet->daddr))); -#endif - CATCH_DEREF_FAULT(); -%} +{ + return ntohl(__ip_sock_daddr(sk)) +} /** * sfunction tcpmib_local_port - Get the local port. * - * Returns the sport from a struct inet_sock. + * Returns the sport from a struct inet_sock in host order. * @sk: Pointer to a struct inet_sock. * */ function tcpmib_local_port:long(sk:long) -%{ /* pure */ - struct inet_sock *inet = (struct inet_sock *) (long) THIS->sk; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) - THIS->__retvalue = ntohs(kread(&(inet->inet_sport))); -#else - THIS->__retvalue = ntohs(kread(&(inet->sport))); -#endif - CATCH_DEREF_FAULT(); -%} +{ + return ntohs(__tcp_sock_sport(sk)) +} /** * sfunction tcpmib_remote_port - Get the remote port. * - * Returns the dport from a struct inet_sock. + * Returns the dport from a struct inet_sock in host order. * @sk: Pointer to a struct inet_sock. * */ function tcpmib_remote_port:long(sk:long) -%{ /* pure */ - struct inet_sock *inet = (struct inet_sock *) (long) THIS->sk; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) - THIS->__retvalue = ntohs(kread(&(inet->inet_dport))); -#else - THIS->__retvalue = ntohs(kread(&(inet->dport))); -#endif - CATCH_DEREF_FAULT(); -%} +{ + return ntohs(__tcp_sock_dport(sk)) +} /** * probe tcpmib.ActiveOpens - Count an active opening of a socket. @@ -327,21 +302,14 @@ function _tcpmib_input_route_type:long (skb:long) probe tcpmib.OutRsts.A=kernel.function("tcp_v4_send_reset") { -%( kernel_v >= "2.6.20" %? - sk = $sk; -%: - sk = 0; -%) + sk = (@defined($sk) ? $sk : 0) skb = $skb op = 1; if ( _is_reset(skb) ) next if (_tcpmib_input_route_type($skb) != _rtn_local() ) next; -%( kernel_v > "2.6.20" %? - key = tcpmib_filter_key(sk,op); -%: - key = ipmib_filter_key(skb,op,1); -%) + key = (@defined($sk) ? tcpmib_filter_key(sk,op) + : ipmib_filter_key(skb,op,1)) if ( key ) OutRsts[key] += op; } |