diff options
Diffstat (limited to 'net/batman-adv/soft-interface.c')
-rw-r--r-- | net/batman-adv/soft-interface.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index 25e6004e8e01..e8a2bd699d40 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c | |||
@@ -34,8 +34,6 @@ | |||
34 | #include <linux/ethtool.h> | 34 | #include <linux/ethtool.h> |
35 | #include <linux/etherdevice.h> | 35 | #include <linux/etherdevice.h> |
36 | #include <linux/if_vlan.h> | 36 | #include <linux/if_vlan.h> |
37 | #include <linux/if_ether.h> | ||
38 | #include "unicast.h" | ||
39 | #include "bridge_loop_avoidance.h" | 37 | #include "bridge_loop_avoidance.h" |
40 | #include "network-coding.h" | 38 | #include "network-coding.h" |
41 | 39 | ||
@@ -139,6 +137,18 @@ static int batadv_interface_change_mtu(struct net_device *dev, int new_mtu) | |||
139 | return 0; | 137 | return 0; |
140 | } | 138 | } |
141 | 139 | ||
140 | /** | ||
141 | * batadv_interface_set_rx_mode - set the rx mode of a device | ||
142 | * @dev: registered network device to modify | ||
143 | * | ||
144 | * We do not actually need to set any rx filters for the virtual batman | ||
145 | * soft interface. However a dummy handler enables a user to set static | ||
146 | * multicast listeners for instance. | ||
147 | */ | ||
148 | static void batadv_interface_set_rx_mode(struct net_device *dev) | ||
149 | { | ||
150 | } | ||
151 | |||
142 | static int batadv_interface_tx(struct sk_buff *skb, | 152 | static int batadv_interface_tx(struct sk_buff *skb, |
143 | struct net_device *soft_iface) | 153 | struct net_device *soft_iface) |
144 | { | 154 | { |
@@ -147,7 +157,7 @@ static int batadv_interface_tx(struct sk_buff *skb, | |||
147 | struct batadv_hard_iface *primary_if = NULL; | 157 | struct batadv_hard_iface *primary_if = NULL; |
148 | struct batadv_bcast_packet *bcast_packet; | 158 | struct batadv_bcast_packet *bcast_packet; |
149 | struct vlan_ethhdr *vhdr; | 159 | struct vlan_ethhdr *vhdr; |
150 | __be16 ethertype = __constant_htons(ETH_P_BATMAN); | 160 | __be16 ethertype = htons(ETH_P_BATMAN); |
151 | static const uint8_t stp_addr[ETH_ALEN] = {0x01, 0x80, 0xC2, 0x00, | 161 | static const uint8_t stp_addr[ETH_ALEN] = {0x01, 0x80, 0xC2, 0x00, |
152 | 0x00, 0x00}; | 162 | 0x00, 0x00}; |
153 | static const uint8_t ectp_addr[ETH_ALEN] = {0xCF, 0x00, 0x00, 0x00, | 163 | static const uint8_t ectp_addr[ETH_ALEN] = {0xCF, 0x00, 0x00, 0x00, |
@@ -286,7 +296,7 @@ static int batadv_interface_tx(struct sk_buff *skb, | |||
286 | 296 | ||
287 | batadv_dat_snoop_outgoing_arp_reply(bat_priv, skb); | 297 | batadv_dat_snoop_outgoing_arp_reply(bat_priv, skb); |
288 | 298 | ||
289 | ret = batadv_unicast_send_skb(bat_priv, skb); | 299 | ret = batadv_send_skb_unicast(bat_priv, skb); |
290 | if (ret != 0) | 300 | if (ret != 0) |
291 | goto dropped_freed; | 301 | goto dropped_freed; |
292 | } | 302 | } |
@@ -314,7 +324,7 @@ void batadv_interface_rx(struct net_device *soft_iface, | |||
314 | struct vlan_ethhdr *vhdr; | 324 | struct vlan_ethhdr *vhdr; |
315 | struct batadv_header *batadv_header = (struct batadv_header *)skb->data; | 325 | struct batadv_header *batadv_header = (struct batadv_header *)skb->data; |
316 | unsigned short vid __maybe_unused = BATADV_NO_FLAGS; | 326 | unsigned short vid __maybe_unused = BATADV_NO_FLAGS; |
317 | __be16 ethertype = __constant_htons(ETH_P_BATMAN); | 327 | __be16 ethertype = htons(ETH_P_BATMAN); |
318 | bool is_bcast; | 328 | bool is_bcast; |
319 | 329 | ||
320 | is_bcast = (batadv_header->packet_type == BATADV_BCAST); | 330 | is_bcast = (batadv_header->packet_type == BATADV_BCAST); |
@@ -444,6 +454,7 @@ static void batadv_softif_destroy_finish(struct work_struct *work) | |||
444 | static int batadv_softif_init_late(struct net_device *dev) | 454 | static int batadv_softif_init_late(struct net_device *dev) |
445 | { | 455 | { |
446 | struct batadv_priv *bat_priv; | 456 | struct batadv_priv *bat_priv; |
457 | uint32_t random_seqno; | ||
447 | int ret; | 458 | int ret; |
448 | size_t cnt_len = sizeof(uint64_t) * BATADV_CNT_NUM; | 459 | size_t cnt_len = sizeof(uint64_t) * BATADV_CNT_NUM; |
449 | 460 | ||
@@ -493,6 +504,10 @@ static int batadv_softif_init_late(struct net_device *dev) | |||
493 | bat_priv->tt.last_changeset = NULL; | 504 | bat_priv->tt.last_changeset = NULL; |
494 | bat_priv->tt.last_changeset_len = 0; | 505 | bat_priv->tt.last_changeset_len = 0; |
495 | 506 | ||
507 | /* randomize initial seqno to avoid collision */ | ||
508 | get_random_bytes(&random_seqno, sizeof(random_seqno)); | ||
509 | atomic_set(&bat_priv->frag_seqno, random_seqno); | ||
510 | |||
496 | bat_priv->primary_if = NULL; | 511 | bat_priv->primary_if = NULL; |
497 | bat_priv->num_ifaces = 0; | 512 | bat_priv->num_ifaces = 0; |
498 | 513 | ||
@@ -580,6 +595,7 @@ static const struct net_device_ops batadv_netdev_ops = { | |||
580 | .ndo_get_stats = batadv_interface_stats, | 595 | .ndo_get_stats = batadv_interface_stats, |
581 | .ndo_set_mac_address = batadv_interface_set_mac_addr, | 596 | .ndo_set_mac_address = batadv_interface_set_mac_addr, |
582 | .ndo_change_mtu = batadv_interface_change_mtu, | 597 | .ndo_change_mtu = batadv_interface_change_mtu, |
598 | .ndo_set_rx_mode = batadv_interface_set_rx_mode, | ||
583 | .ndo_start_xmit = batadv_interface_tx, | 599 | .ndo_start_xmit = batadv_interface_tx, |
584 | .ndo_validate_addr = eth_validate_addr, | 600 | .ndo_validate_addr = eth_validate_addr, |
585 | .ndo_add_slave = batadv_softif_slave_add, | 601 | .ndo_add_slave = batadv_softif_slave_add, |
@@ -623,7 +639,7 @@ static void batadv_softif_init_early(struct net_device *dev) | |||
623 | */ | 639 | */ |
624 | dev->mtu = ETH_DATA_LEN; | 640 | dev->mtu = ETH_DATA_LEN; |
625 | /* reserve more space in the skbuff for our header */ | 641 | /* reserve more space in the skbuff for our header */ |
626 | dev->hard_header_len = BATADV_HEADER_LEN; | 642 | dev->hard_header_len = batadv_max_header_len(); |
627 | 643 | ||
628 | /* generate random address */ | 644 | /* generate random address */ |
629 | eth_hw_addr_random(dev); | 645 | eth_hw_addr_random(dev); |
@@ -760,6 +776,12 @@ static const struct { | |||
760 | { "mgmt_tx_bytes" }, | 776 | { "mgmt_tx_bytes" }, |
761 | { "mgmt_rx" }, | 777 | { "mgmt_rx" }, |
762 | { "mgmt_rx_bytes" }, | 778 | { "mgmt_rx_bytes" }, |
779 | { "frag_tx" }, | ||
780 | { "frag_tx_bytes" }, | ||
781 | { "frag_rx" }, | ||
782 | { "frag_rx_bytes" }, | ||
783 | { "frag_fwd" }, | ||
784 | { "frag_fwd_bytes" }, | ||
763 | { "tt_request_tx" }, | 785 | { "tt_request_tx" }, |
764 | { "tt_request_rx" }, | 786 | { "tt_request_rx" }, |
765 | { "tt_response_tx" }, | 787 | { "tt_response_tx" }, |