aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/batman-adv/main.c20
-rw-r--r--net/batman-adv/packet.h31
-rw-r--r--net/batman-adv/routing.c28
-rw-r--r--net/batman-adv/routing.h2
4 files changed, 68 insertions, 13 deletions
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index b22368e66895..8b195e63e70e 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -393,6 +393,9 @@ static void batadv_recv_handler_init(void)
393 for (i = 0; i < ARRAY_SIZE(batadv_rx_handler); i++) 393 for (i = 0; i < ARRAY_SIZE(batadv_rx_handler); i++)
394 batadv_rx_handler[i] = batadv_recv_unhandled_packet; 394 batadv_rx_handler[i] = batadv_recv_unhandled_packet;
395 395
396 for (i = BATADV_UNICAST_MIN; i <= BATADV_UNICAST_MAX; i++)
397 batadv_rx_handler[i] = batadv_recv_unhandled_unicast_packet;
398
396 /* compile time checks for struct member offsets */ 399 /* compile time checks for struct member offsets */
397 BUILD_BUG_ON(offsetof(struct batadv_unicast_4addr_packet, src) != 10); 400 BUILD_BUG_ON(offsetof(struct batadv_unicast_4addr_packet, src) != 10);
398 BUILD_BUG_ON(offsetof(struct batadv_unicast_packet, dest) != 4); 401 BUILD_BUG_ON(offsetof(struct batadv_unicast_packet, dest) != 4);
@@ -401,18 +404,20 @@ static void batadv_recv_handler_init(void)
401 BUILD_BUG_ON(offsetof(struct batadv_icmp_packet, dst) != 4); 404 BUILD_BUG_ON(offsetof(struct batadv_icmp_packet, dst) != 4);
402 BUILD_BUG_ON(offsetof(struct batadv_icmp_packet_rr, dst) != 4); 405 BUILD_BUG_ON(offsetof(struct batadv_icmp_packet_rr, dst) != 4);
403 406
404 /* batman icmp packet */ 407 /* broadcast packet */
405 batadv_rx_handler[BATADV_ICMP] = batadv_recv_icmp_packet; 408 batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet;
409
410 /* unicast packets ... */
406 /* unicast with 4 addresses packet */ 411 /* unicast with 4 addresses packet */
407 batadv_rx_handler[BATADV_UNICAST_4ADDR] = batadv_recv_unicast_packet; 412 batadv_rx_handler[BATADV_UNICAST_4ADDR] = batadv_recv_unicast_packet;
408 /* unicast packet */ 413 /* unicast packet */
409 batadv_rx_handler[BATADV_UNICAST] = batadv_recv_unicast_packet; 414 batadv_rx_handler[BATADV_UNICAST] = batadv_recv_unicast_packet;
410 /* fragmented unicast packet */ 415 /* fragmented unicast packet */
411 batadv_rx_handler[BATADV_UNICAST_FRAG] = batadv_recv_ucast_frag_packet; 416 batadv_rx_handler[BATADV_UNICAST_FRAG] = batadv_recv_ucast_frag_packet;
412 /* broadcast packet */
413 batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet;
414 /* unicast tvlv packet */ 417 /* unicast tvlv packet */
415 batadv_rx_handler[BATADV_UNICAST_TVLV] = batadv_recv_unicast_tvlv; 418 batadv_rx_handler[BATADV_UNICAST_TVLV] = batadv_recv_unicast_tvlv;
419 /* batman icmp packet */
420 batadv_rx_handler[BATADV_ICMP] = batadv_recv_icmp_packet;
416} 421}
417 422
418int 423int
@@ -420,7 +425,12 @@ batadv_recv_handler_register(uint8_t packet_type,
420 int (*recv_handler)(struct sk_buff *, 425 int (*recv_handler)(struct sk_buff *,
421 struct batadv_hard_iface *)) 426 struct batadv_hard_iface *))
422{ 427{
423 if (batadv_rx_handler[packet_type] != &batadv_recv_unhandled_packet) 428 int (*curr)(struct sk_buff *,
429 struct batadv_hard_iface *);
430 curr = batadv_rx_handler[packet_type];
431
432 if ((curr != batadv_recv_unhandled_packet) &&
433 (curr != batadv_recv_unhandled_unicast_packet))
424 return -EBUSY; 434 return -EBUSY;
425 435
426 batadv_rx_handler[packet_type] = recv_handler; 436 batadv_rx_handler[packet_type] = recv_handler;
diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h
index 87fcf2e7883c..f02dbb1892dd 100644
--- a/net/batman-adv/packet.h
+++ b/net/batman-adv/packet.h
@@ -22,17 +22,32 @@
22 22
23/** 23/**
24 * enum batadv_packettype - types for batman-adv encapsulated packets 24 * enum batadv_packettype - types for batman-adv encapsulated packets
25 * @BATADV_IV_OGM: originator messages for B.A.T.M.A.N. IV
26 * @BATADV_BCAST: broadcast packets carrying broadcast payload
27 * @BATADV_CODED: network coded packets
28 *
29 * @BATADV_UNICAST: unicast packets carrying unicast payload traffic
30 * @BATADV_UNICAST_FRAG: unicast packets carrying a fragment of the original
31 * payload packet
32 * @BATADV_UNICAST_4ADDR: unicast packet including the originator address of
33 * the sender
34 * @BATADV_ICMP: unicast packet like IP ICMP used for ping or traceroute
25 * @BATADV_UNICAST_TVLV: unicast packet carrying TVLV containers 35 * @BATADV_UNICAST_TVLV: unicast packet carrying TVLV containers
26 */ 36 */
27enum batadv_packettype { 37enum batadv_packettype {
28 BATADV_IV_OGM = 0x01, 38 /* 0x00 - 0x3f: local packets or special rules for handling */
29 BATADV_ICMP = 0x02, 39 BATADV_IV_OGM = 0x00,
30 BATADV_UNICAST = 0x03, 40 BATADV_BCAST = 0x01,
31 BATADV_BCAST = 0x04, 41 BATADV_CODED = 0x02,
32 BATADV_UNICAST_FRAG = 0x06, 42 /* 0x40 - 0x7f: unicast */
33 BATADV_UNICAST_4ADDR = 0x09, 43#define BATADV_UNICAST_MIN 0x40
34 BATADV_CODED = 0x0a, 44 BATADV_UNICAST = 0x40,
35 BATADV_UNICAST_TVLV = 0x0b, 45 BATADV_UNICAST_FRAG = 0x41,
46 BATADV_UNICAST_4ADDR = 0x42,
47 BATADV_ICMP = 0x43,
48 BATADV_UNICAST_TVLV = 0x44,
49#define BATADV_UNICAST_MAX 0x7f
50 /* 0x80 - 0xff: reserved */
36}; 51};
37 52
38/** 53/**
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 2a9318bd9026..457dfef9c5fc 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -911,6 +911,34 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
911 return 1; 911 return 1;
912} 912}
913 913
914/**
915 * batadv_recv_unhandled_unicast_packet - receive and process packets which
916 * are in the unicast number space but not yet known to the implementation
917 * @skb: unicast tvlv packet to process
918 * @recv_if: pointer to interface this packet was received on
919 *
920 * Returns NET_RX_SUCCESS if the packet has been consumed or NET_RX_DROP
921 * otherwise.
922 */
923int batadv_recv_unhandled_unicast_packet(struct sk_buff *skb,
924 struct batadv_hard_iface *recv_if)
925{
926 struct batadv_unicast_packet *unicast_packet;
927 struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface);
928 int check, hdr_size = sizeof(*unicast_packet);
929
930 check = batadv_check_unicast_packet(bat_priv, skb, hdr_size);
931 if (check < 0)
932 return NET_RX_DROP;
933
934 /* we don't know about this type, drop it. */
935 unicast_packet = (struct batadv_unicast_packet *)skb->data;
936 if (batadv_is_my_mac(bat_priv, unicast_packet->dest))
937 return NET_RX_DROP;
938
939 return batadv_route_unicast_packet(skb, recv_if);
940}
941
914int batadv_recv_unicast_packet(struct sk_buff *skb, 942int batadv_recv_unicast_packet(struct sk_buff *skb,
915 struct batadv_hard_iface *recv_if) 943 struct batadv_hard_iface *recv_if)
916{ 944{
diff --git a/net/batman-adv/routing.h b/net/batman-adv/routing.h
index b3f53d492b3c..ea15fa6302ad 100644
--- a/net/batman-adv/routing.h
+++ b/net/batman-adv/routing.h
@@ -40,6 +40,8 @@ int batadv_recv_roam_adv(struct sk_buff *skb,
40 struct batadv_hard_iface *recv_if); 40 struct batadv_hard_iface *recv_if);
41int batadv_recv_unicast_tvlv(struct sk_buff *skb, 41int batadv_recv_unicast_tvlv(struct sk_buff *skb,
42 struct batadv_hard_iface *recv_if); 42 struct batadv_hard_iface *recv_if);
43int batadv_recv_unhandled_unicast_packet(struct sk_buff *skb,
44 struct batadv_hard_iface *recv_if);
43struct batadv_neigh_node * 45struct batadv_neigh_node *
44batadv_find_router(struct batadv_priv *bat_priv, 46batadv_find_router(struct batadv_priv *bat_priv,
45 struct batadv_orig_node *orig_node, 47 struct batadv_orig_node *orig_node,