summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Smith <dsmith@redhat.com>2010-04-07 16:12:10 -0500
committerDavid Smith <dsmith@redhat.com>2010-04-07 16:12:10 -0500
commit354c797ef6684dc64be916678efa85619571fdbb (patch)
treeb7e552bb937d2ef503378037157737f295f5a9c4
parent65dd4b7405baeee812f6d41f0ee74824b601a47a (diff)
downloadsystemtap-steved-354c797ef6684dc64be916678efa85619571fdbb.tar.gz
systemtap-steved-354c797ef6684dc64be916678efa85619571fdbb.tar.xz
systemtap-steved-354c797ef6684dc64be916678efa85619571fdbb.zip
PR 9871 (partial) fix. Removed embedded-C in ioblock.stp and ipmib.stp.
* tapset/ioblock.stp(__bio_start_sect): Converted from embedded-C to script language. * tapset/ipmib.stp: Replaced all _tcphdr_get_dport()/_tcphdr_get_sport() calls with _tcp_skb_dport()/_tcp_skb_sport() calls. Removed embedded-C functions _tcphdr_get_dport()/_tcphdr_get_sport(). (ipmib.OutRequests): Fixed for RHEL4. (_trn_unspec): New function. (_input_route_type): Originally called __input_route_type_old()/__input_route_type_new(), which were embedded-C functions. Now just does everything in script language. (__input_route_type_old): Deleted. (__input_route_type_new): Ditto. (_output_route_type): Originally called __output_route_type_old()/__output_route_type_new(), which were embedded-C functions. Now just does everything in script language. (__output_route_type_old): Deleted. (__output_route_type_new): Ditto.
-rw-r--r--tapset/ioblock.stp19
-rw-r--r--tapset/ipmib.stp121
2 files changed, 39 insertions, 101 deletions
diff --git a/tapset/ioblock.stp b/tapset/ioblock.stp
index 6376ac23..e5ad2c9b 100644
--- a/tapset/ioblock.stp
+++ b/tapset/ioblock.stp
@@ -1,6 +1,7 @@
// Block I/O tapset
// Copyright (C) 2006 Intel Corp.
// Copyright (C) 2006 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
@@ -46,19 +47,11 @@ function bio_rw_str(rw)
/* returns start sector */
function __bio_start_sect:long(bio:long)
-%{ /* pure */
- struct bio *bio;
- struct block_device *bi_bdev;
- struct hd_struct *bd_part;
- bio = (struct bio *)(long)THIS->bio;
- bi_bdev = bio? kread(&(bio->bi_bdev)) : NULL;
- bd_part = bi_bdev? kread(&(bi_bdev->bd_part)) : NULL;
- if (bd_part == NULL)
- THIS->__retvalue = -1;
- else
- THIS->__retvalue = kread(&(bd_part->start_sect));
- CATCH_DEREF_FAULT();
-%}
+{
+ bi_bdev = bio ? @cast(bio, "bio")->bi_bdev : 0
+ bd_part = bi_bdev ? @cast(bi_bdev, "block_device")->bd_part : 0
+ return bd_part ? @cast(bd_part, "hd_struct")->start_sect : -1
+}
/* returns the block device name */
function __bio_devname:string(bio:long)
diff --git a/tapset/ipmib.stp b/tapset/ipmib.stp
index fb8cd019..408b8b82 100644
--- a/tapset/ipmib.stp
+++ b/tapset/ipmib.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
@@ -88,8 +90,8 @@ function ipmib_tcp_remote_port:long (skb:long, SourceIsLocal:long)
{
th = _plunge_into_tcphdr(skb);
if ( SourceIsLocal )
- return _tcphdr_get_dport(th);
- return _tcphdr_get_sport(th);
+ return __tcp_skb_dport(th);
+ return __tcp_skb_sport(th);
}
/**
@@ -103,8 +105,8 @@ function ipmib_tcp_local_port:long (skb:long, SourceIsLocal:long)
{
th = _plunge_into_tcphdr(skb);
if ( SourceIsLocal )
- return _tcphdr_get_sport(th);
- return _tcphdr_get_dport(th);
+ return __tcp_skb_sport(th);
+ return __tcp_skb_dport(th);
}
/**
@@ -147,62 +149,48 @@ function _plunge_into_tcphdr:long (skb:long)
CATCH_DEREF_FAULT();
%}
-function _tcphdr_get_sport:long (th:long)
-%{ /* pure */
- struct tcphdr *th = (struct tcphdr *) (long) THIS->th;
- THIS->__retvalue = ntohs(kread(&(th->source)));
- CATCH_DEREF_FAULT();
-%}
-
-function _tcphdr_get_dport:long (th:long)
-%{ /* pure */
- struct tcphdr *th = (struct tcphdr *) (long) THIS->th;
- THIS->__retvalue = ntohs(kread(&(th->dest)));
- CATCH_DEREF_FAULT();
-%}
-
function _ehostunreach:long ()
-%{
+%{ /* pure */ /* unprivileged */
THIS->__retvalue = EHOSTUNREACH;
%}
function _enetunreach:long ()
-%{
+%{ /* pure */ /* unprivileged */
THIS->__retvalue = ENETUNREACH;
%}
function _icmp_dest_unreach:long ()
-%{
+%{ /* pure */ /* unprivileged */
THIS->__retvalue = ICMP_DEST_UNREACH;
%}
function _icmp_prot_unreach:long ()
-%{
+%{ /* pure */ /* unprivileged */
THIS->__retvalue = ICMP_PROT_UNREACH;
%}
function _net_rx_drop:long ()
-%{
+%{ /* pure */ /* unprivileged */
THIS->__retvalue = NET_RX_DROP;
%}
function _icmp_time_exceeded:long ()
-%{
+%{ /* pure */ /* unprivileged */
THIS->__retvalue = ICMP_TIME_EXCEEDED;
%}
function _icmp_exc_fragtime:long ()
-%{
+%{ /* pure */ /* unprivileged */
THIS->__retvalue = ICMP_EXC_FRAGTIME;
%}
function _rtn_multicast:long ()
-%{
+%{ /* pure */ /* unprivileged */
THIS->__retvalue = RTN_MULTICAST;
%}
function _rtn_broadcast:long ()
-%{
+%{ /* pure */ /* unprivileged */
THIS->__retvalue = RTN_BROADCAST;
%}
@@ -340,7 +328,7 @@ probe ipmib.ForwDatagrams=kernel.function("ip_forward_finish")
probe ipmib.OutRequests=kernel.function("ip_output"),
kernel.function("ip_mc_output")
{
- skb = $skb;
+ skb = @defined($skb) ? $skb : kernel_pointer($pskb);
op = 1;
SourceIsLocal = 1;
key = ipmib_filter_key(skb,op,SourceIsLocal);
@@ -423,70 +411,27 @@ probe ipmib.FragFails=kernel.function("ip_fragment").return
if ( key ) FragFails [key] += op;
}
+function _rtn_unspec:long ()
+%{ /* pure */ /* unprivileged */
+ THIS->__retvalue = RTN_UNSPEC;
+%}
+
function _input_route_type:long (skb:long)
{
-%( kernel_v < "2.6.31" %?
- return __input_route_type_old(skb)
-%:
- return __input_route_type_new(skb)
-%)
+ rt = (@defined(@cast(skb, "sk_buff")->_skb_dst)
+ ? @cast(skb, "sk_buff")->_skb_dst
+ : (@defined(@cast(skb, "sk_buff")->rtable)
+ ? @cast(skb, "sk_buff")->rtable
+ : 0))
+ return rt ? @cast(rt, "rtable")->rt_type : _rtn_unspec()
}
-function __input_route_type_old:long (skb:long)
-%{ /* pure */
- struct rtable *rt;
- struct sk_buff *skb = (struct sk_buff *)(long)THIS->skb;
- rt = (struct rtable *)kread(&(skb->rtable));
- if ( rt )
- THIS->__retvalue = kread(&(rt->rt_type));
- else
- THIS->__retvalue = RTN_UNSPEC;
- CATCH_DEREF_FAULT();
-%}
-
-function __input_route_type_new:long (skb:long)
-%{ /* pure */
- struct rtable *rt;
- struct sk_buff *skb = (struct sk_buff *)(long)THIS->skb;
- rt = (struct rtable *)kread(&(skb->_skb_dst));
- if ( rt )
- THIS->__retvalue = kread(&(rt->rt_type));
- else
- THIS->__retvalue = RTN_UNSPEC;
- CATCH_DEREF_FAULT();
-%}
-
function _output_route_type:long (skb:long)
{
-%( kernel_v < "2.6.31" %?
- return __output_route_type_old(skb)
-%:
- return __output_route_type_new(skb)
-%)
+ rt = (@defined(@cast(skb, "sk_buff")->_skb_dst)
+ ? @cast(skb, "sk_buff")->_skb_dst
+ : (@defined(@cast(skb, "sk_buff")->dst)
+ ? @cast(skb, "sk_buff")->dst
+ : 0))
+ return rt ? @cast(rt, "rtable")->rt_type : _rtn_unspec()
}
-
-function __output_route_type_old:long (skb:long)
-%{ /* pure */
- struct rtable *rt;
- struct dst_entry *dst;
- struct sk_buff *skb = (struct sk_buff *)(long)THIS->skb;
- dst = (struct dst_entry *)kread(&(skb->dst));
- rt = (struct rtable *)dst;
- if ( rt )
- THIS->__retvalue = kread(&(rt->rt_type));
- else
- THIS->__retvalue = RTN_UNSPEC;
- CATCH_DEREF_FAULT();
-%}
-
-function __output_route_type_new:long (skb:long)
-%{ /* pure */
- struct rtable *rt;
- struct sk_buff *skb = (struct sk_buff *)(long)THIS->skb;
- rt = (struct rtable *)kread(&(skb->_skb_dst));
- if ( rt )
- THIS->__retvalue = kread(&(rt->rt_type));
- else
- THIS->__retvalue = RTN_UNSPEC;
- CATCH_DEREF_FAULT();
-%}