aboutsummaryrefslogtreecommitdiff
path: root/drivers/net/wan/hdlc.c
AgeCommit message (Collapse)AuthorFilesLines
2020-10-21net: hdlc: In hdlc_rcv, check to make sure dev is an HDLC deviceXie He1-1/+9
The hdlc_rcv function is used as hdlc_packet_type.func to process any skb received in the kernel with skb->protocol == htons(ETH_P_HDLC). The purpose of this function is to provide second-stage processing for skbs not assigned a "real" L3 skb->protocol value in the first stage. This function assumes the device from which the skb is received is an HDLC device (a device created by this module). It assumes that netdev_priv(dev) returns a pointer to "struct hdlc_device". However, it is possible that some driver in the kernel (not necessarily in our control) submits a received skb with skb->protocol == htons(ETH_P_HDLC), from a non-HDLC device. In this case, the skb would still be received by hdlc_rcv. This will cause problems. hdlc_rcv should be able to recognize and drop invalid skbs. It should first make sure "dev" is actually an HDLC device, before starting its processing. This patch adds this check to hdlc_rcv. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: Krzysztof Halasa <[email protected]> Signed-off-by: Xie He <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2020-09-02drivers/net/wan/hdlc: Change the default of hard_header_len to 0Xie He1-1/+1
Change the default value of hard_header_len in hdlc.c from 16 to 0. Currently there are 6 HDLC protocol drivers, among them: hdlc_raw_eth, hdlc_cisco, hdlc_ppp, hdlc_x25 set hard_header_len when attaching the protocol, overriding the default. So this patch does not affect them. hdlc_raw and hdlc_fr don't set hard_header_len when attaching the protocol. So this patch will change the hard_header_len of the HDLC device for them from 16 to 0. This is the correct change because both hdlc_raw and hdlc_fr don't have header_ops, and the code in net/packet/af_packet.c expects the value of hard_header_len to be consistent with header_ops. In net/packet/af_packet.c, in the packet_snd function, for AF_PACKET/DGRAM sockets it would reserve a headroom of hard_header_len and call dev_hard_header to fill in that headroom, and for AF_PACKET/RAW sockets, it does not reserve the headroom and does not call dev_hard_header, but checks if the user has provided a header of length hard_header_len (in function dev_validate_header). Cc: Krzysztof Halasa <[email protected]> Cc: Martin Schiller <[email protected]> Signed-off-by: Xie He <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2020-08-14drivers/net/wan/hdlc_x25: Added needed_headroom and a skb->len checkXie He1-0/+1
1. Added a skb->len check This driver expects upper layers to include a pseudo header of 1 byte when passing down a skb for transmission. This driver will read this 1-byte header. This patch added a skb->len check before reading the header to make sure the header exists. 2. Added needed_headroom and set hard_header_len to 0 When this driver transmits data, first this driver will remove a pseudo header of 1 byte, then the lapb module will prepend the LAPB header of 2 or 3 bytes. So the value of needed_headroom in this driver should be 3 - 1. Because this driver has no header_ops, according to the logic of af_packet.c, the value of hard_header_len should be 0. Reason of setting needed_headroom and hard_header_len at this place: This driver is written using the API of the hdlc module, the hdlc module enables this driver (the protocol driver) to run on any hardware that has a driver (the hardware driver) written using the API of the hdlc module. Two other hdlc protocol drivers - hdlc_ppp and hdlc_raw_eth, also set things like hard_header_len at this place. In hdlc_ppp, it sets hard_header_len after attach_hdlc_protocol and before setting dev->type. In hdlc_raw_eth, it sets hard_header_len by calling ether_setup after attach_hdlc_protocol and after memcpy the settings. 3. Reset needed_headroom when detaching protocols (in hdlc.c) When detaching a protocol from a hardware device, the hdlc module will reset various parameters of the device (including hard_header_len) to the default values. We add needed_headroom here so that needed_headroom will also be reset. Cc: Willem de Bruijn <[email protected]> Cc: Martin Schiller <[email protected]> Cc: Andrew Hendry <[email protected]> Signed-off-by: Xie He <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2019-05-30treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 206Thomas Gleixner1-4/+1
Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of version 2 of the gnu general public license as published by the free software foundation extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 107 file(s). Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Allison Randal <[email protected]> Reviewed-by: Richard Fontana <[email protected]> Reviewed-by: Steve Winslow <[email protected]> Reviewed-by: Alexios Zavras <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2016-10-20net: use core MTU range checking in WAN driversJarod Wilson1-9/+2
- set min/max_mtu in all hdlc drivers, remove hdlc_change_mtu - sent max_mtu in lec driver, remove lec_change_mtu - set min/max_mtu in x25_asy driver CC: [email protected] CC: Krzysztof Halasa <[email protected]> CC: Krzysztof Halasa <[email protected]> CC: Jan "Yenya" Kasprzak <[email protected]> CC: Francois Romieu <[email protected]> CC: Kevin Curtis <[email protected]> CC: Zhao Qiang <[email protected]> Signed-off-by: Jarod Wilson <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2015-12-05WAN: HDLC: Call notifiers before and after changing device typeAndrew Lunn1-2/+17
An HDLC device can change type when the protocol driver is changed. Calling the notifier change allows potential users of the interface know about this planned change, and even block it. After the change has occurred, send a second notification to users can evaluate the new device type etc. Signed-off-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2015-12-05WAN: HDLC: Detach protocol before unregistering deviceAndrew Lunn1-1/+1
The current code first unregisters the device, and then detaches the protocol from it. This should be performed the other way around, since the detach may try to use state which has been freed by the unregister. Swap the order, so that we first detach and then remove the netdev. Signed-off-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2014-07-15net: set name_assign_type in alloc_netdev()Tom Gundersen1-1/+2
Extend alloc_netdev{,_mq{,s}}() to take name_assign_type as argument, and convert all users to pass NET_NAME_UNKNOWN. Coccinelle patch: @@ expression sizeof_priv, name, setup, txqs, rxqs, count; @@ ( -alloc_netdev_mqs(sizeof_priv, name, setup, txqs, rxqs) +alloc_netdev_mqs(sizeof_priv, name, NET_NAME_UNKNOWN, setup, txqs, rxqs) | -alloc_netdev_mq(sizeof_priv, name, setup, count) +alloc_netdev_mq(sizeof_priv, name, NET_NAME_UNKNOWN, setup, count) | -alloc_netdev(sizeof_priv, name, setup) +alloc_netdev(sizeof_priv, name, NET_NAME_UNKNOWN, setup) ) v9: move comments here from the wrong commit Signed-off-by: Tom Gundersen <[email protected]> Reviewed-by: David Herrmann <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2013-05-28net: pass info struct via netdevice notifierJiri Pirko1-1/+1
So far, only net_device * could be passed along with netdevice notifier event. This patch provides a possibility to pass custom structure able to provide info that event listener needs to know. Signed-off-by: Jiri Pirko <[email protected]> v2->v3: fix typo on simeth shortened dev_getter shortened notifier_info struct name v1->v2: fix notifier_call parameter in call_netdevice_notifier() Signed-off-by: David S. Miller <[email protected]>
2013-02-04wan: Remove unnecessary alloc/OOM messagesJoe Perches1-5/+4
alloc failures already get standardized OOM messages and a dump_stack. Hoist assigns from if tests. Signed-off-by: Joe Perches <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2011-06-27generic_hdlc: Update to current logging formsJoe Perches1-7/+9
Use pr_fmt, pr_<level> and netdev_<level> as appropriate. Signed-off-by: Joe Perches <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2010-09-21Fix typo interrest[ing|ed] => interest[ing|ed]Thomas Weber1-1/+1
Fix typos with interrest*. Signed-off-by: Thomas Weber <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
2009-11-25net: use net_eq to compare netsOctavian Purdila1-2/+2
Generated with the following semantic patch @@ struct net *n1; struct net *n2; @@ - n1 == n2 + net_eq(n1, n2) @@ struct net *n1; struct net *n2; @@ - n1 != n2 + !net_eq(n1, n2) applied over {include,net,drivers/net}. Signed-off-by: Octavian Purdila <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2009-09-01wan: convert drivers to netdev_tx_tStephen Hemminger1-1/+1
Signed-off-by: Stephen Hemminger <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2009-03-10net: convert usage of packet_type to read_mostlyStephen Hemminger1-1/+1
Protocols that use packet_type can be __read_mostly section for better locality. Elminate any unnecessary initializations of NULL. Signed-off-by: Stephen Hemminger <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2009-02-01net: replace uses of __constant_{endian}Harvey Harrison1-1/+1
Base versions handle constant folding now. Signed-off-by: Harvey Harrison <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2009-01-21WAN: Convert generic HDLC drivers to netdev_ops.Krzysztof Hałasa1-3/+11
Also remove unneeded last_rx update from Synclink drivers. Synclink part mostly by Stephen Hemminger. Signed-off-by: Krzysztof Hałasa <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2009-01-21WAN: Allow hw HDLC drivers to override dev->get_stats.Krzysztof Hałasa1-11/+1
Use the internal get_stats() by default. Fixes LMC and wanXL drivers. Signed-off-by: Krzysztof Hałasa <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2009-01-21WAN: Generic HDLC now uses IFF_WAN_HDLC private flag.Krzysztof Hałasa1-1/+2
Signed-off-by: Krzysztof Hałasa <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2008-07-23WAN: cosmetic changes to generic HDLCKrzysztof Hałasa1-13/+12
Signed-off-by: Krzysztof Hałasa <[email protected]>
2008-07-04WAN: convert drivers to use built-in netdev_statsKrzysztof Halasa1-1/+1
There is no point in using separate net_device_stats structs when the one in struct net_device is present. Compiles. Signed-off-by: Krzysztof Hałasa <[email protected]> Signed-off-by: Jeff Garzik <[email protected]>
2008-05-22WAN: protect HDLC proto list while insmod/rmmodKrzysztof Halasa1-8/+11
WAN: protect protocol list in hdlc.c with RTNL. Signed-off-by: Krzysztof Hałasa <[email protected]> Signed-off-by: Jeff Garzik <[email protected]>
2008-03-26[NET] NETNS: Omit net_device->nd_net without CONFIG_NET_NS.YOSHIFUJI Hideaki1-2/+2
Introduce per-net_device inlines: dev_net(), dev_net_set(). Without CONFIG_NET_NS, no namespace other than &init_net exists. Let's explicitly define them to help compiler optimizations. Signed-off-by: YOSHIFUJI Hideaki <[email protected]>
2008-02-05Generic HDLC - remove now unneeded hdlc_device_descKrzysztof Halasa1-15/+9
Removes now unneeded struct hdlc_device_desc Signed-off-by: Krzysztof Halasa <[email protected]> Signed-off-by: Jeff Garzik <[email protected]>
2007-10-10[NET]: Move hardware header operations out of netdevice.Stephen Hemminger1-6/+4
Since hardware header operations are part of the protocol class not the device instance, make them into a separate object and save memory. Signed-off-by: Stephen Hemminger <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2007-10-10[NET]: Make device event notification network namespace safeEric W. Biederman1-0/+3
Every user of the network device notifiers is either a protocol stack or a pseudo device. If a protocol stack that does not have support for multiple network namespaces receives an event for a device that is not in the initial network namespace it quite possibly can get confused and do the wrong thing. To avoid problems until all of the protocol stacks are converted this patch modifies all netdev event handlers to ignore events on devices that are not in the initial network namespace. As the rest of the code is made network namespace aware these checks can be removed. Signed-off-by: Eric W. Biederman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2007-10-10[NET]: Make packet reception network namespace safeEric W. Biederman1-0/+7
This patch modifies every packet receive function registered with dev_add_pack() to drop packets if they are not from the initial network namespace. This should ensure that the various network stacks do not receive packets in a anything but the initial network namespace until the code has been converted and is ready for them. Signed-off-by: Eric W. Biederman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2007-03-02[HDLC] Fix dev->header_cache_update having a random value.Krzysztof Halasa1-10/+23
Switching HDLC devices from Ethernet-framing mode caused stale ethernet function assignments within net_device. Signed-off-by: Krzysztof Halasa <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2007-02-05make hdlc_setup() static againAdrian Bunk1-2/+1
hdlc_setup was exported, but this export was never used. If a driver using it actually shows up it can still be exported again. Signed-off-by: Adrian Bunk <[email protected]> Acked-by: Krzysztof Halasa <[email protected]> Signed-off-by: Jeff Garzik <[email protected]>
2006-09-26[PATCH] Modularize generic HDLCKrzysztof Halasa1-0/+368
This patch enables building of individual WAN protocol support routines (parts of generic HDLC) as separate modules. All protocol-private definitions are moved from hdlc.h file to protocol drivers. User-space interface and interface between generic HDLC and underlying low-level HDLC drivers are unchanged. Signed-off-by: Krzysztof Halasa <[email protected]> Signed-off-by: Jeff Garzik <[email protected]>