This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[PATCH] Adding kerneldoc and fixing bare pointers
This patch create a kerneldoc comments for the main functions used by
these tapsets.
Also some kread() are used instead of bare pointers
Signed-off-by: Breno Leitao <leitao@linux.vnet.ibm.com>
---
tapset/dccp_ccid3_hc_tx_sock.stp | 4 ++--
tapset/inet_sock.stp | 21 +++++++++++++++++++++
tapset/iphdr.stp | 17 ++++++++++++++++-
tapset/sk.stp | 10 +++++++++-
tapset/tcp_states.stp | 16 ++++++++++++++++
tapset/tcphdr.stp | 20 ++++++++++++++++++++
6 files changed, 84 insertions(+), 4 deletions(-)
diff --git a/tapset/dccp_ccid3_hc_tx_sock.stp b/tapset/dccp_ccid3_hc_tx_sock.stp
index eadf183..5309054 100644
--- a/tapset/dccp_ccid3_hc_tx_sock.stp
+++ b/tapset/dccp_ccid3_hc_tx_sock.stp
@@ -15,8 +15,8 @@ struct ccid {
};
static inline void *ccid_priv(const struct ccid *ccid)
-{
- return (void *)ccid->ccid_priv;
+%{
+ return (void *)kread(&(ccid))->ccid_priv;
}
%}
diff --git a/tapset/inet_sock.stp b/tapset/inet_sock.stp
index e12d5f4..99f7516 100644
--- a/tapset/inet_sock.stp
+++ b/tapset/inet_sock.stp
@@ -10,6 +10,11 @@
#include <linux/in.h>
%}
+/**
+ * sfunction inet_sk_ntop - returns a string representation from an integer
+ IP number
+ * @addr: the ip represented as an integer
+ */
function inet_sk_ntop:string (addr:long)
%{
__be32 ip;
@@ -18,6 +23,10 @@ function inet_sk_ntop:string (addr:long)
snprintf(THIS->__retvalue, MAXSTRINGLEN, NIPQUAD_FMT, NIPQUAD(ip));
%}
+/**
+ * sfunction inet_sk_saddr - returns the source IP address for a given sock
+ * @sk: the socket (struct sock)
+ */
function inet_sk_saddr:long (sk:long)
%{
struct inet_sock *inet = inet_sk((struct sock *)(long)THIS->sk);
@@ -25,6 +34,10 @@ function inet_sk_saddr:long (sk:long)
CATCH_DEREF_FAULT();
%}
+/**
+ * sfunction inet_sk_daddr - returns the destination IP address for a given sock
+ * @sk: the socket (struct sock)
+ */
function inet_sk_daddr:long (sk:long)
%{
struct inet_sock *inet = inet_sk((struct sock *)(long)THIS->sk);
@@ -32,6 +45,10 @@ function inet_sk_daddr:long (sk:long)
CATCH_DEREF_FAULT();
%}
+/**
+ * sfunction inet_sk_sport - returns the TCP source port for a given sock
+ * @sk: the socket (struct sock)
+ */
function inet_sk_sport:long (sk:long)
%{
struct inet_sock *inet = inet_sk((struct sock *)(long)THIS->sk);
@@ -39,6 +56,10 @@ function inet_sk_sport:long (sk:long)
CATCH_DEREF_FAULT();
%}
+/**
+ * sfunction inet_sk_dport - returns the TCP destination port for a given sock
+ * @sk: the socket (struct sock)
+ */
function inet_sk_dport:long (sk:long)
%{
struct inet_sock *inet = inet_sk((struct sock *)(long)THIS->sk);
diff --git a/tapset/iphdr.stp b/tapset/iphdr.stp
index fffdc77..83dfafe 100644
--- a/tapset/iphdr.stp
+++ b/tapset/iphdr.stp
@@ -12,7 +12,7 @@
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,21)
static inline struct iphdr *ip_hdr(struct sk_buff *skb)
{
- return (struct iphdr *)skb->nh.raw;
+ return (struct iphdr *) kread(&(skb))->nh.raw;
}
#endif
%}
@@ -39,6 +39,11 @@ global IPPROTO_SCTP = 132 // Stream Control Transport Protocol
global IPPROTO_UDPLITE = 136 // UDP-Lite (RFC 3828)
global IPPROTO_RAW = 255 // Raw IP packets
+/**
+ * sfunction skb_iphdr_saddr - returns the source IP address for a given
+ * socket buffer
+ * @skb: the socket buffer (struct sk_buff)
+ */
function skb_iphdr_saddr:long (skb:long)
%{
struct iphdr *iph = ip_hdr((struct sk_buff *)THIS->skb);
@@ -47,6 +52,11 @@ function skb_iphdr_saddr:long (skb:long)
CATCH_DEREF_FAULT();
%}
+/**
+ * sfunction skb_iphdr_daddr - returns the destination IP address for a
+ * given socket buffer
+ * @skb: the socket buffer (struct sk_buff)
+ */
function skb_iphdr_daddr:long (skb:long)
%{
struct iphdr *iph = ip_hdr((struct sk_buff *)THIS->skb);
@@ -55,6 +65,11 @@ function skb_iphdr_daddr:long (skb:long)
CATCH_DEREF_FAULT();
%}
+/**
+ * sfunction skb_iphdr_daddr - returns the protocol number for a given
+ * socket buffer
+ * @skb: the socket buffer (struct sk_buff)
+ */
function skb_iphdr_protocol:long (skb:long)
%{
struct iphdr *iph = ip_hdr((struct sk_buff *)THIS->skb);
diff --git a/tapset/sk.stp b/tapset/sk.stp
index 936c747..9bdeb0f 100644
--- a/tapset/sk.stp
+++ b/tapset/sk.stp
@@ -9,13 +9,21 @@
#include <net/sock.h>
%}
+/**
+ * sfunction sk_state - returns the connection state for a given sock_common
+ * @sk: a sock_common (struct sock_common)
+ */
function sk_state:long (sk:long)
%{
struct sock_common *skc = (struct sock_common *)(long)THIS->sk;
THIS->__retvalue = kread(&(skc->skc_state));
CATCH_DEREF_FAULT();
%}
-
+/**
+ * sfunction sk_protocol - returns which protocol a given a socket belongs
+ * in the network family
+ * @sk: a socket buffer (struct sk_buff)
+ */
function sk_protocol:long (sk:long)
%{
struct sock *sk = (struct sock *)(long)THIS->sk;
diff --git a/tapset/tcp_states.stp b/tapset/tcp_states.stp
index 6a55558..24f364f 100644
--- a/tapset/tcp_states.stp
+++ b/tapset/tcp_states.stp
@@ -20,6 +20,11 @@ global TCP_LAST_ACK=9
global TCP_LISTEN=10
global TCP_CLOSING=11
+/**
+ * sfunction tcp_state_name - returns a string representation of a
+ TCP/IP state number
+ * @state: the TCP/IP state
+ */
function tcp_state_name:string (state:long)
%{
const char *s = "unknown";
@@ -41,11 +46,22 @@ function tcp_state_name:string (state:long)
strlcpy(THIS->__retvalue, s, MAXSTRINGLEN);
%}
+/**
+ * probe tcp_state.tcp_close_state - returns the socket that is
+ * going to be in the closed
+ * state
+ * @sk: the socket(struct sock) of the connection going to be closed
+ */
probe tcp_state.tcp_close_state = kernel.function("tcp_close_state")
{
sk = $sk
}
+/**
+ * probe tcp_state.tcp_fin - returns the socket that just received a
+ * FIN packet
+ * @sk: the socket(struct sock) of the connection that received FIN
+ */
probe tcp_state.tcp_fin = kernel.function("tcp_fin")
{
sk = $sk
diff --git a/tapset/tcphdr.stp b/tapset/tcphdr.stp
index 7be56e4..47669ea 100644
--- a/tapset/tcphdr.stp
+++ b/tapset/tcphdr.stp
@@ -19,6 +19,11 @@ static inline struct tcphdr *tcp_hdr(struct sk_buff *skb)
#endif
%}
+/**
+ * sfunction skb_tcphdr_sport - return the TCP source port for a given socket
+ * buffer
+ * @skb: the socket buffer (struct sk_buff)
+ */
function skb_tcphdr_sport:long (skb:long)
%{
struct tcphdr *tp = tcp_hdr((struct sk_buff *)THIS->skb);
@@ -27,6 +32,11 @@ function skb_tcphdr_sport:long (skb:long)
CATCH_DEREF_FAULT();
%}
+/**
+ * sfunction skb_tcphdr_dport - returns the TCP destination port for a given
+ * socket buffer
+ * @skb: the socket buffer (struct sk_buff)
+ */
function skb_tcphdr_dport:long (skb:long)
%{
struct tcphdr *tp = tcp_hdr((struct sk_buff *)THIS->skb);
@@ -35,6 +45,11 @@ function skb_tcphdr_dport:long (skb:long)
CATCH_DEREF_FAULT();
%}
+/**
+ * sfunction skb_tcphdr_sport - returns the TCP source port for a given socket
+ * buffer
+ * @skb: the socket buffer (struct sk_buff)
+ */
function skb_iphdr_tcp_sport:long (skb:long)
%{
struct iphdr *iph = ip_hdr((struct sk_buff *)THIS->skb);
@@ -44,6 +59,11 @@ function skb_iphdr_tcp_sport:long (skb:long)
CATCH_DEREF_FAULT();
%}
+/**
+ * sfunction skb_tcphdr_dport - returns the TCP destination port for a given
+ * socket buffer
+ * @skb: the socket buffer (struct sk_buff)
+ */
function skb_iphdr_tcp_dport:long (skb:long)
%{
struct iphdr *iph = ip_hdr((struct sk_buff *)THIS->skb);
--
1.6.0.2