<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
</head>
<body>
<p>Hi,</p>
<p>I sent in this patch last month and did not hear about any
updates since then.<br>
</p>
<p>There were a few formatting issues that have been addressed. Is
there anything more that should be done?<br>
</p>
<div class="moz-forward-container">Best regards,</div>
<div class="moz-forward-container">Florian Walbroel</div>
<div class="moz-forward-container"><br>
</div>
<div class="moz-forward-container">-------- Forwarded Message
--------
<table class="moz-email-headers-table" cellspacing="0"
cellpadding="0" border="0">
<tbody>
<tr>
<th valign="BASELINE" nowrap="nowrap" align="RIGHT">Subject:
</th>
<td>[PATCH lttng-modules] Add UDP and ICMP packet header
information to the tracepoint:</td>
</tr>
<tr>
<th valign="BASELINE" nowrap="nowrap" align="RIGHT">Date: </th>
<td>Wed, 13 Nov 2019 17:38:14 +0100</td>
</tr>
<tr>
<th valign="BASELINE" nowrap="nowrap" align="RIGHT">From: </th>
<td>Florian Walbroel <a class="moz-txt-link-rfc2396E" href="mailto:walbroel@silexica.com"><walbroel@silexica.com></a></td>
</tr>
<tr>
<th valign="BASELINE" nowrap="nowrap" align="RIGHT">To: </th>
<td><a class="moz-txt-link-abbreviated" href="mailto:lttng-dev@lists.lttng.org">lttng-dev@lists.lttng.org</a></td>
</tr>
</tbody>
</table>
<br>
<br>
* UDP transport header<br>
* ICMP transport header<br>
<br>
(Correct indentation for switch/case)<br>
<br>
Signed-off-by: Florian Walbroel <a class="moz-txt-link-rfc2396E" href="mailto:walbroel@silexica.com"><walbroel@silexica.com></a><br>
---<br>
instrumentation/events/lttng-module/net.h | 166
++++++++++++++++++++--<br>
1 file changed, 153 insertions(+), 13 deletions(-)<br>
<br>
diff --git a/instrumentation/events/lttng-module/net.h
b/instrumentation/events/lttng-module/net.h<br>
index bfa14fc..ad1892a 100644<br>
--- a/instrumentation/events/lttng-module/net.h<br>
+++ b/instrumentation/events/lttng-module/net.h<br>
@@ -11,6 +11,8 @@<br>
#include <linux/ip.h><br>
#include <linux/ipv6.h><br>
#include <linux/tcp.h><br>
+#include <linux/udp.h><br>
+#include <linux/icmp.h><br>
#include <linux/version.h><br>
#include <lttng-endian.h><br>
#include <net/sock.h><br>
@@ -85,6 +87,53 @@ static struct lttng_event_field tcpfields[] = {<br>
},<br>
};<br>
+static struct lttng_event_field udpfields[] = {<br>
+ [0] = {<br>
+ .name = "source_port",<br>
+ .type = __type_integer(uint16_t, 0, 0, 0,<br>
+ __BIG_ENDIAN, 10, none),<br>
+ },<br>
+ [1] = {<br>
+ .name = "dest_port",<br>
+ .type = __type_integer(uint16_t, 0, 0, 0,<br>
+ __BIG_ENDIAN, 10, none),<br>
+ },<br>
+ [2] = {<br>
+ .name = "len",<br>
+ .type = __type_integer(uint16_t, 0, 0, 0,<br>
+ __BIG_ENDIAN, 10, none),<br>
+ },<br>
+ [3] = {<br>
+ .name = "check",<br>
+ .type = __type_integer(uint16_t, 0, 0, 0,<br>
+ __BIG_ENDIAN, 10, none),<br>
+ },<br>
+};<br>
+<br>
+static struct lttng_event_field icmpfields[] = {<br>
+ [0] = {<br>
+ .name = "type",<br>
+ .type = __type_integer(uint8_t, 0, 0, 0,<br>
+ __BIG_ENDIAN, 10, none),<br>
+ },<br>
+ [1] = {<br>
+ .name = "code",<br>
+ .type = __type_integer(uint8_t, 0, 0, 0,<br>
+ __BIG_ENDIAN, 10, none),<br>
+ },<br>
+ [2] = {<br>
+ .name = "checksum",<br>
+ .type = __type_integer(uint16_t, 0, 0, 0,<br>
+ __BIG_ENDIAN, 10, none),<br>
+ },<br>
+ [3] = {<br>
+ .name = "gateway",<br>
+ .type = __type_integer(uint32_t, 0, 0, 0,<br>
+ __BIG_ENDIAN, 10, none),<br>
+ },<br>
+};<br>
+<br>
+<br>
static struct lttng_event_field transport_fields[] = {<br>
[0] = {<br>
.name = "unknown",<br>
@@ -102,13 +151,57 @@ static struct lttng_event_field
transport_fields[] = {<br>
.u._struct.fields = tcpfields,<br>
},<br>
},<br>
+ [2] = {<br>
+ .name = "udp",<br>
+ .type = {<br>
+ .atype = atype_struct,<br>
+ .u._struct.nr_fields = ARRAY_SIZE(udpfields),<br>
+ .u._struct.fields = udpfields,<br>
+ },<br>
+ },<br>
+ [3] = {<br>
+ .name = "icmp",<br>
+ .type = {<br>
+ .atype = atype_struct,<br>
+ .u._struct.nr_fields = ARRAY_SIZE(icmpfields),<br>
+ .u._struct.fields = icmpfields,<br>
+ },<br>
+ },<br>
};<br>
enum transport_header_types {<br>
TH_NONE = 0,<br>
TH_TCP = 1,<br>
+ TH_UDP = 2,<br>
+ TH_ICMP = 3,<br>
};<br>
+static inline enum transport_header_types
__get_transport_header_type_ip(struct sk_buff *skb)<br>
+{<br>
+ switch(ip_hdr(skb)->protocol) {<br>
+ case IPPROTO_TCP:<br>
+ return TH_TCP;<br>
+ case IPPROTO_UDP:<br>
+ return TH_UDP;<br>
+ case IPPROTO_ICMP:<br>
+ return TH_ICMP;<br>
+ }<br>
+ return TH_NONE;<br>
+}<br>
+<br>
+static inline enum transport_header_types
__get_transport_header_type_ipv6(struct sk_buff *skb)<br>
+{<br>
+ switch(ipv6_hdr(skb)->nexthdr) {<br>
+ case IPPROTO_TCP:<br>
+ return TH_TCP;<br>
+ case IPPROTO_UDP:<br>
+ return TH_UDP;<br>
+ case IPPROTO_ICMP:<br>
+ return TH_ICMP;<br>
+ }<br>
+ return TH_NONE;<br>
+}<br>
+<br>
static inline enum transport_header_types
__get_transport_header_type(struct sk_buff *skb)<br>
{<br>
if (__has_network_hdr(skb)) {<br>
@@ -123,13 +216,13 @@ static inline enum transport_header_types
__get_transport_header_type(struct sk_<br>
* header's data. This method works both for<br>
* sent and received packets.<br>
*/<br>
- if ((skb->protocol == htons(ETH_P_IP) &&<br>
- ip_hdr(skb)->protocol == IPPROTO_TCP) ||<br>
- (skb->protocol == htons(ETH_P_IPV6) &&<br>
- ipv6_hdr(skb)->nexthdr == IPPROTO_TCP))<br>
- return TH_TCP;<br>
+ if (skb->protocol == htons(ETH_P_IP)) {<br>
+ return __get_transport_header_type_ip(skb);<br>
+ } else if(skb->protocol == htons(ETH_P_IPV6)) {<br>
+ return __get_transport_header_type_ipv6(skb);<br>
+ }<br>
}<br>
- /* Fallthrough for other cases where header is not TCP. */<br>
+ /* Fallthrough for other cases where header is not recognized.
*/<br>
}<br>
return TH_NONE;<br>
}<br>
@@ -137,16 +230,36 @@ static inline enum transport_header_types
__get_transport_header_type(struct sk_<br>
static struct lttng_enum_entry proto_transport_enum_entries[] = {<br>
[0] = {<br>
.start = { .value = 0, .signedness = 0, },<br>
- .end = { .value = IPPROTO_TCP - 1, .signedness = 0, },<br>
+ .end = { .value = IPPROTO_ICMP - 1, .signedness = 0, },<br>
.string = "_unknown",<br>
},<br>
[1] = {<br>
+ .start = { .value = IPPROTO_ICMP, .signedness = 0, },<br>
+ .end = { .value = IPPROTO_ICMP, .signedness = 0, },<br>
+ .string = "_icmp",<br>
+ },<br>
+ [2] = {<br>
+ .start = { .value = IPPROTO_ICMP + 1, .signedness = 0, },<br>
+ .end = { .value = IPPROTO_TCP - 1, .signedness = 0, },<br>
+ .string = "_unknown",<br>
+ },<br>
+ [3] = {<br>
.start = { .value = IPPROTO_TCP, .signedness = 0, },<br>
.end = { .value = IPPROTO_TCP, .signedness = 0, },<br>
.string = "_tcp",<br>
},<br>
- [2] = {<br>
+ [4] = {<br>
.start = { .value = IPPROTO_TCP + 1, .signedness = 0, },<br>
+ .end = { .value = IPPROTO_UDP - 1, .signedness = 0, },<br>
+ .string = "_unknown",<br>
+ },<br>
+ [5] = {<br>
+ .start = { .value = IPPROTO_UDP, .signedness = 0, },<br>
+ .end = { .value = IPPROTO_UDP, .signedness = 0, },<br>
+ .string = "_udp",<br>
+ },<br>
+ [6] = {<br>
+ .start = { .value = IPPROTO_UDP + 1, .signedness = 0, },<br>
.end = { .value = 255, .signedness = 0, },<br>
.string = "_unknown",<br>
},<br>
@@ -169,6 +282,16 @@ static struct lttng_enum_entry
transport_enum_entries[] = {<br>
.end = { .value = TH_TCP, .signedness = 0, },<br>
.string = "_tcp",<br>
},<br>
+ [2] = {<br>
+ .start = { .value = TH_UDP, .signedness = 0, },<br>
+ .end = { .value = TH_UDP, .signedness = 0, },<br>
+ .string = "_udp",<br>
+ },<br>
+ [3] = {<br>
+ .start = { .value = TH_ICMP, .signedness = 0, },<br>
+ .end = { .value = TH_ICMP, .signedness = 0, },<br>
+ .string = "_icmp",<br>
+ },<br>
};<br>
static const struct lttng_enum_desc transport_header_type = {<br>
@@ -510,15 +633,32 @@
LTTNG_TRACEPOINT_EVENT_CLASS(net_dev_template,<br>
ctf_integer_type(unsigned char, th_type)<br>
/* Copy the transport header. */<br>
- if (th_type == TH_TCP) {<br>
+ switch (th_type) {<br>
+ case TH_TCP: {<br>
ctf_align(uint32_t)<br>
ctf_array_type(uint8_t, tcp_hdr(skb),<br>
sizeof(struct tcphdr))<br>
+ break;<br>
+ }<br>
+ case TH_UDP: {<br>
+ ctf_align(uint32_t)<br>
+ ctf_array_type(uint8_t, udp_hdr(skb),<br>
+ sizeof(struct udphdr))<br>
+ break;<br>
+ }<br>
+ case TH_ICMP: {<br>
+ ctf_align(uint32_t)<br>
+ ctf_array_type(uint8_t, icmp_hdr(skb),<br>
+ sizeof(struct udphdr))<br>
+ break;<br>
+ }<br>
+ default:<br>
+ /*<br>
+ * For any other transport header type,<br>
+ * there is nothing to do.<br>
+ */<br>
+ break;<br>
}<br>
- /*<br>
- * For any other transport header type,<br>
- * there is nothing to do.<br>
- */<br>
}<br>
)<br>
)<br>
<pre class="moz-signature">--
2.17.1
</pre>
</div>
</body>
</html>