From cd8a0489f48f50eb0e1b7fa2f5289670cc26caa3 Mon Sep 17 00:00:00 2001 From: Breno Leitao Date: Wed, 16 Sep 2009 14:37:15 -0400 Subject: Adding a some new probes to the networking.stp tapset A tapset that helps those who are working with network devices. These new fnctions try to cover almost all functions related to these network devices. Signed-off-by: Josh Stone --- tapset/networking.stp | 177 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 177 insertions(+) (limited to 'tapset/networking.stp') diff --git a/tapset/networking.stp b/tapset/networking.stp index f6d78536..bcc99789 100644 --- a/tapset/networking.stp +++ b/tapset/networking.stp @@ -8,6 +8,12 @@ // // This family of probe points is used to probe the activities of the network device. // + +/* 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.receive - Data recieved from network device. * @dev_name: The name of the device. e.g: eth0, ath1. @@ -78,3 +84,174 @@ probe netdev.transmit protocol = $skb->protocol truesize = $skb->truesize } + +/** + * probe netdev.change_mtu - Called when the netdev MTU is changed + * @dev_name: 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 = $dev->mtu + new_mtu = $new_mtu + dev_name = get_netdev_name($dev) +} + +/** + * probe netdev.open - Called when the device is opened + * @dev_name: The device that is going to be opened + */ +probe netdev.open + = kernel.function("dev_open") +{ + dev_name = get_netdev_name($dev) +} + +/** + * probe netdev.close - Called when the device is closed + * @dev_name: The device that is going to be closed + */ +probe netdev.close + = kernel.function("dev_close") +{ + dev_name = get_netdev_name($dev) +} + +/** + * probe netdev.hard_transmit - Called when the devices is going to TX (hard) + * @dev_name: The device scheduled to transmit + * @protocol: The protocol used in the transmission + * @length: The length of the transmit buffer. + * @truesize: The size of the the data to be transmitted. + */ +probe netdev.hard_transmit + = kernel.function("dev_hard_start_xmit") +{ + dev_name = get_netdev_name($dev) + protocol = $skb->protocol + length = $skb->len + truesize = $skb->truesize +} + +/** + * probe netdev.rx - Called when the device is going to receive a packet + * @dev_name: The device received the packet + * @protocol: The packet protocol + */ +probe netdev.rx + = kernel.function("netif_rx") +{ + netdev = $skb->dev + dev_name = get_netdev_name(netdev) + protocol = $skb->protocol +} + +/** + * probe netdev.change_rx_flag - Called when the device RX flag will be changed + * @dev_name: The device that will be changed + * @flags: The new flags + */ +probe netdev.change_rx_flag + = kernel.function("dev_change_rx_flags") +{ + dev_name = get_netdev_name($dev) + flags = $flags +} + +/** + * probe netdev.set_promiscuity - Called when the device enters/leaves promiscuity + * @dev_name: 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_name = 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_name: The device that is going to be registered + */ +probe netdev.register + = kernel.function("register_netdevice"), + kernel.function("register_netdev") +{ + dev_name = get_netdev_name($dev) +} + +/** + * probe netdev.unregister - Called when the device is being unregistered + * @dev_name: The device that is going to be unregistered + */ +probe netdev.unregister + = kernel.function("unregister_netdev") +{ + dev_name = get_netdev_name($dev) +} + +/** + * probe netdev.get_stats - Called when someone asks the device statistics + * @dev_name: The device that is going to provide the statistics + */ +probe netdev.get_stats + = kernel.function("dev_get_stats") +{ + dev_name = get_netdev_name($dev) +} + +/** + * probe netdev.change_mac - Called when the netdev_name has the MAC changed + * @dev_name: 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_name = get_netdev_name($dev) + mac_len = $dev->addr_len + + // Old MAC Address + zero = $dev->dev_addr[0] + one = $dev->dev_addr[1] + two = $dev->dev_addr[2] + three =$dev->dev_addr[3] + four = $dev->dev_addr[4] + five = $dev->dev_addr[5] + old_mac = sprintf("%02x:%02x:%02x:%02x:%02x:%02x", + zero, one, two, three, four, five) + + // New MAC Address + zero = $sa->sa_data[0] + one = $sa->sa_data[1] + two = $sa->sa_data[2] + three =$sa->sa_data[3] + four =$sa->sa_data[4] + five = $sa->sa_data[5] + new_mac = sprintf("%02x:%02x:%02x:%02x:%02x:%02x", + zero, one, two, three, four, five) +} -- cgit From b57367210bd84bdbf6a78785905127fb7711e567 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 16 Sep 2009 15:23:50 -0700 Subject: Spelling fixes in the tapsets --- tapset/networking.stp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tapset/networking.stp') diff --git a/tapset/networking.stp b/tapset/networking.stp index bcc99789..0c9d8afb 100644 --- a/tapset/networking.stp +++ b/tapset/networking.stp @@ -15,10 +15,10 @@ function get_netdev_name:string (addr:long) { } /** - * probe netdev.receive - Data recieved from network device. + * probe netdev.receive - Data received from network device. * @dev_name: The name of the device. e.g: eth0, ath1. * @length: The length of the receiving buffer. - * @protocol: Protocol of recieved packet. + * @protocol: Protocol of received packet. * */ /// protocol @@ -72,7 +72,7 @@ probe netdev.receive * @dev_name: The name of the device. e.g: eth0, ath1. * @length: The length of the transmit buffer. * @protocol: The protocol of this packet. - * @truesize: The size of the the data to be transmitted. + * @truesize: The size of the data to be transmitted. * */ // Queue a buffer for transmission to a network device @@ -124,7 +124,7 @@ probe netdev.close * @dev_name: The device scheduled to transmit * @protocol: The protocol used in the transmission * @length: The length of the transmit buffer. - * @truesize: The size of the the data to be transmitted. + * @truesize: The size of the data to be transmitted. */ probe netdev.hard_transmit = kernel.function("dev_hard_start_xmit") -- cgit From 597c982e513c9fef84e64e9aaef77cb736245096 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 17 Sep 2009 14:42:04 -0700 Subject: Remove temporaries in netdev.change_mac As reported by dsmith, reusing temporary locals will prevent our limited optimizer from eliminating code. I'm getting rid of these particular locals altogether. * tapset/networking.stp (netdev.change_mac): Don't write mac intermediates into locals; just pass them directly to sprintf. --- tapset/networking.stp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'tapset/networking.stp') diff --git a/tapset/networking.stp b/tapset/networking.stp index 0c9d8afb..4732a72d 100644 --- a/tapset/networking.stp +++ b/tapset/networking.stp @@ -236,22 +236,14 @@ probe netdev.change_mac mac_len = $dev->addr_len // Old MAC Address - zero = $dev->dev_addr[0] - one = $dev->dev_addr[1] - two = $dev->dev_addr[2] - three =$dev->dev_addr[3] - four = $dev->dev_addr[4] - five = $dev->dev_addr[5] old_mac = sprintf("%02x:%02x:%02x:%02x:%02x:%02x", - zero, one, two, three, four, five) + $dev->dev_addr[0], $dev->dev_addr[1], + $dev->dev_addr[2], $dev->dev_addr[3], + $dev->dev_addr[4], $dev->dev_addr[5]) // New MAC Address - zero = $sa->sa_data[0] - one = $sa->sa_data[1] - two = $sa->sa_data[2] - three =$sa->sa_data[3] - four =$sa->sa_data[4] - five = $sa->sa_data[5] new_mac = sprintf("%02x:%02x:%02x:%02x:%02x:%02x", - zero, one, two, three, four, five) + $sa->sa_data[0], $sa->sa_data[1], + $sa->sa_data[2], $sa->sa_data[3], + $sa->sa_data[4], $sa->sa_data[5]) } -- cgit