Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
config HOMA
tristate "The Homa transport protocol"
depends on IPV6
#ifndef __STRIP__ /* See strip.py */
depends on NET_UDP_TUNNEL
#endif /* See strip.py */

help
Homa is a network transport protocol for communication within
Expand Down
8 changes: 8 additions & 0 deletions dissector/homa.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ WS_DLL_PUBLIC_DEF const int plugin_want_minor = WIRESHARK_VERSION_MINOR;

#define HOMA_PROTO 0xFD

/* Fixed UDP destination port used by Homa's optional UDP hijacking
* feature (see HOMA_UDP_HIJACK_PORT in homa_wire.h); packets encapsulated
* this way carry a Homa common header immediately after the UDP header,
* so the same dissector used for IPPROTO_HOMA also works for them.
*/
#define HOMA_UDP_HIJACK_PORT 54321

#define HOMA_HEADER_TYPE_OFFSET 13
#define HOMA_DATA_PACKET 0x10
#define HOMA_GRANT_PACKET 0x11
Expand Down Expand Up @@ -396,6 +403,7 @@ static void proto_reg_handoff_homa(void)

homa_handle = create_dissector_handle(dissect_homa, proto_homa);
dissector_add_uint("ip.proto", HOMA_PROTO, homa_handle);
dissector_add_uint("udp.port", HOMA_UDP_HIJACK_PORT, homa_handle);
}

WS_DLL_PUBLIC void plugin_register(void)
Expand Down
45 changes: 43 additions & 2 deletions homa_devel.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#include "homa_impl.h"
#include "homa_devel.h"
#include "homa_grant.h"
#ifndef __STRIP__ /* See strip.py */
#include "homa_hijack.h"
#endif /* See strip.py */
#include "homa_peer.h"
#include "homa_rpc.h"
#ifndef __STRIP__ /* See strip.py */
Expand Down Expand Up @@ -122,6 +125,38 @@ char *homa_print_ipv6_addr(const struct in6_addr *addr)
return buffer;
}

/**
* homa_print_hdr_offset() - Determine how many bytes past
* skb_transport_header(skb) the packet's homa_common_hdr begins, for use
* by homa_print_packet() and homa_print_packet_short(). Those functions
* are invoked both on incoming packets (already positioned at the Homa
* header by the receive path) and on outgoing packets at the point they
* are handed to ip_queue_xmit()/ip6_xmit(), which is before any IP
* header has been added; homa_skb_inner_hdr() can't be used here because
* its UDP-encapsulation detection relies on an IP header (and
* skb->protocol) that doesn't exist yet at that point. Instead, this
* peeks directly at skb_transport_header(skb): if it looks like a real
* UDP header for the UDP-hijack port, the Homa header follows
* immediately after it; otherwise skb_transport_header(skb) already
* points at the Homa header.
* @skb: Packet to examine.
* Return: Number of bytes between skb_transport_header(skb) and the
* packet's homa_common_hdr.
*/
static int homa_print_hdr_offset(struct sk_buff *skb)
{
#ifndef __STRIP__ /* See strip.py */
struct udphdr *uh = (struct udphdr *)skb_transport_header(skb);

if (skb->len >= (int)(skb_transport_offset(skb) + sizeof(*uh) +
sizeof(struct homa_common_hdr)) &&
uh->dest == htons(HOMA_UDP_HIJACK_PORT) &&
uh->source == htons(HOMA_UDP_HIJACK_PORT))
return sizeof(*uh);
#endif /* See strip.py */
return 0;
}

/**
* homa_print_packet() - Print a human-readable string describing the
* information in a Homa packet.
Expand All @@ -137,14 +172,17 @@ char *homa_print_packet(struct sk_buff *skb, char *buffer, int buf_len)
char header[HOMA_MAX_HEADER];
struct in6_addr saddr;
int used = 0;
int offset;

if (!skb) {
snprintf(buffer, buf_len, "skb is NULL!");
buffer[buf_len - 1] = 0;
return buffer;
}

skb_copy_bits(skb, 0, &header, min(sizeof(header), skb->len));
offset = homa_print_hdr_offset(skb);
skb_copy_bits(skb, offset, &header, min(sizeof(header),
skb->len - offset));
common = (struct homa_common_hdr *)header;
saddr = skb_canonical_ipv6_saddr(skb);
used = homa_snprintf(buffer, buf_len, used,
Expand Down Expand Up @@ -308,9 +346,12 @@ char *homa_print_packet_short(struct sk_buff *skb, char *buffer, int buf_len)
{
struct homa_common_hdr *common;
char header[HOMA_MAX_HEADER];
int offset;

offset = homa_print_hdr_offset(skb);
common = (struct homa_common_hdr *)header;
skb_copy_bits(skb, 0, header, min(HOMA_MAX_HEADER, skb->len));
skb_copy_bits(skb, offset, header, min(HOMA_MAX_HEADER,
skb->len - offset));
switch (common->type) {
case DATA: {
struct homa_data_hdr *h = (struct homa_data_hdr *)header;
Expand Down
Loading