* [PATCH 0/2] Network device tapset (cover letter)
@ 2009-09-15 17:09 leitao
2009-09-15 17:09 ` [PATCH 1/2] A network device tapset leitao
2009-09-15 17:09 ` [PATCH 2/2] A netdev example leitao
0 siblings, 2 replies; 3+ messages in thread
From: leitao @ 2009-09-15 17:09 UTC (permalink / raw)
To: systemtap
Guys, I created a new tapset for network device specific things.
Please, review and let me know what I can do to improve it.
I didn't find a better way to implement netdev.change_mac,
and I am sure someone will clear my ideas there.
root (2):
A tapset that helps those who are working with network devices.
A network device example
tapset/netdev.stp | 178 +++++++++++++++++++++++
testsuite/systemtap.examples/network/netdev.stp | 62 ++++++++
2 files changed, 240 insertions(+), 0 deletions(-)
create mode 100644 tapset/netdev.stp
create mode 100644 testsuite/systemtap.examples/network/netdev.stp
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] A network device tapset
2009-09-15 17:09 [PATCH 0/2] Network device tapset (cover letter) leitao
@ 2009-09-15 17:09 ` leitao
2009-09-15 17:09 ` [PATCH 2/2] A netdev example leitao
1 sibling, 0 replies; 3+ messages in thread
From: leitao @ 2009-09-15 17:09 UTC (permalink / raw)
To: systemtap; +Cc: Breno Leitão
A tapset that helps those who are working with network devices.
This tapset tries to cover the most used functions related to
these devices
Signed-off-by: Breno Leitão <leitao@linux.vnet.ibm.com>
---
tapset/netdev.stp | 178 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 178 insertions(+), 0 deletions(-)
create mode 100644 tapset/netdev.stp
diff --git a/tapset/netdev.stp b/tapset/netdev.stp
new file mode 100644
index 0000000..dfd9c2b
--- /dev/null
+++ b/tapset/netdev.stp
@@ -0,0 +1,178 @@
+// Network devices tapset
+// Copyright (C) 2009, IBM Inc.
+// Author : Breno Leitao <leitao@linux.vnet.ibm.com>
+//
+// This file is free software. You can redistribute it and/or modify it under
+// the terms of the GNU General Public License (GPL), version 2.
+//
+
+/* A function that returns the device name given the net_device struct */
+function get_netdev_name:string (addr:long) {
+ return kernel_string(@cast(addr, "net_device")->name)
+}
+
+/**
+ * probe netdev.change_mtu - Called when the netdev MTU is changed
+ * @dev: The device that will have the MTU changed
+ * @old_mtu: The current MTU
+ * @new_mtu: The new MTU
+ */
+probe netdev.change_mtu = kernel.function("dev_set_mtu"){
+ old_mtu = @cast($dev, "net_device")->mtu
+ new_mtu = $new_mtu
+ dev = get_netdev_name($dev)
+}
+
+/**
+ * probe netdev.open - Called when the device is opened
+ * @dev: The device that is going to be opened
+ */
+probe netdev.open = kernel.function("dev_open") {
+ dev = get_netdev_name($dev)
+}
+
+/**
+ * probe netdev.close - Called when the device is closed
+ * @dev: The device that is going to be closed
+ */
+probe netdev.close = kernel.function("dev_close"){
+ dev = get_netdev_name($dev)
+}
+
+/**
+ * probe netdev.hard_tx - Called when the devices is going to TX (hard)
+ * @dev: The device scheduled to transmit
+ * @protocol: The protocol used in the transmission
+ */
+probe netdev.hard_tx = kernel.function("dev_hard_start_xmit"){
+ dev = get_netdev_name($dev)
+ protocol = @cast($skb, "sk_buff")->protocol
+}
+
+/**
+ * probe netdev.queue_tx - Called when the device is going to TX (queued)
+ * @dev: The device scheduled to transmit
+ * @protocol: The protocol used in the transmission
+ */
+probe netdev.queue_tx = kernel.function("dev_queue_xmit"){
+ netdev = @cast($skb, "sk_buff")->dev
+ dev = get_netdev_name(netdev)
+ protocol = @cast($skb, "sk_buff")->protocol
+}
+
+/**
+ * probe netdev.rx - Called when the device is going to receive a packet
+ * @dev: The device received the packet
+ * @protocol: The packet protocol
+ */
+probe netdev.rx = kernel.function("netif_rx"){
+ netdev = @cast($skb, "sk_buff")->dev
+ dev = get_netdev_name(netdev)
+ protocol = @cast($skb, "sk_buff")->protocol
+}
+
+/**
+ * probe netdev.rx_skb - Called when the SKB is going to be processed
+ * @dev: The device received the packet
+ * @protocol: The packet protocol
+ */
+probe netdev.rx_skb = kernel.function("netif_receive_skb"){
+ netdev = @cast($skb, "sk_buff")->dev
+ dev = get_netdev_name(netdev)
+ protocol = @cast($skb, "sk_buff")->protocol
+}
+
+/**
+ * probe netdev.change_rx_flag - Called when the device RX flag will be changed
+ * @dev: The device that will be changed
+ * @flags: The new flags
+ */
+probe netdev.change_rx_flag = kernel.function("dev_change_rx_flags"){
+ dev = get_netdev_name($dev)
+ flags = $flags
+}
+
+/**
+ * probe netdev.set_promiscuity - Called when the device enters/leaves promiscuity
+ * @dev: The device that is entering/leaving promiscuity mode
+ * @enable: If the device is entering promiscuity mode
+ * @disable: If the device is leaving promiscuity mode
+ * @inc: Count the number of promiscuity openers
+ */
+probe netdev.set_promiscuity = kernel.function("dev_set_promiscuity"){
+ dev = get_netdev_name($dev)
+ if ($inc){
+ enable = 1
+ } else {
+ disable = 1
+ }
+ inc = $inc
+}
+
+/**
+ * probe netdev.ioctl - Called when the device suffers an IOCTL
+ * @cmd: The IOCTL request
+ * @arg: The IOCTL argument (usually the netdev interface)
+ */
+probe netdev.ioctl = kernel.function("dev_ioctl"){
+ cmd = $cmd
+ arg = user_string($arg)
+}
+
+/**
+ * probe netdev.register - Called when the device is registered
+ * @dev: The device that is going to be registered
+ */
+probe netdev.register = kernel.function("register_netdevice"),
+ kernel.function("register_netdev"){
+ dev = get_netdev_name($dev)
+}
+
+/**
+ * probe netdev.unregister - Called when the device is being unregistered
+ * @dev: The device that is going to be unregistered
+ */
+probe netdev.unregister = kernel.function("unregister_netdev"){
+ dev = get_netdev_name($dev)
+}
+
+/**
+ * probe netdev.get_stats - Called when someone asks the device statistics
+ * @dev: The device that is going to provide the statistics
+ */
+probe netdev.get_stats = kernel.function("dev_get_stats"){
+ dev = get_netdev_name($dev)
+}
+
+/**
+ * probe netdev.change_mac - Called when the netdev has the MAC changed
+ * @dev: The device that will have the MTU changed
+ * @mac_len: The MAC length
+ * @old_mac: The current MAC address
+ * @new_mac: The new MAC address
+ */
+probe netdev.change_mac = kernel.function("dev_set_mac_address"){
+ dev = get_netdev_name($dev)
+ mac_len = @cast($dev, "net_device")->addr_len
+
+ // Old MAC Address
+ zero = @cast($dev, "net_device")->dev_addr[0]
+ one = @cast($dev, "net_device")->dev_addr[1]
+ two = @cast($dev, "net_device")->dev_addr[2]
+ three = @cast($dev, "net_device")->dev_addr[3]
+ four = @cast($dev, "net_device")->dev_addr[4]
+ five = @cast($dev, "net_device")->dev_addr[5]
+ new_mac = sprintf("%x:%x:%x:%x:%x:%x", zero, one, two, three,
+ four, five)
+
+ // New MAC Address
+ zero = @cast($dev, "sockaddr")->sa_data[0]
+ one = @cast($dev, "sockaddr")->sa_data[1]
+ two = @cast($dev, "sockaddr")->sa_data[2]
+ three = @cast($dev, "sockaddr")->sa_data[3]
+ four = @cast($dev, "sockaddr")->sa_data[4]
+ five = @cast($dev, "sockaddr")->sa_data[5]
+ old_mac = sprintf("%x:%x:%x:%x:%x:%x", zero, one, two, three,
+ four, five)
+}
+
--
1.6.0.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] A netdev example
2009-09-15 17:09 [PATCH 0/2] Network device tapset (cover letter) leitao
2009-09-15 17:09 ` [PATCH 1/2] A network device tapset leitao
@ 2009-09-15 17:09 ` leitao
1 sibling, 0 replies; 3+ messages in thread
From: leitao @ 2009-09-15 17:09 UTC (permalink / raw)
To: systemtap; +Cc: Breno Leitão
Add a example that cover the network device tapset. This example
just add simple probes and display what is going one with all
the network devices.
Signed-off-by: Breno Leitão <leitao@linux.vnet.ibm.com>
---
testsuite/systemtap.examples/network/netdev.stp | 62 +++++++++++++++++++++++
1 files changed, 62 insertions(+), 0 deletions(-)
create mode 100644 testsuite/systemtap.examples/network/netdev.stp
diff --git a/testsuite/systemtap.examples/network/netdev.stp b/testsuite/systemtap.examples/network/netdev.stp
new file mode 100644
index 0000000..42b79c5
--- /dev/null
+++ b/testsuite/systemtap.examples/network/netdev.stp
@@ -0,0 +1,62 @@
+#! /usr/bin/env stap
+
+############################################################
+# netdev.stp
+# Author: Breno Leitao <leitao@linux.vnet.ibm.com>
+# An example script to show how a netdev works and its
+# functions
+############################################################
+
+
+probe netdev.get_stats{
+ printf("%s was asked for statistics structure\n", dev)
+}
+
+probe netdev.register{
+ printf("Registering netdev %s\n", dev)
+}
+
+probe netdev.unregister{
+ printf("Unregistering netdev %s\n", dev)
+}
+
+probe netdev.ioctl{
+ printf("Netdev ioctl raised with param: %d and arg: %s\n", cmd, arg)
+}
+
+probe netdev.set_promiscuity {
+ if (enable)
+ printf("Device %s entering in prosmicuous mode\n", dev)
+ else
+ printf("Device %s leaving prosmicuous mode\n", dev)
+}
+
+probe netdev.change_rx_flag {
+ printf("Device %s is changing its RX flags to %d\n", dev, flags)
+}
+
+probe netdev.change_mtu {
+ printf("Changing MTU on device %s from %d to %d\n", dev,
+ old_mtu, new_mtu)
+}
+
+probe netdev.change_mac {
+ printf("Changing MAC adddres on device %s from %s to %s\n",
+ dev, old_mac, new_mac)
+}
+
+probe netdev.queue_tx {
+ printf("Device %s is sending (queued) a packet with protocol %d\n", dev, protocol)
+}
+
+probe netdev.hard_tx {
+ printf("Device %s is sending (hard) a packet with protocol %d\n", dev, protocol)
+}
+
+probe netdev.rx {
+ printf("Device %s received a packet with protocol %d\n", dev, protocol)
+}
+
+probe netdev.rx_skb {
+ printf("Device %s is going to process a packet with protocol %d\n", dev, protocol)
+}
--
1.6.0.2
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-09-15 17:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-15 17:09 [PATCH 0/2] Network device tapset (cover letter) leitao
2009-09-15 17:09 ` [PATCH 1/2] A network device tapset leitao
2009-09-15 17:09 ` [PATCH 2/2] A netdev example leitao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).