Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

batman-adv: keep skb crc32 helper local in BLA

The batadv_skb_crc32() helper was shared between Bridge Loop Avoidance and
Network Coding. With the removal of the network coding feature, it is
possible to just move this helper directly to Bridge Loop Avoidance.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>

authored by

Sven Eckelmann and committed by
Simon Wunderlich
d5d80ac7 87b95082

+34 -35
+34
net/batman-adv/bridge_loop_avoidance.c
··· 12 12 #include <linux/compiler.h> 13 13 #include <linux/container_of.h> 14 14 #include <linux/crc16.h> 15 + #include <linux/crc32.h> 15 16 #include <linux/err.h> 16 17 #include <linux/errno.h> 17 18 #include <linux/etherdevice.h> ··· 1583 1582 queue_delayed_work(batadv_event_workqueue, &bat_priv->bla.work, 1584 1583 msecs_to_jiffies(BATADV_BLA_PERIOD_LENGTH)); 1585 1584 return 0; 1585 + } 1586 + 1587 + /** 1588 + * batadv_skb_crc32() - calculate CRC32 of the whole packet and skip bytes in 1589 + * the header 1590 + * @skb: skb pointing to fragmented socket buffers 1591 + * @payload_ptr: Pointer to position inside the head buffer of the skb 1592 + * marking the start of the data to be CRC'ed 1593 + * 1594 + * payload_ptr must always point to an address in the skb head buffer and not to 1595 + * a fragment. 1596 + * 1597 + * Return: big endian crc32c of the checksummed data 1598 + */ 1599 + static __be32 batadv_skb_crc32(struct sk_buff *skb, u8 *payload_ptr) 1600 + { 1601 + unsigned int to = skb->len; 1602 + unsigned int consumed = 0; 1603 + struct skb_seq_state st; 1604 + unsigned int from; 1605 + unsigned int len; 1606 + const u8 *data; 1607 + u32 crc = 0; 1608 + 1609 + from = (unsigned int)(payload_ptr - skb->data); 1610 + 1611 + skb_prepare_seq_read(skb, from, to, &st); 1612 + while ((len = skb_seq_read(consumed, &data, &st)) != 0) { 1613 + crc = crc32c(crc, data, len); 1614 + consumed += len; 1615 + } 1616 + 1617 + return htonl(crc); 1586 1618 } 1587 1619 1588 1620 /**
-34
net/batman-adv/main.c
··· 11 11 #include <linux/build_bug.h> 12 12 #include <linux/byteorder/generic.h> 13 13 #include <linux/container_of.h> 14 - #include <linux/crc32.h> 15 14 #include <linux/device.h> 16 15 #include <linux/errno.h> 17 16 #include <linux/gfp.h> ··· 558 559 void batadv_recv_handler_unregister(u8 packet_type) 559 560 { 560 561 batadv_rx_handler[packet_type] = batadv_recv_unhandled_packet; 561 - } 562 - 563 - /** 564 - * batadv_skb_crc32() - calculate CRC32 of the whole packet and skip bytes in 565 - * the header 566 - * @skb: skb pointing to fragmented socket buffers 567 - * @payload_ptr: Pointer to position inside the head buffer of the skb 568 - * marking the start of the data to be CRC'ed 569 - * 570 - * payload_ptr must always point to an address in the skb head buffer and not to 571 - * a fragment. 572 - * 573 - * Return: big endian crc32c of the checksummed data 574 - */ 575 - __be32 batadv_skb_crc32(struct sk_buff *skb, u8 *payload_ptr) 576 - { 577 - u32 crc = 0; 578 - unsigned int from; 579 - unsigned int to = skb->len; 580 - struct skb_seq_state st; 581 - const u8 *data; 582 - unsigned int len; 583 - unsigned int consumed = 0; 584 - 585 - from = (unsigned int)(payload_ptr - skb->data); 586 - 587 - skb_prepare_seq_read(skb, from, to, &st); 588 - while ((len = skb_seq_read(consumed, &data, &st)) != 0) { 589 - crc = crc32c(crc, data, len); 590 - consumed += len; 591 - } 592 - 593 - return htonl(crc); 594 562 } 595 563 596 564 /**
-1
net/batman-adv/main.h
··· 248 248 int (*recv_handler)(struct sk_buff *, 249 249 struct batadv_hard_iface *)); 250 250 void batadv_recv_handler_unregister(u8 packet_type); 251 - __be32 batadv_skb_crc32(struct sk_buff *skb, u8 *payload_ptr); 252 251 253 252 /** 254 253 * batadv_compare_eth() - Compare two not u16 aligned Ethernet addresses