16bf3d33c6
In rmnet_map_ipv4_dl_csum_trailer(), an illegal checksum subtraction is done, subtracting hdr_csum (in host byte order) from csum_value (in network byte order). Despite being illegal, it generally works, because it turns out the value subtracted is (or should be) always 0, which has the same representation in either byte order. Doing illegal operations is not good form though, so fix this by verifying the IP header checksum early in that function. If its checksum is non-zero, the packet will be bad, so just return an error. This will cause the packet to passed to the IP layer where it can be dropped. Thereafter, there is no need subtract the IP header checksum from the checksum value in the trailer because we know it is zero. Add a comment explaining this. This type of packet error is different from other types, so add a new statistics counter to track this condition. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
82 lines
1.9 KiB
C
82 lines
1.9 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/* Copyright (c) 2013-2014, 2016-2018, 2021 The Linux Foundation.
|
|
* All rights reserved.
|
|
*
|
|
* RMNET Data configuration engine
|
|
*/
|
|
|
|
#include <linux/skbuff.h>
|
|
#include <net/gro_cells.h>
|
|
|
|
#ifndef _RMNET_CONFIG_H_
|
|
#define _RMNET_CONFIG_H_
|
|
|
|
#define RMNET_MAX_LOGICAL_EP 255
|
|
|
|
struct rmnet_endpoint {
|
|
u8 mux_id;
|
|
struct net_device *egress_dev;
|
|
struct hlist_node hlnode;
|
|
};
|
|
|
|
/* One instance of this structure is instantiated for each real_dev associated
|
|
* with rmnet.
|
|
*/
|
|
struct rmnet_port {
|
|
struct net_device *dev;
|
|
u32 data_format;
|
|
u8 nr_rmnet_devs;
|
|
u8 rmnet_mode;
|
|
struct hlist_head muxed_ep[RMNET_MAX_LOGICAL_EP];
|
|
struct net_device *bridge_ep;
|
|
struct net_device *rmnet_dev;
|
|
};
|
|
|
|
extern struct rtnl_link_ops rmnet_link_ops;
|
|
|
|
struct rmnet_vnd_stats {
|
|
u64 rx_pkts;
|
|
u64 rx_bytes;
|
|
u64 tx_pkts;
|
|
u64 tx_bytes;
|
|
u32 tx_drops;
|
|
};
|
|
|
|
struct rmnet_pcpu_stats {
|
|
struct rmnet_vnd_stats stats;
|
|
struct u64_stats_sync syncp;
|
|
};
|
|
|
|
struct rmnet_priv_stats {
|
|
u64 csum_ok;
|
|
u64 csum_ip4_header_bad;
|
|
u64 csum_valid_unset;
|
|
u64 csum_validation_failed;
|
|
u64 csum_err_bad_buffer;
|
|
u64 csum_err_invalid_ip_version;
|
|
u64 csum_err_invalid_transport;
|
|
u64 csum_fragmented_pkt;
|
|
u64 csum_skipped;
|
|
u64 csum_sw;
|
|
u64 csum_hw;
|
|
};
|
|
|
|
struct rmnet_priv {
|
|
u8 mux_id;
|
|
struct net_device *real_dev;
|
|
struct rmnet_pcpu_stats __percpu *pcpu_stats;
|
|
struct gro_cells gro_cells;
|
|
struct rmnet_priv_stats stats;
|
|
};
|
|
|
|
struct rmnet_port *rmnet_get_port_rcu(struct net_device *real_dev);
|
|
struct rmnet_endpoint *rmnet_get_endpoint(struct rmnet_port *port, u8 mux_id);
|
|
int rmnet_add_bridge(struct net_device *rmnet_dev,
|
|
struct net_device *slave_dev,
|
|
struct netlink_ext_ack *extack);
|
|
int rmnet_del_bridge(struct net_device *rmnet_dev,
|
|
struct net_device *slave_dev);
|
|
struct rmnet_port*
|
|
rmnet_get_port_rtnl(const struct net_device *real_dev);
|
|
#endif /* _RMNET_CONFIG_H_ */
|