net: move the type 2 sockets out of tree
Subsystems (8)
Jakub Kicinski
maintainercover net: move the type 2 sockets out of tree
LLC2 sockets are admin-only already. We have been getting a trickle of LLM-driven fixes for these, even tho we don't know of any active user. The code is so bad the LLM fixes just turn into a never ending stream of revisions and follow ups as fixing one condition reveals 5 more bugs. Let's move this code out of tree.
The series itself is LLM generated, the LLM was also nice enough to generates some tests and validate that the OOT module actually works.
Jakub Kicinski (3):
llc: move the type 2 sockets out of tree
llc: strip the leftovers of the llc2 removal
net: drop unused LLC-related includes
net/llc/Kconfig | 7 - net/llc/Makefile | 10 +- include/linux/llc.h | 5 - include/net/llc.h | 108 +- include/net/llc_c_ac.h | 180 - include/net/llc_c_ev.h | 217 - include/net/llc_c_st.h | 46 - include/net/llc_conn.h | 114 - include/net/llc_if.h | 63 - include/net/llc_pdu.h | 379 +- include/net/llc_s_ac.h | 35 - include/net/llc_s_ev.h | 61 - include/net/llc_s_st.h | 32 - include/net/llc_sap.h | 26 - net/802/garp.c | 4 +- net/802/psnap.c | 2 +- net/bridge/br.c | 2 - net/bridge/br_stp_bpdu.c | 3 +- net/llc/af_llc.c | 1304 ----- net/llc/llc_c_ac.c | 1448 ------ net/llc/llc_c_ev.c | 742 --- net/llc/llc_c_st.c | 4940 ------------------- net/llc/llc_conn.c | 1025 ---- net/llc/llc_core.c | 28 +- net/llc/llc_if.c | 151 - net/llc/llc_input.c | 128 +- net/llc/llc_output.c | 3 +- net/llc/llc_pdu.c | 366 -- net/llc/llc_proc.c | 245 - net/llc/llc_s_ac.c | 220 - net/llc/llc_s_ev.c | 109 - net/llc/llc_s_st.c | 177 - net/llc/llc_sap.c | 437 -- net/llc/llc_station.c | 120 - net/llc/sysctl_net_llc.c | 71 - net/openvswitch/flow.c | 1 - net/openvswitch/flow_netlink.c | 2 - net/openvswitch/flow_table.c | 2 - net/openvswitch/vport-netdev.c | 1 - arch/loongarch/configs/loongson32_defconfig | 1 - arch/loongarch/configs/loongson64_defconfig | 1 - arch/mips/configs/gpr_defconfig | 1 - arch/mips/configs/mtx1_defconfig | 1 - arch/mips/configs/rb532_defconfig | 1 - arch/parisc/configs/generic-32bit_defconfig | 1 - 45 files changed, 33 insertions(+), 12787 deletions(-) delete mode 100644 include/net/llc_c_ac.h delete mode 100644 include/net/llc_c_ev.h delete mode 100644 include/net/llc_c_st.h delete mode 100644 include/net/llc_conn.h delete mode 100644 include/net/llc_if.h delete mode 100644 include/net/llc_s_ac.h delete mode 100644 include/net/llc_s_ev.h delete mode 100644 include/net/llc_s_st.h delete mode 100644 include/net/llc_sap.h delete mode 100644 net/llc/af_llc.c delete mode 100644 net/llc/llc_c_ac.c delete mode 100644 net/llc/llc_c_ev.c delete mode 100644 net/llc/llc_c_st.c delete mode 100644 net/llc/llc_conn.c delete mode 100644 net/llc/llc_if.c delete mode 100644 net/llc/llc_pdu.c delete mode 100644 net/llc/llc_proc.c delete mode 100644 net/llc/llc_s_ac.c delete mode 100644 net/llc/llc_s_ev.c delete mode 100644 net/llc/llc_s_st.c delete mode 100644 net/llc/llc_sap.c delete mode 100644 net/llc/llc_station.c delete mode 100644 net/llc/sysctl_net_llc.c
Signature · 1 line
2.55.0
Jakub Kicinski
maintainerPATCH 1/3 llc: move the type 2 sockets out of tree
802.2 LLC is only used in tree by protocols which need the connectionless type 1 subset: STP, which carries the bridge's BPDUs, GARP, which sends its own UI PDUs, and SNAP. The llc2 module on top of the core - the type 2 connection state machine, the type 1 SAP state machine, the station component and the PF_LLC socket family - has no in-kernel users and nobody who can test it; what we get instead is a slow trickle of drive-by fixes.
There was a recent patch from Ernestas Kulik indicating potential real life use, but it was new/experimental and that person is not responding to off-list pings.
Let LLC2 follow AX.25, hamradio and AppleTalk out of the Linux tree. We will maintain the code at: github.com/linux-netdev/mod-orphan for anyone interested in playing with it.
PF_LLC goes in full, both the class two SOCK_STREAM and the class one SOCK_DGRAM half, and so do /proc/net/llc/ and /proc/sys/net/llc/. Note that the kernel also stops answering XID and TEST commands, addressed to a SAP or to the station - those are type 1, but they lived in the module, and they got answered whether or not any socket was open. Nothing in tree asks for them; what the core keeps is SAP registration and the UI path the in-tree users need.
Retain the uAPI for now, like we did for AppleTalk. Only the socket ABI half of it is vestigial: STP, GARP, the bridge and openvswitch use the SAP numbers it defines. Cleaning up what the core no longer needs follows in the next patch.
---
CC: Ernestas Kulik <[email protected]>
--- net/llc/Kconfig | 7 - net/llc/Makefile | 10 +- include/linux/llc.h | 5 - include/net/llc.h | 26 - include/net/llc_c_ac.h | 180 - include/net/llc_c_ev.h | 217 - include/net/llc_c_st.h | 46 - include/net/llc_conn.h | 114 - include/net/llc_if.h | 63 - include/net/llc_s_ac.h | 35 - include/net/llc_s_ev.h | 61 - include/net/llc_s_st.h | 32 - include/net/llc_sap.h | 26 - net/llc/af_llc.c | 1304 ----- net/llc/llc_c_ac.c | 1448 ------ net/llc/llc_c_ev.c | 742 --- net/llc/llc_c_st.c | 4940 ------------------- net/llc/llc_conn.c | 1025 ---- net/llc/llc_if.c | 151 - net/llc/llc_input.c | 1 - net/llc/llc_pdu.c | 366 -- net/llc/llc_proc.c | 245 - net/llc/llc_s_ac.c | 220 - net/llc/llc_s_ev.c | 109 - net/llc/llc_s_st.c | 177 - net/llc/llc_sap.c | 437 -- net/llc/llc_station.c | 120 - net/llc/sysctl_net_llc.c | 71 - arch/loongarch/configs/loongson32_defconfig | 1 - arch/loongarch/configs/loongson64_defconfig | 1 - arch/mips/configs/gpr_defconfig | 1 - arch/mips/configs/mtx1_defconfig | 1 - arch/mips/configs/rb532_defconfig | 1 - arch/parisc/configs/generic-32bit_defconfig | 1 - 34 files changed, 1 insertion(+), 12183 deletions(-) delete mode 100644 include/net/llc_c_ac.h delete mode 100644 include/net/llc_c_ev.h delete mode 100644 include/net/llc_c_st.h delete mode 100644 include/net/llc_conn.h delete mode 100644 include/net/llc_if.h delete mode 100644 include/net/llc_s_ac.h delete mode 100644 include/net/llc_s_ev.h delete mode 100644 include/net/llc_s_st.h delete mode 100644 include/net/llc_sap.h delete mode 100644 net/llc/af_llc.c delete mode 100644 net/llc/llc_c_ac.c delete mode 100644 net/llc/llc_c_ev.c delete mode 100644 net/llc/llc_c_st.c delete mode 100644 net/llc/llc_conn.c delete mode 100644 net/llc/llc_if.c delete mode 100644 net/llc/llc_pdu.c delete mode 100644 net/llc/llc_proc.c delete mode 100644 net/llc/llc_s_ac.c delete mode 100644 net/llc/llc_s_ev.c delete mode 100644 net/llc/llc_s_st.c delete mode 100644 net/llc/llc_sap.c delete mode 100644 net/llc/llc_station.c delete mode 100644 net/llc/sysctl_net_llc.c
net/llc/Kconfig +0 -7
@@ -1,10 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only config LLC tristate - -config LLC2 - tristate "ANSI/IEEE 802.2 LLC type 2 Support" - select LLC - help - This is a Logical Link Layer type 2, connection oriented support. - Select this if you want to have support for PF_LLC sockets.
net/llc/Makefile +1 -9
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 ########################################################################### -# Makefile for the Linux 802.2 LLC (fully-functional) layer. +# Makefile for the Linux 802.2 LLC layer. # # Copyright (c) 1997 by Procom Technology,Inc. # 2001-2003 by Arnaldo Carvalho de Melo <[email protected]>
@@ -9,11 +9,3 @@ obj-$(CONFIG_LLC) += llc.o llc-y := llc_core.o llc_input.o llc_output.o - -obj-$(CONFIG_LLC2) += llc2.o - -llc2-y := llc_if.o llc_c_ev.o llc_c_ac.o llc_conn.o llc_c_st.o llc_pdu.o \ - llc_sap.o llc_s_ac.o llc_s_ev.o llc_s_st.o af_llc.o llc_station.o - -llc2-$(CONFIG_PROC_FS) += llc_proc.o -llc2-$(CONFIG_SYSCTL) += sysctl_net_llc.o
include/linux/llc.h +0 -5
@@ -9,9 +9,4 @@#include <uapi/linux/llc.h> -#define LLC_SAP_DYN_START 0xC0 -#define LLC_SAP_DYN_STOP 0xDE -#define LLC_SAP_DYN_TRIES 4 - -#define llc_ui_skb_cb (__skb) ((struct sockaddr_llc *)&((__skb)->cb[0]))#endif /* __LINUX_LLC_H */
include/net/llc.h +0 -26
@@ -130,30 +130,4 @@ struct llc_sap *llc_sap_find(unsigned char sap_value);int llc_build_and_send_ui_pkt (struct llc_sap *sap,struct sk_buff *skb,const unsigned char *dmac,unsigned char dsap); - -void llc_sap_handler (struct llc_sap *sap,struct sk_buff *skb); -void llc_conn_handler (struct llc_sap *sap,struct sk_buff *skb); - -void llc_station_init (void ); -void llc_station_exit (void ); - -#ifdef CONFIG_PROC_FS -int llc_proc_init (void ); -void llc_proc_exit (void ); -#else -#define llc_proc_init () (0) -#define llc_proc_exit () do { } while(0) -#endif /* CONFIG_PROC_FS */ -#ifdef CONFIG_SYSCTL -int llc_sysctl_init (void ); -void llc_sysctl_exit (void ); - -extern int sysctl_llc2_ack_timeout; -extern int sysctl_llc2_busy_timeout; -extern int sysctl_llc2_p_timeout; -extern int sysctl_llc2_rej_timeout; -#else -#define llc_sysctl_init () (0) -#define llc_sysctl_exit () do { } while(0) -#endif /* CONFIG_SYSCTL */ #endif /* LLC_H */
include/net/llc_c_ac.h deleted +0 -180
180 lines not on this page · raw message
include/net/llc_c_ev.h deleted +0 -217
217 lines not on this page · raw message
include/net/llc_c_st.h deleted +0 -46
46 lines not on this page · raw message
include/net/llc_conn.h deleted +0 -114
114 lines not on this page · raw message
include/net/llc_if.h deleted +0 -63
63 lines not on this page · raw message
include/net/llc_s_ac.h deleted +0 -35
@@ -1,35 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef LLC_S_AC_H -#define LLC_S_AC_H -/* -* Copyright (c) 1997 by Procom Technology,Inc. -* 2001 by Arnaldo Carvalho de Melo <[email protected]> -*/ - -struct llc_sap ; -struct sk_buff ; - -/* SAP component actions */ -#define SAP_ACT_UNITDATA_IND 1 -#define SAP_ACT_SEND_UI 2 -#define SAP_ACT_SEND_XID_C 3 -#define SAP_ACT_SEND_XID_R 4 -#define SAP_ACT_SEND_TEST_C 5 -#define SAP_ACT_SEND_TEST_R 6 -#define SAP_ACT_REPORT_STATUS 7 -#define SAP_ACT_XID_IND 8 -#define SAP_ACT_TEST_IND 9 - -/* All action functions must look like this */ -typedef int (*llc_sap_action_t )(struct llc_sap *sap,struct sk_buff *skb); - -int llc_sap_action_unitdata_ind (struct llc_sap *sap,struct sk_buff *skb); -int llc_sap_action_send_ui (struct llc_sap *sap,struct sk_buff *skb); -int llc_sap_action_send_xid_c (struct llc_sap *sap,struct sk_buff *skb); -int llc_sap_action_send_xid_r (struct llc_sap *sap,struct sk_buff *skb); -int llc_sap_action_send_test_c (struct llc_sap *sap,struct sk_buff *skb); -int llc_sap_action_send_test_r (struct llc_sap *sap,struct sk_buff *skb); -int llc_sap_action_report_status (struct llc_sap *sap,struct sk_buff *skb); -int llc_sap_action_xid_ind (struct llc_sap *sap,struct sk_buff *skb); -int llc_sap_action_test_ind (struct llc_sap *sap,struct sk_buff *skb); -#endif /* LLC_S_AC_H */
include/net/llc_s_ev.h deleted +0 -61
61 lines not on this page · raw message
include/net/llc_s_st.h deleted +0 -32
@@ -1,32 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef LLC_S_ST_H -#define LLC_S_ST_H -/* -* Copyright (c) 1997 by Procom Technology,Inc. -* 2001 by Arnaldo Carvalho de Melo <[email protected]> -*/ - -#include <linux/types.h> -#include <net/llc_s_ac.h> -#include <net/llc_s_ev.h> - -struct llc_sap_state_trans ; - -#define LLC_NR_SAP_STATES 2/* size of state table */ - -/* structures and types */ -/* SAP state table structure */ -struct llc_sap_state_trans { -llc_sap_ev_t ev; -u8 next_state; -const llc_sap_action_t *ev_actions; -}; - -struct llc_sap_state { -u8 curr_state; -const struct llc_sap_state_trans **transitions; -}; - -/* only access to SAP state table */ -extern struct llc_sap_state llc_sap_state_table[LLC_NR_SAP_STATES ]; -#endif /* LLC_S_ST_H */
include/net/llc_sap.h deleted +0 -26
@@ -1,26 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef LLC_SAP_H -#define LLC_SAP_H - -#include <asm/types.h> - -/* -* Copyright (c) 1997 by Procom Technology,Inc. -* 2001-2003 by Arnaldo Carvalho de Melo <[email protected]> -*/ -struct llc_sap ; -struct net_device ; -struct sk_buff ; -struct sock ; - -void llc_sap_rtn_pdu (struct llc_sap *sap,struct sk_buff *skb); -void llc_save_primitive (struct sock *sk,struct sk_buff *skb, -unsigned char prim); -struct sk_buff *llc_alloc_frame (struct sock *sk,struct net_device *dev, -u8 type,u32 data_size); - -void llc_build_and_send_test_pkt (struct llc_sap *sap,struct sk_buff *skb, -unsigned char *dmac,unsigned char dsap); -void llc_build_and_send_xid_pkt (struct llc_sap *sap,struct sk_buff *skb, -unsigned char *dmac,unsigned char dsap); -#endif /* LLC_SAP_H */
net/llc/af_llc.c deleted +0 -1304
1,304 lines not on this page · raw message
net/llc/llc_c_ac.c deleted +0 -1448
855 lines not on this page · raw message
net/llc/llc_c_ev.c deleted +0 -742
742 lines not on this page · raw message
net/llc/llc_c_st.c deleted +0 -4940
4,940 lines not on this page · raw message
net/llc/llc_conn.c deleted +0 -1025
1,025 lines not on this page · raw message
net/llc/llc_if.c deleted +0 -151
151 lines not on this page · raw message
net/llc/llc_pdu.c deleted +0 -366
366 lines not on this page · raw message
net/llc/llc_proc.c deleted +0 -245
245 lines not on this page · raw message
net/llc/llc_s_ac.c deleted +0 -220
220 lines not on this page · raw message
net/llc/llc_s_ev.c deleted +0 -109
109 lines not on this page · raw message
net/llc/llc_s_st.c deleted +0 -177
177 lines not on this page · raw message
net/llc/llc_sap.c deleted +0 -437
437 lines not on this page · raw message
net/llc/llc_station.c deleted +0 -120
120 lines not on this page · raw message
net/llc/sysctl_net_llc.c deleted +0 -71
71 lines not on this page · raw message
arch/loongarch/configs/loongson32_defconfig +0 -1
Lines of this file are not shown. View the raw message.
arch/loongarch/configs/loongson64_defconfig +0 -1
Lines of this file are not shown. View the raw message.
arch/parisc/configs/generic-32bit_defconfig +0 -1
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.55.0
Part of the diff is not shown here. View the raw message.
Jakub Kicinski
maintainerPATCH 2/3 llc: strip the leftovers of the llc2 removal
In reply to Jakub KicinskiNothing in tree registers the type 1 / type 2 packet handlers or the station handler any more, and nothing looks at the socket hashes hanging off struct llc_sap. The two SAPs opened in tree - SNAP, and STP for the bridge's BPDUs and GARP's PDUs - receive through the per-SAP rcv_func(), so llc_rcv() boils down to a SAP lookup and a call. llc_sap_list becomes static and five exports go away with all this; the llc2 module out of tree has been reworked to open its own SAPs.
Frames with a NULL DSAP used to be handed to the station handler before the SAP lookup. They take the normal path now, meaning they get dropped unless something registers SAP 0.
struct llc_sap is down to 48 bytes on 64-bit from over a kilobyte, which also moves its GFP_ATOMIC allocation from kmalloc-2k to kmalloc-64. The two 64-entry socket hashes are the bulk of it, and the address it carried is now just the SAP number - nothing has read the MAC half since the socket layer left.
llc_pdu.h keeps only what its remaining users need, plus LLC_PDU_RSP to document the one argument which can take it. That takes out the type 2 (I and S format, FRMR) definitions, the XID and TEST builders with their constants - the kernel neither sends nor answers either any more
- the SAP address defines, the field accessors, and the prototypes of the llc_pdu.c helpers which went out of tree with the rest of LLC2. With the I and S formats gone llc_pdu_header_init() has one PDU type left, so drop the argument.
--- include/net/llc.h | 82 +-------- include/net/llc_pdu.h | 379 +-------------------------------------- net/802/garp.c | 4 +- net/802/psnap.c | 2 +- net/bridge/br_stp_bpdu.c | 3 +- net/llc/llc_core.c | 25 +-- net/llc/llc_input.c | 125 +------------ net/llc/llc_output.c | 3 +- 8 files changed, 32 insertions(+), 591 deletions(-)
include/net/llc.h +7 -75
@@ -6,112 +6,44 @@* 2001-2003 by Arnaldo Carvalho de Melo <[email protected]> */ -#include <linux/if.h> -#include <linux/if_ether.h> #include <linux/list.h> -#include <linux/spinlock.h> -#include <linux/rculist_nulls.h> -#include <linux/hash.h> -#include <linux/jhash.h> - -#include <linux/atomic.h> +#include <linux/refcount.h> struct net_device ;struct packet_type ;struct sk_buff ; -struct llc_addr { -unsigned char lsap; -unsigned char mac[IFHWADDRLEN ]; -}; - -#define LLC_SAP_STATE_INACTIVE 1 -#define LLC_SAP_STATE_ACTIVE 2 - -#define LLC_SK_DEV_HASH_BITS 6 -#define LLC_SK_DEV_HASH_ENTRIES (1<<LLC_SK_DEV_HASH_BITS) - -#define LLC_SK_LADDR_HASH_BITS 6 -#define LLC_SK_LADDR_HASH_ENTRIES (1<<LLC_SK_LADDR_HASH_BITS) -/** * struct llc_sap - Defines the SAP component * -* @station - station this sap belongs to -* @state - sap state -* @p_bit - only lowest-order bit used -* @f_bit - only lowest-order bit used -* @laddr - SAP value in this 'lsap' -* @node - entry in station sap_list -* @sk_list - LLC sockets this one manages +* @refcnt: reference count +* @lsap: SAP number +* @rcv_func: handler for the PDUs addressed to this SAP +* @node: entry in the SAP list +* @rcu: for deferred freeing */ struct llc_sap { -unsigned char state; -unsigned char p_bit; -unsigned char f_bit;refcount_t refcnt; +unsigned char lsap;int (*rcv_func)(struct sk_buff *skb,struct net_device *dev,struct packet_type *pt,struct net_device *orig_dev); -struct llc_addr laddr;struct list_head node; -spinlock_t sk_lock; -int sk_count; -struct hlist_nulls_head sk_laddr_hash[LLC_SK_LADDR_HASH_ENTRIES ]; -struct hlist_head sk_dev_hash[LLC_SK_DEV_HASH_ENTRIES ];struct rcu_head rcu; }; -static inline -struct hlist_head *llc_sk_dev_hash (struct llc_sap *sap,int ifindex) -{ -u32 bucket =hash_32 (ifindex,LLC_SK_DEV_HASH_BITS ); - -return &sap->sk_dev_hash[bucket]; -} - -static inline -u32 llc_sk_laddr_hashfn (struct llc_sap *sap,const struct llc_addr *laddr) -{ -return hash_32 (jhash (laddr->mac,sizeof (laddr->mac),0 ), -LLC_SK_LADDR_HASH_BITS ); -} - -static inline -struct hlist_nulls_head *llc_sk_laddr_hash (struct llc_sap *sap, -const struct llc_addr *laddr) -{ -return &sap->sk_laddr_hash[llc_sk_laddr_hashfn (sap, laddr)]; -} - -#define LLC_DEST_INVALID 0/* Invalid LLC PDU type */ -#define LLC_DEST_SAP 1/* Type 1 goes here */ -#define LLC_DEST_CONN 2/* Type 2 goes here */ - -extern struct list_head llc_sap_list; -int llc_rcv (struct sk_buff *skb,struct net_device *dev,struct packet_type *pt,struct net_device *orig_dev);int llc_mac_hdr_init (struct sk_buff *skb,const unsigned char *sa,const unsigned char *da); -void llc_add_pack (int type, -void (*handler)(struct llc_sap *sap,struct sk_buff *skb)); -void llc_remove_pack (int type); - -void llc_set_station_handler (void (*handler)(struct sk_buff *skb)); -struct llc_sap *llc_sap_open (unsigned char lsap,int (*rcv)(struct sk_buff *skb,struct net_device *dev,struct packet_type *pt,struct net_device *orig_dev)); -static inline void llc_sap_hold (struct llc_sap *sap) -{ -refcount_inc (&sap->refcnt); -}static inline bool llc_sap_hold_safe (struct llc_sap *sap) {
include/net/llc_pdu.h +5 -374
419 lines not on this page · raw message
net/802/garp.c +2 -2
@@ -255,8 +255,8 @@ static void garp_pdu_queue(struct garp_applicant *app)garp_pdu_append_end_mark (app);garp_pdu_append_end_mark (app); -llc_pdu_header_init (app->pdu,LLC_PDU_TYPE_U ,LLC_SAP_BSPAN , -LLC_SAP_BSPAN ,LLC_PDU_CMD ); +llc_pdu_header_init (app->pdu,LLC_SAP_BSPAN ,LLC_SAP_BSPAN , +LLC_PDU_CMD );llc_pdu_init_as_ui_cmd (app->pdu);llc_mac_hdr_init (app->pdu, app->dev->dev_addr, app->app->proto.group_address);
net/802/psnap.c +1 -1
@@ -82,7 +82,7 @@ static int snap_request(struct datalink_proto *dl, struct sk_buff *skb, const u8 *dest) { memcpy(skb_push(skb, 5), dl->type, 5); -llc_build_and_send_ui_pkt (snap_sap, skb, dest, snap_sap->laddr.lsap); +llc_build_and_send_ui_pkt (snap_sap, skb, dest, snap_sap->lsap);return 0 ; }
net/bridge/br_stp_bpdu.c +1 -2
@@ -48,8 +48,7 @@ static void br_send_bpdu(struct net_bridge_port *p,skb_reserve (skb,LLC_RESERVE );__skb_put_data (skb, data, length); -llc_pdu_header_init (skb,LLC_PDU_TYPE_U ,LLC_SAP_BSPAN , -LLC_SAP_BSPAN ,LLC_PDU_CMD ); +llc_pdu_header_init (skb,LLC_SAP_BSPAN ,LLC_SAP_BSPAN ,LLC_PDU_CMD );llc_pdu_init_as_ui_cmd (skb);if (llc_mac_hdr_init (skb, p->dev->dev_addr, p->br->group_addr)) {
net/llc/llc_core.c +6 -19
@@ -16,7 +16,7 @@#include <net/net_namespace.h> #include <net/llc.h> -LIST_HEAD (llc_sap_list); +static LIST_HEAD (llc_sap_list);static DEFINE_SPINLOCK (llc_sap_list_lock);/**
@@ -27,16 +27,9 @@ static DEFINE_SPINLOCK(llc_sap_list_lock);static struct llc_sap *llc_sap_alloc (void ) {struct llc_sap *sap =kzalloc_obj (*sap,GFP_ATOMIC ); -int i; -if (sap) { -/* sap->laddr.mac - leave as a null, it's filled by bind */ - sap->state =LLC_SAP_STATE_ACTIVE ; -spin_lock_init (&sap->sk_lock); -for (i =0 ; i <LLC_SK_LADDR_HASH_ENTRIES ; i++) -INIT_HLIST_NULLS_HEAD (&sap->sk_laddr_hash[i], i); +if (sap)refcount_set (&sap->refcnt,1 ); - }return sap; }
@@ -45,7 +38,7 @@ static struct llc_sap *__llc_sap_find(unsigned char sap_value)struct llc_sap *sap;list_for_each_entry (sap, &llc_sap_list, node) -if (sap->laddr.lsap == sap_value) +if (sap->lsap == sap_value) goto out; sap =NULL ; out:
@@ -53,10 +46,9 @@ static struct llc_sap *__llc_sap_find(unsigned char sap_value) }/** -* llc_sap_find - searches a SAP in station +* llc_sap_find - searches for a SAP by its number * @sap_value: sap to be found * -* Searches for a sap in the sap list of the LLC's station upon the sap ID. * If the sap is found it will be refcounted and the user will have to do * a llc_sap_put after use. * Returns the sap or %NULL if not found.
@@ -96,7 +88,7 @@ struct llc_sap *llc_sap_open(unsigned char lsap, sap =llc_sap_alloc ();if (!sap) goto out; - sap->laddr.lsap = lsap; + sap->lsap = lsap; sap->rcv_func = func;list_add_tail_rcu (&sap->node, &llc_sap_list); out:
@@ -110,13 +102,10 @@ struct llc_sap *llc_sap_open(unsigned char lsap,* * Close interface function to upper layer. Each one who wants to * close an open SAP (for example NetBEUI) should call this function. -* Removes this sap from the list of saps in the station and then -* frees the memory for this sap. +* Removes this sap from the SAP list and then frees the memory for it. */ void llc_sap_close (struct llc_sap *sap) { -WARN_ON (sap->sk_count); -spin_lock_bh (&llc_sap_list_lock);list_del_rcu (&sap->node);spin_unlock_bh (&llc_sap_list_lock);
@@ -143,8 +132,6 @@ static void __exit llc_exit(void)module_init (llc_init);module_exit (llc_exit); -EXPORT_SYMBOL (llc_sap_list); -EXPORT_SYMBOL (llc_sap_find);EXPORT_SYMBOL (llc_sap_open);EXPORT_SYMBOL (llc_sap_close);
net/llc/llc_input.c +9 -116
166 lines not on this page · raw message
net/llc/llc_output.c +1 -2
@@ -59,8 +59,7 @@ int llc_build_and_send_ui_pkt(struct llc_sap *sap, struct sk_buff *skb, const unsigned char *dmac, unsigned char dsap) { int rc; -llc_pdu_header_init (skb,LLC_PDU_TYPE_U , sap->laddr.lsap, - dsap,LLC_PDU_CMD ); +llc_pdu_header_init (skb, sap->lsap, dsap,LLC_PDU_CMD );llc_pdu_init_as_ui_cmd (skb); rc =llc_mac_hdr_init (skb, skb->dev->dev_addr, dmac);if (likely (!rc))
Signature · 1 line
2.55.0
Jakub Kicinski
maintainerPATCH 3/3 net: drop unused LLC-related includes
In reply to Jakub KicinskiThe bridge and the openvswitch code include <net/llc.h>, <net/llc_pdu.h> and <linux/llc.h> without using anything out of them. parse_ethertype() is the one exception: it wants LLC_SAP_SNAP, which comes from the uAPI header <linux/llc.h> pulls in, so flow.c keeps that one. The LLC core has leftovers of its own - slab, string, interrupt and net_namespace - which it has not used in a long time.
None of this is new, the type 2 removal has just shrunk the LLC headers enough to make it easy to see.
--- net/bridge/br.c | 2 -- net/llc/llc_core.c | 3 --- net/llc/llc_input.c | 2 -- net/openvswitch/flow.c | 1 - net/openvswitch/flow_netlink.c | 2 -- net/openvswitch/flow_table.c | 2 -- net/openvswitch/vport-netdev.c | 1 - 7 files changed, 13 deletions(-)
net/bridge/br.c +0 -2
@@ -12,8 +12,6 @@#include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/init.h> -#include <linux/llc.h> -#include <net/llc.h> #include <net/stp.h> #include <net/switchdev.h>
net/llc/llc_core.c +0 -3
@@ -7,13 +7,10 @@*/ #include <linux/module.h> -#include <linux/interrupt.h> #include <linux/if_ether.h> #include <linux/netdevice.h> #include <linux/slab.h> -#include <linux/string.h> #include <linux/init.h> -#include <net/net_namespace.h> #include <net/llc.h> static LIST_HEAD (llc_sap_list);
net/llc/llc_input.c +0 -2
@@ -6,8 +6,6 @@* 2001-2003 by Arnaldo Carvalho de Melo <[email protected]> */ #include <linux/netdevice.h> -#include <linux/slab.h> -#include <net/net_namespace.h> #include <net/llc.h> #include <net/llc_pdu.h>
net/openvswitch/flow.c +0 -1
@@ -8,7 +8,6 @@#include <linux/etherdevice.h> #include <linux/if_ether.h> #include <linux/if_vlan.h> -#include <net/llc_pdu.h> #include <linux/kernel.h> #include <linux/jhash.h> #include <linux/jiffies.h>
net/openvswitch/flow_netlink.c +0 -2
@@ -12,11 +12,9 @@#include <linux/etherdevice.h> #include <linux/if_ether.h> #include <linux/if_vlan.h> -#include <net/llc_pdu.h> #include <linux/kernel.h> #include <linux/jhash.h> #include <linux/jiffies.h> -#include <linux/llc.h> #include <linux/module.h> #include <linux/in.h> #include <linux/rcupdate.h>
net/openvswitch/flow_table.c +0 -2
@@ -11,11 +11,9 @@#include <linux/etherdevice.h> #include <linux/if_ether.h> #include <linux/if_vlan.h> -#include <net/llc_pdu.h> #include <linux/kernel.h> #include <linux/jhash.h> #include <linux/jiffies.h> -#include <linux/llc.h> #include <linux/module.h> #include <linux/in.h> #include <linux/rcupdate.h>
net/openvswitch/vport-netdev.c +0 -1
@@ -9,7 +9,6 @@#include <linux/if_bridge.h> #include <linux/if_vlan.h> #include <linux/kernel.h> -#include <linux/llc.h> #include <linux/rtnetlink.h> #include <linux/skbuff.h> #include <linux/openvswitch.h>
Signature · 1 line
2.55.0
Re: [PATCH net-next 3/3] net: drop unused LLC-related includes
Quoted 7 lines · Jakub Kicinski
The bridge and the openvswitch code include <
net/llc.h>, <net/llc_pdu.h> and <linux/llc.h> without using anything out of them.parse_ethertype()is the one exception: it wantsLLC_SAP_SNAP, which comes from the uAPI header <linux/llc.h> pulls in, soflow.ckeeps that one. The LLC core has leftovers of its own - slab, string, interrupt andnet_namespace- which it has not used in a long time.
Quoted 5 lines
None of this is new, the type 2 removal has just shrunk the LLC headers enough to make it easy to see.
Signed-off-by Jakub Kicinski <[email protected]>---
The openvswitch changes look fine to me. I guess it's just a minimal header adjustment so:
NOTE: I didn't review anything else in the series.
Quoted 76 lines · Jakub Kicinski
LLC2 sockets are admin-only already. We have been getting a trickle of LLM-driven fixes for these, even tho we don't know of any active user. The code is so bad the LLM fixes just turn into a never ending stream of revisions and follow ups as fixing one condition reveals 5 more bugs. Let's move this code out of tree.
The series itself is LLM generated, the LLM was also nice enough to generates some tests and validate that the OOT module actually works.
Jakub Kicinski (3):
llc: move the type 2 sockets out of tree
llc: strip the leftovers of the llc2 removal
net: drop unused LLC-related includesnet/llc/Kconfig | 7 - net/llc/Makefile | 10 +- include/linux/llc.h | 5 - include/net/llc.h | 108 +- include/net/llc_c_ac.h | 180 - include/net/llc_c_ev.h | 217 - include/net/llc_c_st.h | 46 - include/net/llc_conn.h | 114 - include/net/llc_if.h | 63 - include/net/llc_pdu.h | 379 +- include/net/llc_s_ac.h | 35 - include/net/llc_s_ev.h | 61 - include/net/llc_s_st.h | 32 - include/net/llc_sap.h | 26 - net/802/garp.c | 4 +- net/802/psnap.c | 2 +- net/bridge/br.c | 2 - net/bridge/br_stp_bpdu.c | 3 +- net/llc/af_llc.c | 1304 ----- net/llc/llc_c_ac.c | 1448 ------ net/llc/llc_c_ev.c | 742 --- net/llc/llc_c_st.c | 4940 ------------------- net/llc/llc_conn.c | 1025 ---- net/llc/llc_core.c | 28 +- net/llc/llc_if.c | 151 - net/llc/llc_input.c | 128 +- net/llc/llc_output.c | 3 +- net/llc/llc_pdu.c | 366 -- net/llc/llc_proc.c | 245 - net/llc/llc_s_ac.c | 220 - net/llc/llc_s_ev.c | 109 - net/llc/llc_s_st.c | 177 - net/llc/llc_sap.c | 437 -- net/llc/llc_station.c | 120 - net/llc/sysctl_net_llc.c | 71 - net/openvswitch/flow.c | 1 - net/openvswitch/flow_netlink.c | 2 - net/openvswitch/flow_table.c | 2 - net/openvswitch/vport-netdev.c | 1 - arch/loongarch/configs/loongson32_defconfig | 1 - arch/loongarch/configs/loongson64_defconfig | 1 - arch/mips/configs/gpr_defconfig | 1 - arch/mips/configs/mtx1_defconfig | 1 - arch/mips/configs/rb532_defconfig | 1 - arch/parisc/configs/generic-32bit_defconfig | 1 - 45 files changed, 33 insertions(+), 12787 deletions(-)delete mode 100644
include/net/llc_c_ac.h
delete mode 100644include/net/llc_c_ev.h
delete mode 100644include/net/llc_c_st.h
delete mode 100644include/net/llc_conn.h
delete mode 100644include/net/llc_if.h
delete mode 100644include/net/llc_s_ac.h
delete mode 100644include/net/llc_s_ev.h
delete mode 100644include/net/llc_s_st.h
delete mode 100644include/net/llc_sap.h
delete mode 100644net/llc/af_llc.c
delete mode 100644net/llc/llc_c_ac.c
delete mode 100644net/llc/llc_c_ev.c
delete mode 100644net/llc/llc_c_st.c
delete mode 100644net/llc/llc_conn.c
delete mode 100644net/llc/llc_if.c
Quoted 9 lines
delete mode 100644
net/llc/llc_pdu.c
delete mode 100644net/llc/llc_proc.c
delete mode 100644net/llc/llc_s_ac.c
delete mode 100644net/llc/llc_s_ev.c
delete mode 100644net/llc/llc_s_st.c
delete mode 100644net/llc/llc_sap.c
delete mode 100644net/llc/llc_station.c
delete mode 100644net/llc/sysctl_net_llc.c
Reviewed what I could, generally sounds good as well.
For the series:
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 11 lines · On Mon, 28 Sep 2026 12:07:57 -0700 you wrote:
LLC2 sockets are admin-only already. We have been getting a trickle of LLM-driven fixes for these, even tho we don't know of any active user. The code is so bad the LLM fixes just turn into a never ending stream of revisions and follow ups as fixing one condition reveals 5 more bugs. Let's move this code out of tree.
The series itself is LLM generated, the LLM was also nice enough to generates some tests and validate that the OOT module actually works.
[...]
Here is the summary with links:
- [net-next,1/3] llc: move the type 2 sockets out of tree
https://git.kernel.org/netdev/net-next/c/003f21868b2b - [net-next,2/3] llc: strip the leftovers of the llc2 removal https://git.kernel.org/netdev/net-next/c/6c1f58d7d5df - [net-next,3/3] net: drop unused LLC-related includes https://git.kernel.org/netdev/net-next/c/0b934eb6b142
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Re: [PATCH net-next 1/3] llc: move the type 2 sockets out of tree
In reply to Jakub KicinskiQuoted 8 lines · On Mon, 28 Sep 2026 12:07:58 -0700 Jakub Kicinski <[email protected]> wrote:
802.2 LLC is only used in tree by protocols which need the connectionless type 1 subset: STP, which carries the bridge's BPDUs, GARP, which sends its own UI PDUs, and SNAP. The llc2 module on top of the core - the type 2 connection state machine, the type 1 SAP state machine, the station component and the
PF_LLCsocket family - has no in-kernel users and nobody who can test it; what we get instead is a slow trickle of drive-by fixes.
Quoted 7 lines
There was a recent patch from Ernestas Kulik indicating potential real life use, but it was new/experimental and that person is not responding to off-list pings.
Let LLC2 follow AX.25, hamradio and AppleTalk out of the Linux tree. We will maintain the code at: github.com/linux-netdev/mod-orphan for anyone interested in playing with it.
As far as I remember the only historic use of LLC2 was netbeui (which I've probably misspelled).
That was really replaced by NetBios of TCP.
So we are in the age of 8-bit ISA ethernet cards that stood no chance of receiving the 15 back-to-back ethernet frames they issued credit for. Oh, and another stunningly bad ISA card that sometimes failed to indicate there was a frame in its rx fifo (for pio reads) until the following frame arrived (even the fifo byte count was wrong).
I can't remember exactly why that completely broke llc2.
David
Quoted 12,516 lines
PF_LLCgoes in full, both the class twoSOCK_STREAMand the class oneSOCK_DGRAMhalf, and so do/proc/net/llc/and/proc/sys/net/llc/. Note that the kernel also stops answering XID and TEST commands, addressed to a SAP or to the station - those are type 1, but they lived in the module, and they got answered whether or not any socket was open. Nothing in tree asks for them; what the core keeps is SAP registration and the UI path the in-tree users need.Retain the uAPI for now, like we did for AppleTalk. Only the socket ABI half of it is vestigial: STP, GARP, the bridge and openvswitch use the SAP numbers it defines. Cleaning up what the core no longer needs follows in the next patch.
Signed-off-by Jakub Kicinski <[email protected]>---
CC: Ernestas Kulik <[email protected]>--- net/llc/Kconfig | 7 - net/llc/Makefile | 10 +- include/linux/llc.h | 5 - include/net/llc.h | 26 - include/net/llc_c_ac.h | 180 - include/net/llc_c_ev.h | 217 - include/net/llc_c_st.h | 46 - include/net/llc_conn.h | 114 - include/net/llc_if.h | 63 - include/net/llc_s_ac.h | 35 - include/net/llc_s_ev.h | 61 - include/net/llc_s_st.h | 32 - include/net/llc_sap.h | 26 - net/llc/af_llc.c | 1304 ----- net/llc/llc_c_ac.c | 1448 ------ net/llc/llc_c_ev.c | 742 --- net/llc/llc_c_st.c | 4940 ------------------- net/llc/llc_conn.c | 1025 ---- net/llc/llc_if.c | 151 - net/llc/llc_input.c | 1 - net/llc/llc_pdu.c | 366 -- net/llc/llc_proc.c | 245 - net/llc/llc_s_ac.c | 220 - net/llc/llc_s_ev.c | 109 - net/llc/llc_s_st.c | 177 - net/llc/llc_sap.c | 437 -- net/llc/llc_station.c | 120 - net/llc/sysctl_net_llc.c | 71 - arch/loongarch/configs/loongson32_defconfig | 1 - arch/loongarch/configs/loongson64_defconfig | 1 - arch/mips/configs/gpr_defconfig | 1 - arch/mips/configs/mtx1_defconfig | 1 - arch/mips/configs/rb532_defconfig | 1 - arch/parisc/configs/generic-32bit_defconfig | 1 - 34 files changed, 1 insertion(+), 12183 deletions(-) delete mode 100644 include/net/llc_c_ac.h delete mode 100644 include/net/llc_c_ev.h delete mode 100644 include/net/llc_c_st.h delete mode 100644 include/net/llc_conn.h delete mode 100644 include/net/llc_if.h delete mode 100644 include/net/llc_s_ac.h delete mode 100644 include/net/llc_s_ev.h delete mode 100644 include/net/llc_s_st.h delete mode 100644 include/net/llc_sap.h delete mode 100644 net/llc/af_llc.c delete mode 100644 net/llc/llc_c_ac.c delete mode 100644 net/llc/llc_c_ev.c delete mode 100644 net/llc/llc_c_st.c delete mode 100644 net/llc/llc_conn.c delete mode 100644 net/llc/llc_if.c delete mode 100644 net/llc/llc_pdu.c delete mode 100644 net/llc/llc_proc.c delete mode 100644 net/llc/llc_s_ac.c delete mode 100644 net/llc/llc_s_ev.c delete mode 100644 net/llc/llc_s_st.c delete mode 100644 net/llc/llc_sap.c delete mode 100644 net/llc/llc_station.c delete mode 100644 net/llc/sysctl_net_llc.cnet/llc/Kconfig +0
-7@@ -1,10 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only config LLC tristate - -config LLC2 - tristate "ANSI/IEEE 802.2 LLC type 2 Support" - select LLC - help - This is a Logical Link Layer type 2, connection oriented support. - Select this if you want to have support for PF_LLC sockets.net/llc/Makefile +1
-9@@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 ########################################################################### -# Makefile for the Linux 802.2 LLC (fully-functional) layer. +# Makefile for the Linux 802.2 LLC layer. # # Copyright (c) 1997 by Procom Technology,Inc. # 2001-2003 by Arnaldo Carvalho de Melo <[email protected]>@@ -9,11 +9,3 @@ obj-$(CONFIG_LLC) += llc.o llc-y := llc_core.o llc_input.o llc_output.o - -obj-$(CONFIG_LLC2) += llc2.o - -llc2-y := llc_if.o llc_c_ev.o llc_c_ac.o llc_conn.o llc_c_st.o llc_pdu.o \ - llc_sap.o llc_s_ac.o llc_s_ev.o llc_s_st.o af_llc.o llc_station.o - -llc2-$(CONFIG_PROC_FS) += llc_proc.o -llc2-$(CONFIG_SYSCTL) += sysctl_net_llc.oinclude/linux/llc.h +0
-5@@ -9,9 +9,4 @@#include <uapi/linux/llc.h> -#define LLC_SAP_DYN_START 0xC0 -#define LLC_SAP_DYN_STOP 0xDE -#define LLC_SAP_DYN_TRIES 4 - -#define llc_ui_skb_cb (__skb) ((struct sockaddr_llc *)&((__skb)->cb[0]))#endif /* __LINUX_LLC_H */ include/net/llc.h +0
-26@@ -130,30 +130,4 @@ struct llc_sap *llc_sap_find(unsigned char sap_value);int llc_build_and_send_ui_pkt (struct llc_sap *sap,struct sk_buff *skb,const unsigned char *dmac,unsigned char dsap); - -void llc_sap_handler (struct llc_sap *sap,struct sk_buff *skb); -void llc_conn_handler (struct llc_sap *sap,struct sk_buff *skb); - -void llc_station_init (void ); -void llc_station_exit (void ); - -#ifdef CONFIG_PROC_FS -int llc_proc_init (void ); -void llc_proc_exit (void ); -#else -#define llc_proc_init () (0) -#define llc_proc_exit () do { } while(0) -#endif /* CONFIG_PROC_FS */ -#ifdef CONFIG_SYSCTL -int llc_sysctl_init (void ); -void llc_sysctl_exit (void ); - -extern int sysctl_llc2_ack_timeout; -extern int sysctl_llc2_busy_timeout; -extern int sysctl_llc2_p_timeout; -extern int sysctl_llc2_rej_timeout; -#else -#define llc_sysctl_init () (0) -#define llc_sysctl_exit () do { } while(0) -#endif /* CONFIG_SYSCTL */ #endif /* LLC_H */ include/net/llc_c_ac.h deleted +0
-180@@ -1,180 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef LLC_C_AC_H -#define LLC_C_AC_H -/* -* Copyright (c) 1997 by Procom Technology,Inc. -* 2001 by Arnaldo Carvalho de Melo <[email protected]> -*/ -/* Connection component state transition actions */ -/* -* Connection state transition actions -* (Fb = F bit; Pb = P bit; Xb = X bit) -*/ - -#include <linux/types.h> - -struct sk_buff ; -struct sock ; -struct timer_list ; - -#define LLC_CONN_AC_CLR_REMOTE_BUSY 1 -#define LLC_CONN_AC_CONN_IND 2 -#define LLC_CONN_AC_CONN_CONFIRM 3 -#define LLC_CONN_AC_DATA_IND 4 -#define LLC_CONN_AC_DISC_IND 5 -#define LLC_CONN_AC_RESET_IND 6 -#define LLC_CONN_AC_RESET_CONFIRM 7 -#define LLC_CONN_AC_REPORT_STATUS 8 -#define LLC_CONN_AC_CLR_REMOTE_BUSY_IF_Fb_EQ_1 9 -#define LLC_CONN_AC_STOP_REJ_TMR_IF_DATA_FLAG_EQ_2 10 -#define LLC_CONN_AC_SEND_DISC_CMD_Pb_SET_X 11 -#define LLC_CONN_AC_SEND_DM_RSP_Fb_SET_Pb 12 -#define LLC_CONN_AC_SEND_DM_RSP_Fb_SET_1 13 -#define LLC_CONN_AC_SEND_DM_RSP_Fb_SET_F_FLAG 14 -#define LLC_CONN_AC_SEND_FRMR_RSP_Fb_SET_X 15 -#define LLC_CONN_AC_RESEND_FRMR_RSP_Fb_SET_0 16 -#define LLC_CONN_AC_RESEND_FRMR_RSP_Fb_SET_Pb 17 -#define LLC_CONN_AC_SEND_I_CMD_Pb_SET_1 18 -#define LLC_CONN_AC_RESEND_I_CMD_Pb_SET_1 19 -#define LLC_CONN_AC_RESEND_I_CMD_Pb_SET_1_OR_SEND_RR 20 -#define LLC_CONN_AC_SEND_I_XXX_Xb_SET_0 21 -#define LLC_CONN_AC_RESEND_I_XXX_Xb_SET_0 22 -#define LLC_CONN_AC_RESEND_I_XXX_Xb_SET_0_OR_SEND_RR 23 -#define LLC_CONN_AC_RESEND_I_RSP_Fb_SET_1 24 -#define LLC_CONN_AC_SEND_REJ_CMD_Pb_SET_1 25 -#define LLC_CONN_AC_SEND_REJ_RSP_Fb_SET_1 26 -#define LLC_CONN_AC_SEND_REJ_XXX_Xb_SET_0 27 -#define LLC_CONN_AC_SEND_RNR_CMD_Pb_SET_1 28 -#define LLC_CONN_AC_SEND_RNR_RSP_Fb_SET_1 29 -#define LLC_CONN_AC_SEND_RNR_XXX_Xb_SET_0 30 -#define LLC_CONN_AC_SET_REMOTE_BUSY 31 -#define LLC_CONN_AC_OPTIONAL_SEND_RNR_XXX_Xb_SET_0 32 -#define LLC_CONN_AC_SEND_RR_CMD_Pb_SET_1 33 -#define LLC_CONN_AC_SEND_ACK_CMD_Pb_SET_1 34 -#define LLC_CONN_AC_SEND_RR_RSP_Fb_SET_1 35 -#define LLC_CONN_AC_SEND_ACK_RSP_Fb_SET_1 36 -#define LLC_CONN_AC_SEND_RR_XXX_Xb_SET_0 37 -#define LLC_CONN_AC_SEND_ACK_XXX_Xb_SET_0 38 -#define LLC_CONN_AC_SEND_SABME_CMD_Pb_SET_X 39 -#define LLC_CONN_AC_SEND_UA_RSP_Fb_SET_Pb 40 -#define LLC_CONN_AC_SEND_UA_RSP_Fb_SET_F_FLAG 41 -#define LLC_CONN_AC_S_FLAG_SET_0 42 -#define LLC_CONN_AC_S_FLAG_SET_1 43 -#define LLC_CONN_AC_START_P_TMR 44 -#define LLC_CONN_AC_START_ACK_TMR 45 -#define LLC_CONN_AC_START_REJ_TMR 46 -#define LLC_CONN_AC_START_ACK_TMR_IF_NOT_RUNNING 47 -#define LLC_CONN_AC_STOP_ACK_TMR 48 -#define LLC_CONN_AC_STOP_P_TMR 49 -#define LLC_CONN_AC_STOP_REJ_TMR 50 -#define LLC_CONN_AC_STOP_ALL_TMRS 51 -#define LLC_CONN_AC_STOP_OTHER_TMRS 52 -#define LLC_CONN_AC_UPDATE_Nr_RECEIVED 53 -#define LLC_CONN_AC_UPDATE_P_FLAG 54 -#define LLC_CONN_AC_DATA_FLAG_SET_2 55 -#define LLC_CONN_AC_DATA_FLAG_SET_0 56 -#define LLC_CONN_AC_DATA_FLAG_SET_1 57 -#define LLC_CONN_AC_DATA_FLAG_SET_1_IF_DATA_FLAG_EQ_0 58 -#define LLC_CONN_AC_P_FLAG_SET_0 59 -#define LLC_CONN_AC_P_FLAG_SET_P 60 -#define LLC_CONN_AC_REMOTE_BUSY_SET_0 61 -#define LLC_CONN_AC_RETRY_CNT_SET_0 62 -#define LLC_CONN_AC_RETRY_CNT_INC_BY_1 63 -#define LLC_CONN_AC_Vr_SET_0 64 -#define LLC_CONN_AC_Vr_INC_BY_1 65 -#define LLC_CONN_AC_Vs_SET_0 66 -#define LLC_CONN_AC_Vs_SET_Nr 67 -#define LLC_CONN_AC_F_FLAG_SET_P 68 -#define LLC_CONN_AC_STOP_SENDACK_TMR 70 -#define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71 - -typedef int (*llc_conn_action_t )(struct sock *sk,struct sk_buff *skb); - -int llc_conn_ac_clear_remote_busy (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_conn_ind (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_conn_confirm (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_data_ind (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_disc_ind (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_rst_ind (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_rst_confirm (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_clear_remote_busy_if_f_eq_1 (struct sock *sk, -struct sk_buff *skb); -int llc_conn_ac_stop_rej_tmr_if_data_flag_eq_2 (struct sock *sk, -struct sk_buff *skb); -int llc_conn_ac_send_disc_cmd_p_set_x (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_send_dm_rsp_f_set_p (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_send_dm_rsp_f_set_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_send_frmr_rsp_f_set_x (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_resend_frmr_rsp_f_set_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_resend_frmr_rsp_f_set_p (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_send_i_cmd_p_set_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_send_i_xxx_x_set_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_resend_i_xxx_x_set_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_resend_i_xxx_x_set_0_or_send_rr (struct sock *sk, -struct sk_buff *skb); -int llc_conn_ac_resend_i_rsp_f_set_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_send_rej_cmd_p_set_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_send_rej_rsp_f_set_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_send_rej_xxx_x_set_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_send_rnr_cmd_p_set_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_send_rnr_rsp_f_set_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_send_rnr_xxx_x_set_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_set_remote_busy (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_opt_send_rnr_xxx_x_set_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_send_rr_cmd_p_set_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_send_rr_rsp_f_set_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_send_ack_rsp_f_set_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_send_rr_xxx_x_set_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_send_ack_xxx_x_set_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_send_sabme_cmd_p_set_x (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_send_ua_rsp_f_set_p (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_set_s_flag_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_set_s_flag_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_start_p_timer (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_start_ack_timer (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_start_rej_timer (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_start_ack_tmr_if_not_running (struct sock *sk, -struct sk_buff *skb); -int llc_conn_ac_stop_ack_timer (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_stop_p_timer (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_stop_rej_timer (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_stop_all_timers (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_stop_other_timers (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_upd_nr_received (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_inc_tx_win_size (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_dec_tx_win_size (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_upd_p_flag (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_set_data_flag_2 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_set_data_flag_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_set_data_flag_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_set_data_flag_1_if_data_flag_eq_0 (struct sock *sk, -struct sk_buff *skb); -int llc_conn_ac_set_p_flag_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_set_remote_busy_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_set_retry_cnt_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_set_cause_flag_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_set_cause_flag_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_inc_retry_cnt_by_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_set_vr_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_inc_vr_by_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_set_vs_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_set_vs_nr (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_rst_vs (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_upd_vs (struct sock *sk,struct sk_buff *skb); -int llc_conn_disc (struct sock *sk,struct sk_buff *skb); -int llc_conn_reset (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_disc_confirm (struct sock *sk,struct sk_buff *skb); -u8 llc_circular_between (u8 a,u8 b,u8 c); -int llc_conn_ac_send_ack_if_needed (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_adjust_npta_by_rr (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_adjust_npta_by_rnr (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_rst_sendack_flag (struct sock *sk,struct sk_buff *skb); -int llc_conn_ac_send_i_as_ack (struct sock *sk,struct sk_buff *skb); - -void llc_conn_busy_tmr_cb (struct timer_list *t); -void llc_conn_pf_cycle_tmr_cb (struct timer_list *t); -void llc_conn_ack_tmr_cb (struct timer_list *t); -void llc_conn_rej_tmr_cb (struct timer_list *t); - -void llc_conn_set_p_flag (struct sock *sk,u8 value); -#endif /* LLC_C_AC_H */ include/net/llc_c_ev.h deleted +0
-217@@ -1,217 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef LLC_C_EV_H -#define LLC_C_EV_H -/* -* Copyright (c) 1997 by Procom Technology,Inc. -* 2001 by Arnaldo Carvalho de Melo <[email protected]> -*/ - -#include <net/sock.h> - -/* Connection component state transition event qualifiers */ -/* Types of events (possible values in 'ev->type') */ -#define LLC_CONN_EV_TYPE_SIMPLE 1 -#define LLC_CONN_EV_TYPE_CONDITION 2 -#define LLC_CONN_EV_TYPE_PRIM 3 -#define LLC_CONN_EV_TYPE_PDU 4/* command/response PDU */ -#define LLC_CONN_EV_TYPE_ACK_TMR 5 -#define LLC_CONN_EV_TYPE_P_TMR 6 -#define LLC_CONN_EV_TYPE_REJ_TMR 7 -#define LLC_CONN_EV_TYPE_BUSY_TMR 8 -#define LLC_CONN_EV_TYPE_RPT_STATUS 9 -#define LLC_CONN_EV_TYPE_SENDACK_TMR 10 - -#define NBR_CONN_EV 5 -/* Connection events which cause state transitions when fully qualified */ - -#define LLC_CONN_EV_CONN_REQ 1 -#define LLC_CONN_EV_CONN_RESP 2 -#define LLC_CONN_EV_DATA_REQ 3 -#define LLC_CONN_EV_DISC_REQ 4 -#define LLC_CONN_EV_RESET_REQ 5 -#define LLC_CONN_EV_RESET_RESP 6 -#define LLC_CONN_EV_LOCAL_BUSY_DETECTED 7 -#define LLC_CONN_EV_LOCAL_BUSY_CLEARED 8 -#define LLC_CONN_EV_RX_BAD_PDU 9 -#define LLC_CONN_EV_RX_DISC_CMD_Pbit_SET_X 10 -#define LLC_CONN_EV_RX_DM_RSP_Fbit_SET_X 11 -#define LLC_CONN_EV_RX_FRMR_RSP_Fbit_SET_X 12 -#define LLC_CONN_EV_RX_I_CMD_Pbit_SET_X 13 -#define LLC_CONN_EV_RX_I_CMD_Pbit_SET_X_UNEXPD_Ns 14 -#define LLC_CONN_EV_RX_I_CMD_Pbit_SET_X_INVAL_Ns 15 -#define LLC_CONN_EV_RX_I_RSP_Fbit_SET_X 16 -#define LLC_CONN_EV_RX_I_RSP_Fbit_SET_X_UNEXPD_Ns 17 -#define LLC_CONN_EV_RX_I_RSP_Fbit_SET_X_INVAL_Ns 18 -#define LLC_CONN_EV_RX_REJ_CMD_Pbit_SET_X 19 -#define LLC_CONN_EV_RX_REJ_RSP_Fbit_SET_X 20 -#define LLC_CONN_EV_RX_RNR_CMD_Pbit_SET_X 21 -#define LLC_CONN_EV_RX_RNR_RSP_Fbit_SET_X 22 -#define LLC_CONN_EV_RX_RR_CMD_Pbit_SET_X 23 -#define LLC_CONN_EV_RX_RR_RSP_Fbit_SET_X 24 -#define LLC_CONN_EV_RX_SABME_CMD_Pbit_SET_X 25 -#define LLC_CONN_EV_RX_UA_RSP_Fbit_SET_X 26 -#define LLC_CONN_EV_RX_XXX_CMD_Pbit_SET_X 27 -#define LLC_CONN_EV_RX_XXX_RSP_Fbit_SET_X 28 -#define LLC_CONN_EV_RX_XXX_YYY 29 -#define LLC_CONN_EV_RX_ZZZ_CMD_Pbit_SET_X_INVAL_Nr 30 -#define LLC_CONN_EV_RX_ZZZ_RSP_Fbit_SET_X_INVAL_Nr 31 -#define LLC_CONN_EV_P_TMR_EXP 32 -#define LLC_CONN_EV_ACK_TMR_EXP 33 -#define LLC_CONN_EV_REJ_TMR_EXP 34 -#define LLC_CONN_EV_BUSY_TMR_EXP 35 -#define LLC_CONN_EV_RX_XXX_CMD_Pbit_SET_1 36 -#define LLC_CONN_EV_RX_XXX_CMD_Pbit_SET_0 37 -#define LLC_CONN_EV_RX_I_CMD_Pbit_SET_0_UNEXPD_Ns 38 -#define LLC_CONN_EV_RX_I_RSP_Fbit_SET_0_UNEXPD_Ns 39 -#define LLC_CONN_EV_RX_I_RSP_Fbit_SET_1_UNEXPD_Ns 40 -#define LLC_CONN_EV_RX_I_CMD_Pbit_SET_1_UNEXPD_Ns 41 -#define LLC_CONN_EV_RX_I_CMD_Pbit_SET_0 42 -#define LLC_CONN_EV_RX_I_RSP_Fbit_SET_0 43 -#define LLC_CONN_EV_RX_I_CMD_Pbit_SET_1 44 -#define LLC_CONN_EV_RX_RR_CMD_Pbit_SET_0 45 -#define LLC_CONN_EV_RX_RR_RSP_Fbit_SET_0 46 -#define LLC_CONN_EV_RX_RR_RSP_Fbit_SET_1 47 -#define LLC_CONN_EV_RX_RR_CMD_Pbit_SET_1 48 -#define LLC_CONN_EV_RX_RNR_CMD_Pbit_SET_0 49 -#define LLC_CONN_EV_RX_RNR_RSP_Fbit_SET_0 50 -#define LLC_CONN_EV_RX_RNR_RSP_Fbit_SET_1 51 -#define LLC_CONN_EV_RX_RNR_CMD_Pbit_SET_1 52 -#define LLC_CONN_EV_RX_REJ_CMD_Pbit_SET_0 53 -#define LLC_CONN_EV_RX_REJ_RSP_Fbit_SET_0 54 -#define LLC_CONN_EV_RX_REJ_CMD_Pbit_SET_1 55 -#define LLC_CONN_EV_RX_I_RSP_Fbit_SET_1 56 -#define LLC_CONN_EV_RX_REJ_RSP_Fbit_SET_1 57 -#define LLC_CONN_EV_RX_XXX_RSP_Fbit_SET_1 58 -#define LLC_CONN_EV_TX_BUFF_FULL 59 - -#define LLC_CONN_EV_INIT_P_F_CYCLE 100 -/* -* Connection event qualifiers; for some events a certain combination of -* these qualifiers must be TRUE before event recognized valid for state; -* these constants act as indexes into the Event Qualifier function -* table -*/ -#define LLC_CONN_EV_QFY_DATA_FLAG_EQ_1 1 -#define LLC_CONN_EV_QFY_DATA_FLAG_EQ_0 2 -#define LLC_CONN_EV_QFY_DATA_FLAG_EQ_2 3 -#define LLC_CONN_EV_QFY_P_FLAG_EQ_1 4 -#define LLC_CONN_EV_QFY_P_FLAG_EQ_0 5 -#define LLC_CONN_EV_QFY_P_FLAG_EQ_Fbit 6 -#define LLC_CONN_EV_QFY_REMOTE_BUSY_EQ_0 7 -#define LLC_CONN_EV_QFY_RETRY_CNT_LT_N2 8 -#define LLC_CONN_EV_QFY_RETRY_CNT_GTE_N2 9 -#define LLC_CONN_EV_QFY_S_FLAG_EQ_1 10 -#define LLC_CONN_EV_QFY_S_FLAG_EQ_0 11 -#define LLC_CONN_EV_QFY_INIT_P_F_CYCLE 12 - -struct llc_conn_state_ev { -u8 type; -u8 prim; -u8 prim_type; -u8 reason; -u8 status; -u8 ind_prim; -u8 cfm_prim; -}; - -static __inline__struct llc_conn_state_ev *llc_conn_ev (struct sk_buff *skb) -{ -return (struct llc_conn_state_ev *)skb->cb; -} - -typedef int (*llc_conn_ev_t )(struct sock *sk,struct sk_buff *skb); -typedef int (*llc_conn_ev_qfyr_t )(struct sock *sk,struct sk_buff *skb); - -int llc_conn_ev_conn_req (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_data_req (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_disc_req (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rst_req (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_local_busy_detected (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_local_busy_cleared (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_bad_pdu (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_disc_cmd_pbit_set_x (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_dm_rsp_fbit_set_x (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_frmr_rsp_fbit_set_x (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_i_cmd_pbit_set_x_inval_ns (struct sock *sk, -struct sk_buff *skb); -int llc_conn_ev_rx_i_rsp_fbit_set_x (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_i_rsp_fbit_set_x_unexpd_ns (struct sock *sk, -struct sk_buff *skb); -int llc_conn_ev_rx_i_rsp_fbit_set_x_inval_ns (struct sock *sk, -struct sk_buff *skb); -int llc_conn_ev_rx_rej_rsp_fbit_set_x (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_sabme_cmd_pbit_set_x (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_ua_rsp_fbit_set_x (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_xxx_cmd_pbit_set_x (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_xxx_rsp_fbit_set_x (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_zzz_cmd_pbit_set_x_inval_nr (struct sock *sk, -struct sk_buff *skb); -int llc_conn_ev_rx_zzz_rsp_fbit_set_x_inval_nr (struct sock *sk, -struct sk_buff *skb); -int llc_conn_ev_p_tmr_exp (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_ack_tmr_exp (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rej_tmr_exp (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_busy_tmr_exp (struct sock *sk,struct sk_buff *skb); -/* NOT_USED functions and their variations */ -int llc_conn_ev_rx_xxx_cmd_pbit_set_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_xxx_rsp_fbit_set_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_i_cmd_pbit_set_0_unexpd_ns (struct sock *sk, -struct sk_buff *skb); -int llc_conn_ev_rx_i_cmd_pbit_set_1_unexpd_ns (struct sock *sk, -struct sk_buff *skb); -int llc_conn_ev_rx_i_cmd_pbit_set_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_i_cmd_pbit_set_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_i_rsp_fbit_set_0_unexpd_ns (struct sock *sk, -struct sk_buff *skb); -int llc_conn_ev_rx_i_rsp_fbit_set_1_unexpd_ns (struct sock *sk, -struct sk_buff *skb); -int llc_conn_ev_rx_i_rsp_fbit_set_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_i_rsp_fbit_set_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_rr_cmd_pbit_set_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_rr_cmd_pbit_set_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_rr_rsp_fbit_set_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_rr_rsp_fbit_set_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_rnr_cmd_pbit_set_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_rnr_cmd_pbit_set_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_rnr_rsp_fbit_set_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_rnr_rsp_fbit_set_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_rej_cmd_pbit_set_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_rej_cmd_pbit_set_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_rej_rsp_fbit_set_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_rej_rsp_fbit_set_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_rx_any_frame (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_tx_buffer_full (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_init_p_f_cycle (struct sock *sk,struct sk_buff *skb); - -/* Available connection action qualifiers */ -int llc_conn_ev_qlfy_data_flag_eq_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_qlfy_data_flag_eq_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_qlfy_data_flag_eq_2 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_qlfy_p_flag_eq_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_qlfy_last_frame_eq_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_qlfy_last_frame_eq_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_qlfy_p_flag_eq_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_qlfy_p_flag_eq_f (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_qlfy_remote_busy_eq_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_qlfy_remote_busy_eq_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_qlfy_retry_cnt_lt_n2 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_qlfy_retry_cnt_gte_n2 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_qlfy_s_flag_eq_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_qlfy_s_flag_eq_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_qlfy_cause_flag_eq_1 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_qlfy_cause_flag_eq_0 (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_qlfy_set_status_conn (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_qlfy_set_status_disc (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_qlfy_set_status_failed (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_qlfy_set_status_remote_busy (struct sock *sk, -struct sk_buff *skb); -int llc_conn_ev_qlfy_set_status_refuse (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_qlfy_set_status_conflict (struct sock *sk,struct sk_buff *skb); -int llc_conn_ev_qlfy_set_status_rst_done (struct sock *sk,struct sk_buff *skb); - -static __inline__int llc_conn_space (struct sock *sk,struct sk_buff *skb) -{ -return atomic_read (&sk->sk_rmem_alloc) + skb->truesize < - (unsigned int )sk->sk_rcvbuf; -} -#endif /* LLC_C_EV_H */ include/net/llc_c_st.h deleted +0
-46@@ -1,46 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef LLC_C_ST_H -#define LLC_C_ST_H -/* -* Copyright (c) 1997 by Procom Technology,Inc. -* 2001 by Arnaldo Carvalho de Melo <[email protected]> -*/ - -#include <net/llc_c_ac.h> -#include <net/llc_c_ev.h> - -/* Connection component state management */ -/* connection states */ -#define LLC_CONN_OUT_OF_SVC 0/* prior to allocation */ - -#define LLC_CONN_STATE_ADM 1/* disc, initial state */ -#define LLC_CONN_STATE_SETUP 2/* disconnected state */ -#define LLC_CONN_STATE_NORMAL 3/* connected state */ -#define LLC_CONN_STATE_BUSY 4/* connected state */ -#define LLC_CONN_STATE_REJ 5/* connected state */ -#define LLC_CONN_STATE_AWAIT 6/* connected state */ -#define LLC_CONN_STATE_AWAIT_BUSY 7/* connected state */ -#define LLC_CONN_STATE_AWAIT_REJ 8/* connected state */ -#define LLC_CONN_STATE_D_CONN 9/* disconnected state */ -#define LLC_CONN_STATE_RESET 10/* disconnected state */ -#define LLC_CONN_STATE_ERROR 11/* disconnected state */ -#define LLC_CONN_STATE_TEMP 12/* disconnected state */ - -#define NBR_CONN_STATES 12/* size of state table */ -#define NO_STATE_CHANGE 100 - -/* Connection state table structure */ -struct llc_conn_state_trans { -llc_conn_ev_t ev; -u8 next_state; -const llc_conn_ev_qfyr_t *ev_qualifiers; -const llc_conn_action_t *ev_actions; -}; - -struct llc_conn_state { -u8 current_state; -const struct llc_conn_state_trans **transitions; -}; - -extern struct llc_conn_state llc_conn_state_table[]; -#endif /* LLC_C_ST_H */ include/net/llc_conn.h deleted +0
-114@@ -1,114 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef LLC_CONN_H -#define LLC_CONN_H -/* -* Copyright (c) 1997 by Procom Technology, Inc. -* 2001, 2002 by Arnaldo Carvalho de Melo <[email protected]> -*/ -#include <linux/timer.h> -#include <net/llc_if.h> -#include <net/sock.h> -#include <linux/llc.h> - -#define LLC_EVENT 1 -#define LLC_PACKET 2 - -#define LLC2_P_TIME 2 -#define LLC2_ACK_TIME 1 -#define LLC2_REJ_TIME 3 -#define LLC2_BUSY_TIME 3 - -struct llc_timer { -struct timer_list timer; -unsigned long expire;/* timer expire time */ -}; - -struct llc_sock { -/* struct sock must be the first member of llc_sock */ -struct sock sk; -struct sockaddr_llc addr;/* address sock is bound to */ -u8 state;/* state of connection */ -struct llc_sap *sap;/* pointer to parent SAP */ -struct llc_addr laddr;/* lsap/mac pair */ -struct llc_addr daddr;/* dsap/mac pair */ -struct net_device *dev;/* device to send to remote */ -netdevice_tracker dev_tracker; -u32 copied_seq;/* head of yet unread data */ -u8 retry_count;/* number of retries */ -u8 ack_must_be_send; -u8 first_pdu_Ns; -u8 npta; -struct llc_timer ack_timer; -struct llc_timer pf_cycle_timer; -struct llc_timer rej_sent_timer; -struct llc_timer busy_state_timer;/* ind busy clr at remote LLC */ -u8 vS;/* seq# next in-seq I-PDU tx'd*/ -u8 vR;/* seq# next in-seq I-PDU rx'd*/ -u32 n2;/* max nbr re-tx's for timeout*/ -u32 n1;/* max nbr octets in I PDU */ -u8 k;/* tx window size; max = 127 */ -u8 rw;/* rx window size; max = 127 */ -u8 p_flag;/* state flags */ -u8 f_flag; -u8 s_flag; -u8 data_flag; -u8 remote_busy_flag; -u8 cause_flag; -struct sk_buff_head pdu_unack_q;/* PUDs sent/waiting ack */ -u16 link;/* network layer link number */ -u8 X;/* a temporary variable */ -u8 ack_pf;/* this flag indicates what is -the P-bit of acknowledge */ -u8 failed_data_req;/* recognize that already exist a -failed llc_data_req_handler -(tx_buffer_full or unacceptable -state */ -u8 dec_step; -u8 inc_cntr; -u8 dec_cntr; -u8 connect_step; -u8 last_nr;/* NR of last pdu received */ -u32 rx_pdu_hdr;/* used for saving header of last pdu -received and caused sending FRMR. -Used for resending FRMR */ -u32 cmsg_flags; -struct hlist_node dev_hash_node; -}; - -static inline struct llc_sock *llc_sk (const struct sock *sk) -{ -return (struct llc_sock *)sk; -} - -static __inline__void llc_set_backlog_type (struct sk_buff *skb,char type) -{ - skb->cb[sizeof (skb->cb) -1 ] = type; -} - -static __inline__char llc_backlog_type (struct sk_buff *skb) -{ -return skb->cb[sizeof (skb->cb) -1 ]; -} - -struct sock *llc_sk_alloc (struct net *net,int family,gfp_t priority, -struct proto *prot,int kern); -void llc_sk_stop_all_timers (struct sock *sk,bool sync); -void llc_sk_free (struct sock *sk); - -void llc_sk_reset (struct sock *sk); - -/* Access to a connection */ -int llc_conn_state_process (struct sock *sk,struct sk_buff *skb); -void llc_conn_send_pdu (struct sock *sk,struct sk_buff *skb); -void llc_conn_rtn_pdu (struct sock *sk,struct sk_buff *skb); -void llc_conn_resend_i_pdu_as_cmd (struct sock *sk,u8 nr,u8 first_p_bit); -void llc_conn_resend_i_pdu_as_rsp (struct sock *sk,u8 nr,u8 first_f_bit); -int llc_conn_remove_acked_pdus (struct sock *conn,u8 nr,u16 *how_many_unacked); -struct sock *llc_lookup_established (struct llc_sap *sap,struct llc_addr *daddr, -struct llc_addr *laddr,const struct net *net); -void llc_sap_add_socket (struct llc_sap *sap,struct sock *sk); -void llc_sap_remove_socket (struct llc_sap *sap,struct sock *sk); - -u8 llc_data_accept_state (u8 state); -void llc_build_offset_table (void ); -#endif /* LLC_CONN_H */ include/net/llc_if.h deleted +0
-63@@ -1,63 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef LLC_IF_H -#define LLC_IF_H -/* -* Copyright (c) 1997 by Procom Technology,Inc. -* 2001 by Arnaldo Carvalho de Melo <[email protected]> -*/ -/* Defines LLC interface to network layer */ -/* Available primitives */ -#include <linux/if.h> -#include <linux/if_arp.h> -#include <linux/llc.h> -#include <linux/etherdevice.h> -#include <net/llc.h> - -#define LLC_DATAUNIT_PRIM 1 -#define LLC_CONN_PRIM 2 -#define LLC_DATA_PRIM 3 -#define LLC_DISC_PRIM 4 -#define LLC_RESET_PRIM 5 -#define LLC_FLOWCONTROL_PRIM 6/* Not supported at this time */ -#define LLC_DISABLE_PRIM 7 -#define LLC_XID_PRIM 8 -#define LLC_TEST_PRIM 9 -#define LLC_SAP_ACTIVATION 10 -#define LLC_SAP_DEACTIVATION 11 - -#define LLC_NBR_PRIMITIVES 11 - -#define LLC_IND 1 -#define LLC_CONFIRM 2 - -/* Primitive type */ -#define LLC_PRIM_TYPE_REQ 1 -#define LLC_PRIM_TYPE_IND 2 -#define LLC_PRIM_TYPE_RESP 3 -#define LLC_PRIM_TYPE_CONFIRM 4 - -/* Reset reasons, remote entity or local LLC */ -#define LLC_RESET_REASON_REMOTE 1 -#define LLC_RESET_REASON_LOCAL 2 - -/* Disconnect reasons */ -#define LLC_DISC_REASON_RX_DM_RSP_PDU 0 -#define LLC_DISC_REASON_RX_DISC_CMD_PDU 1 -#define LLC_DISC_REASON_ACK_TMR_EXP 2 - -/* Confirm reasons */ -#define LLC_STATUS_CONN 0/* connect confirm & reset confirm */ -#define LLC_STATUS_DISC 1/* connect confirm & reset confirm */ -#define LLC_STATUS_FAILED 2/* connect confirm & reset confirm */ -#define LLC_STATUS_IMPOSSIBLE 3/* connect confirm */ -#define LLC_STATUS_RECEIVED 4/* data conn */ -#define LLC_STATUS_REMOTE_BUSY 5/* data conn */ -#define LLC_STATUS_REFUSE 6/* data conn */ -#define LLC_STATUS_CONFLICT 7/* disconnect conn */ -#define LLC_STATUS_RESET_DONE 8/* */ - -int llc_establish_connection (struct sock *sk,const u8 *lmac,u8 *dmac, -u8 dsap); -int llc_build_and_send_pkt (struct sock *sk,struct sk_buff *skb); -int llc_send_disc (struct sock *sk); -#endif /* LLC_IF_H */ include/net/llc_s_ac.h deleted +0
-35@@ -1,35 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef LLC_S_AC_H -#define LLC_S_AC_H -/* -* Copyright (c) 1997 by Procom Technology,Inc. -* 2001 by Arnaldo Carvalho de Melo <[email protected]> -*/ - -struct llc_sap ; -struct sk_buff ; - -/* SAP component actions */ -#define SAP_ACT_UNITDATA_IND 1 -#define SAP_ACT_SEND_UI 2 -#define SAP_ACT_SEND_XID_C 3 -#define SAP_ACT_SEND_XID_R 4 -#define SAP_ACT_SEND_TEST_C 5 -#define SAP_ACT_SEND_TEST_R 6 -#define SAP_ACT_REPORT_STATUS 7 -#define SAP_ACT_XID_IND 8 -#define SAP_ACT_TEST_IND 9 - -/* All action functions must look like this */ -typedef int (*llc_sap_action_t )(struct llc_sap *sap,struct sk_buff *skb); - -int llc_sap_action_unitdata_ind (struct llc_sap *sap,struct sk_buff *skb); -int llc_sap_action_send_ui (struct llc_sap *sap,struct sk_buff *skb); -int llc_sap_action_send_xid_c (struct llc_sap *sap,struct sk_buff *skb); -int llc_sap_action_send_xid_r (struct llc_sap *sap,struct sk_buff *skb); -int llc_sap_action_send_test_c (struct llc_sap *sap,struct sk_buff *skb); -int llc_sap_action_send_test_r (struct llc_sap *sap,struct sk_buff *skb); -int llc_sap_action_report_status (struct llc_sap *sap,struct sk_buff *skb); -int llc_sap_action_xid_ind (struct llc_sap *sap,struct sk_buff *skb); -int llc_sap_action_test_ind (struct llc_sap *sap,struct sk_buff *skb); -#endif /* LLC_S_AC_H */ include/net/llc_s_ev.h deleted +0
-61@@ -1,61 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef LLC_S_EV_H -#define LLC_S_EV_H -/* -* Copyright (c) 1997 by Procom Technology,Inc. -* 2001 by Arnaldo Carvalho de Melo <[email protected]> -*/ - -#include <linux/skbuff.h> -#include <net/llc.h> - -/* Defines SAP component events */ -/* Types of events (possible values in 'ev->type') */ -#define LLC_SAP_EV_TYPE_SIMPLE 1 -#define LLC_SAP_EV_TYPE_CONDITION 2 -#define LLC_SAP_EV_TYPE_PRIM 3 -#define LLC_SAP_EV_TYPE_PDU 4/* command/response PDU */ -#define LLC_SAP_EV_TYPE_ACK_TMR 5 -#define LLC_SAP_EV_TYPE_RPT_STATUS 6 - -#define LLC_SAP_EV_ACTIVATION_REQ 1 -#define LLC_SAP_EV_RX_UI 2 -#define LLC_SAP_EV_UNITDATA_REQ 3 -#define LLC_SAP_EV_XID_REQ 4 -#define LLC_SAP_EV_RX_XID_C 5 -#define LLC_SAP_EV_RX_XID_R 6 -#define LLC_SAP_EV_TEST_REQ 7 -#define LLC_SAP_EV_RX_TEST_C 8 -#define LLC_SAP_EV_RX_TEST_R 9 -#define LLC_SAP_EV_DEACTIVATION_REQ 10 - -struct llc_sap_state_ev { -u8 prim; -u8 prim_type; -u8 type; -u8 reason; -u8 ind_cfm_flag; -struct llc_addr saddr; -struct llc_addr daddr; -}; - -static __inline__struct llc_sap_state_ev *llc_sap_ev (struct sk_buff *skb) -{ -return (struct llc_sap_state_ev *)skb->cb; -} - -struct llc_sap ; - -typedef int (*llc_sap_ev_t )(struct llc_sap *sap,struct sk_buff *skb); - -int llc_sap_ev_activation_req (struct llc_sap *sap,struct sk_buff *skb); -int llc_sap_ev_rx_ui (struct llc_sap *sap,struct sk_buff *skb); -int llc_sap_ev_unitdata_req (struct llc_sap *sap,struct sk_buff *skb); -int llc_sap_ev_xid_req (struct llc_sap *sap,struct sk_buff *skb); -int llc_sap_ev_rx_xid_c (struct llc_sap *sap,struct sk_buff *skb); -int llc_sap_ev_rx_xid_r (struct llc_sap *sap,struct sk_buff *skb); -int llc_sap_ev_test_req (struct llc_sap *sap,struct sk_buff *skb); -int llc_sap_ev_rx_test_c (struct llc_sap *sap,struct sk_buff *skb); -int llc_sap_ev_rx_test_r (struct llc_sap *sap,struct sk_buff *skb); -int llc_sap_ev_deactivation_req (struct llc_sap *sap,struct sk_buff *skb); -#endif /* LLC_S_EV_H */ include/net/llc_s_st.h deleted +0
-32@@ -1,32 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef LLC_S_ST_H -#define LLC_S_ST_H -/* -* Copyright (c) 1997 by Procom Technology,Inc. -* 2001 by Arnaldo Carvalho de Melo <[email protected]> -*/ - -#include <linux/types.h> -#include <net/llc_s_ac.h> -#include <net/llc_s_ev.h> - -struct llc_sap_state_trans ; - -#define LLC_NR_SAP_STATES 2/* size of state table */ - -/* structures and types */ -/* SAP state table structure */ -struct llc_sap_state_trans { -llc_sap_ev_t ev; -u8 next_state; -const llc_sap_action_t *ev_actions; -}; - -struct llc_sap_state { -u8 curr_state; -const struct llc_sap_state_trans **transitions; -}; - -/* only access to SAP state table */ -extern struct llc_sap_state llc_sap_state_table[LLC_NR_SAP_STATES ]; -#endif /* LLC_S_ST_H */ include/net/llc_sap.h deleted +0
-26@@ -1,26 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef LLC_SAP_H -#define LLC_SAP_H - -#include <asm/types.h> - -/* -* Copyright (c) 1997 by Procom Technology,Inc. -* 2001-2003 by Arnaldo Carvalho de Melo <[email protected]> -*/ -struct llc_sap ; -struct net_device ; -struct sk_buff ; -struct sock ; - -void llc_sap_rtn_pdu (struct llc_sap *sap,struct sk_buff *skb); -void llc_save_primitive (struct sock *sk,struct sk_buff *skb, -unsigned char prim); -struct sk_buff *llc_alloc_frame (struct sock *sk,struct net_device *dev, -u8 type,u32 data_size); - -void llc_build_and_send_test_pkt (struct llc_sap *sap,struct sk_buff *skb, -unsigned char *dmac,unsigned char dsap); -void llc_build_and_send_xid_pkt (struct llc_sap *sap,struct sk_buff *skb, -unsigned char *dmac,unsigned char dsap); -#endif /* LLC_SAP_H */ net/llc/af_llc.c deleted +0
-1304@@ -1,1304 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* -* af_llc.c - LLC User Interface SAPs -* Description: -* Functions in this module are implementation of socket based llc -* communications for the Linux operating system. Support of llc class -* one and class two is provided via SOCK_DGRAM and SOCK_STREAM -* respectively. -* -* An llc2 connection is (mac + sap), only one llc2 sap connection -* is allowed per mac. Though one sap may have multiple mac + sap -* connections. -* -* Copyright (c) 2001 by Jay Schulist <[email protected]> -* 2002-2003 by Arnaldo Carvalho de Melo <[email protected]> -*/ -#include <linux/compiler.h> -#include <linux/kernel.h> -#include <linux/module.h> -#include <linux/rtnetlink.h> -#include <linux/init.h> -#include <linux/slab.h> -#include <linux/sched/signal.h> -#include <linux/uio.h> - -#include <net/llc.h> -#include <net/llc_sap.h> -#include <net/llc_pdu.h> -#include <net/llc_conn.h> -#include <net/tcp_states.h> - -/* remember: uninitialized global data is zeroed because its in .bss */ -static u16 llc_ui_sap_last_autoport =LLC_SAP_DYN_START ; -static u16 llc_ui_sap_link_no_max[256 ]; -static struct sockaddr_llc llc_ui_addrnull; -static const struct proto_ops llc_ui_ops; - -static bool llc_ui_wait_for_conn (struct sock *sk,long timeout); -static int llc_ui_wait_for_disc (struct sock *sk,long timeout); -static int llc_ui_wait_for_busy_core (struct sock *sk,long timeout); - -#if 0 -#define dprintk(args...) printk(KERN_DEBUG args) -#else -#define dprintk(args...) do {} while (0) -#endif - -/* Maybe we'll add some more in the future. */ -#define LLC_CMSG_PKTINFO 1 - - -/** -* llc_ui_next_link_no - return the next unused link number for a sap -* @sap: Address of sap to get link number from. -* -* Return the next unused link number for a given sap. -*/ -static inline u16 llc_ui_next_link_no (int sap) -{ -return llc_ui_sap_link_no_max[sap]++; -} - -/** -* llc_proto_type - return eth protocol for ARP header type -* @arphrd: ARP header type. -* -* Given an ARP header type return the corresponding ethernet protocol. -*/ -static inline __be16 llc_proto_type (u16 arphrd) -{ -return htons (ETH_P_802_2 ); -} - -/** -* llc_ui_addr_null - determines if a address structure is null -* @addr: Address to test if null. -*/ -static inline u8 llc_ui_addr_null (struct sockaddr_llc *addr) -{ -return !memcmp (addr, &llc_ui_addrnull,sizeof (*addr)); -} - -/** -* llc_ui_header_len - return length of llc header based on operation -* @sk: Socket which contains a valid llc socket type. -* @addr: Complete sockaddr_llc structure received from the user. -* -* Provide the length of the llc header depending on what kind of -* operation the user would like to perform and the type of socket. -* Returns the correct llc header length. -*/ -static inline u8 llc_ui_header_len (struct sock *sk,struct sockaddr_llc *addr) -{ -u8 rc =LLC_PDU_LEN_U ; - -if (addr->sllc_test) - rc =LLC_PDU_LEN_U ; -else if (addr->sllc_xid) -/* We need to expand header to sizeof(struct llc_xid_info) -* since llc_pdu_init_as_xid_cmd() sets 4,5,6 bytes of LLC header -* as XID PDU. In llc_ui_sendmsg() we reserved header size and then -* filled all other space with user data. If we won't reserve this -* bytes, llc_pdu_init_as_xid_cmd() will overwrite user data -*/ - rc =LLC_PDU_LEN_U_XID ; -else if (sk->sk_type ==SOCK_STREAM ) - rc =LLC_PDU_LEN_I ; -return rc; -} - -/** -* llc_ui_send_data - send data via reliable llc2 connection -* @sk: Connection the socket is using. -* @skb: Data the user wishes to send. -* @noblock: can we block waiting for data? -* -* Send data via reliable llc2 connection. -* Returns 0 upon success, non-zero if action did not succeed. -* -* This function always consumes a reference to the skb. -*/ -static int llc_ui_send_data (struct sock * sk,struct sk_buff *skb,int noblock) -{ -struct llc_sock * llc =llc_sk (sk); - -if (unlikely (llc_data_accept_state (llc->state) || - llc->remote_busy_flag || - llc->p_flag)) { -long timeout =sock_sndtimeo (sk, noblock); -int rc; - - rc =llc_ui_wait_for_busy_core (sk, timeout); -if (rc) { -kfree_skb (skb); -return rc; - } - } -return llc_build_and_send_pkt (sk, skb); -} - -static void llc_ui_sk_init (struct socket *sock,struct sock *sk) -{ -sock_graft (sk, sock); - sk->sk_type = sock->type; - sock->ops = &llc_ui_ops; -} - -static struct proto llc_proto = { - .name ="LLC" , - .owner =THIS_MODULE , - .obj_size =sizeof (struct llc_sock ), - .slab_flags =SLAB_TYPESAFE_BY_RCU , -}; - -/** -* llc_ui_create - alloc and init a new llc_ui socket -* @net: network namespace (must be default network) -* @sock: Socket to initialize and attach allocated sk to. -* @protocol: Unused. -* @kern: on behalf of kernel or userspace -* -* Allocate and initialize a new llc_ui socket, validate the user wants a -* socket type we have available. -* Returns 0 upon success, negative upon failure. -*/ -static int llc_ui_create (struct net *net,struct socket *sock,int protocol, -int kern) -{ -struct sock *sk; -int rc = -ESOCKTNOSUPPORT ; - -if (!ns_capable (net->user_ns,CAP_NET_RAW )) -return -EPERM ; - -if (!net_eq (net, &init_net)) -return -EAFNOSUPPORT ; - -if (likely (sock->type ==SOCK_DGRAM || sock->type ==SOCK_STREAM )) { - rc = -ENOMEM ; - sk =llc_sk_alloc (net,PF_LLC ,GFP_KERNEL , &llc_proto, kern); -if (sk) { - rc =0 ; -llc_ui_sk_init (sock, sk); - } - } -return rc; -} - -/** -* llc_ui_release - shutdown socket -* @sock: Socket to release. -* -* Shutdown and deallocate an existing socket. -*/ -static int llc_ui_release (struct socket *sock) -{ -struct sock *sk = sock->sk; -struct llc_sock *llc; - -if (unlikely (sk ==NULL )) - goto out; -sock_hold (sk); -lock_sock (sk); - llc =llc_sk (sk); -dprintk ("%s: closing local(%02X) remote(%02X)\n" , __func__, - llc->laddr.lsap, llc->daddr.lsap); -if (!llc_send_disc (sk)) -llc_ui_wait_for_disc (sk,READ_ONCE (sk->sk_rcvtimeo)); -if (!sock_flag (sk,SOCK_ZAPPED )) { -struct llc_sap *sap = llc->sap; - -/* Hold this for release_sock(), so that llc_backlog_rcv() -* could still use it. -*/ -llc_sap_hold (sap); -llc_sap_remove_socket (llc->sap, sk); -release_sock (sk); -llc_sap_put (sap); - }else { -release_sock (sk); - } -netdev_put (llc->dev, &llc->dev_tracker); -sock_put (sk); -sock_orphan (sk); - sock->sk =NULL ; -llc_sk_free (sk); -out: -return 0 ; -} - -/** -* llc_ui_autoport - provide dynamically allocate SAP number -* -* Provide the caller with a dynamically allocated SAP number according -* to the rules that are set in this function. Returns: 0, upon failure, -* SAP number otherwise. -*/ -static int llc_ui_autoport (void ) -{ -struct llc_sap *sap; -int i, tries =0 ; - -while (tries <LLC_SAP_DYN_TRIES ) { -for (i = llc_ui_sap_last_autoport; - i <LLC_SAP_DYN_STOP ; i +=2 ) { - sap =llc_sap_find (i); -if (!sap) { - llc_ui_sap_last_autoport = i +2 ; - goto out; - } -llc_sap_put (sap); - } - llc_ui_sap_last_autoport =LLC_SAP_DYN_START ; - tries++; - } - i =0 ; -out: -return i; -} - -/** -* llc_ui_autobind - automatically bind a socket to a sap -* @sock: socket to bind -* @addr: address to connect to -* -* Used by llc_ui_connect and llc_ui_sendmsg when the user hasn't -* specifically used llc_ui_bind to bind to an specific address/sap -* -* Returns: 0 upon success, negative otherwise. -*/ -static int llc_ui_autobind (struct socket *sock,struct sockaddr_llc *addr) -{ -struct sock *sk = sock->sk; -struct llc_sock *llc =llc_sk (sk); -struct net_device *dev =NULL ; -struct llc_sap *sap; -int rc = -EINVAL ; - -if (!sock_flag (sk,SOCK_ZAPPED )) - goto out; -if (!addr->sllc_arphrd) - addr->sllc_arphrd =ARPHRD_ETHER ; -if (addr->sllc_arphrd !=ARPHRD_ETHER ) - goto out; - rc = -ENODEV ; -if (sk->sk_bound_dev_if) { - dev =dev_get_by_index (&init_net, sk->sk_bound_dev_if); -if (dev && addr->sllc_arphrd != dev->type) { -dev_put (dev); - dev =NULL ; - } - }else - dev =dev_getfirstbyhwtype (&init_net, addr->sllc_arphrd); -if (!dev) - goto out; - rc = -EUSERS ; - llc->laddr.lsap =llc_ui_autoport (); -if (!llc->laddr.lsap) - goto out; - rc = -EBUSY ;/* some other network layer is using the sap */ - sap =llc_sap_open (llc->laddr.lsap,NULL ); -if (!sap) - goto out; - -/* Note: We do not expect errors from this point. */ - llc->dev = dev; -netdev_tracker_alloc (llc->dev, &llc->dev_tracker,GFP_KERNEL ); - dev =NULL ; - -memcpy (llc->laddr.mac, llc->dev->dev_addr,IFHWADDRLEN ); -memcpy (&llc->addr, addr,sizeof (llc->addr)); -/* assign new connection to its SAP */ -llc_sap_add_socket (sap, sk); -sock_reset_flag (sk,SOCK_ZAPPED ); -llc_sap_put (sap); - rc =0 ; -out: -dev_put (dev); -return rc; -} - -/** -* llc_ui_bind - bind a socket to a specific address. -* @sock: Socket to bind an address to. -* @uaddr: Address the user wants the socket bound to. -* @addrlen: Length of the uaddr structure. -* -* Bind a socket to a specific address. For llc a user is able to bind to -* a specific sap only or mac + sap. -* If the user desires to bind to a specific mac + sap, it is possible to -* have multiple sap connections via multiple macs. -* Bind and autobind for that matter must enforce the correct sap usage -* otherwise all hell will break loose. -* Returns: 0 upon success, negative otherwise. -*/ -static int llc_ui_bind (struct socket *sock,struct sockaddr_unsized *uaddr,int addrlen) -{ -struct sockaddr_llc *addr = (struct sockaddr_llc *)uaddr; -struct sock *sk = sock->sk; -struct llc_sock *llc =llc_sk (sk); -struct net_device *dev =NULL ; -struct llc_sap *sap; -int rc = -EINVAL ; - -lock_sock (sk); -if (unlikely (!sock_flag (sk,SOCK_ZAPPED ) || addrlen !=sizeof (*addr))) - goto out; - rc = -EAFNOSUPPORT ; -if (!addr->sllc_arphrd) - addr->sllc_arphrd =ARPHRD_ETHER ; -if (unlikely (addr->sllc_family !=AF_LLC || addr->sllc_arphrd !=ARPHRD_ETHER )) - goto out; -dprintk ("%s: binding %02X\n" , __func__, addr->sllc_sap); - rc = -ENODEV ; -rcu_read_lock (); -if (sk->sk_bound_dev_if) { - dev =dev_get_by_index_rcu (&init_net, sk->sk_bound_dev_if); -if (dev) { -if (is_zero_ether_addr (addr->sllc_mac)) -memcpy (addr->sllc_mac, dev->dev_addr, -IFHWADDRLEN ); -if (addr->sllc_arphrd != dev->type || - !ether_addr_equal (addr->sllc_mac, - dev->dev_addr)) { - rc = -EINVAL ; - dev =NULL ; - } - } - }else { - dev =dev_getbyhwaddr_rcu (&init_net, addr->sllc_arphrd, - addr->sllc_mac); - } -dev_hold (dev); -rcu_read_unlock (); -if (!dev) - goto out; - -if (!addr->sllc_sap) { - rc = -EUSERS ; - addr->sllc_sap =llc_ui_autoport (); -if (!addr->sllc_sap) - goto out; - } - sap =llc_sap_find (addr->sllc_sap); -if (!sap) { - sap =llc_sap_open (addr->sllc_sap,NULL ); - rc = -EBUSY ;/* some other network layer is using the sap */ -if (!sap) - goto out; - }else { -struct llc_addr laddr, daddr; -struct sock *ask; - -memset (&laddr,0 ,sizeof (laddr)); -memset (&daddr,0 ,sizeof (daddr)); -/* -* FIXME: check if the address is multicast, -* only SOCK_DGRAM can do this. -*/ -memcpy (laddr.mac, addr->sllc_mac,IFHWADDRLEN ); - laddr.lsap = addr->sllc_sap; - rc = -EADDRINUSE ;/* mac + sap clash. */ - ask =llc_lookup_established (sap, &daddr, &laddr, &init_net); -if (ask) { -sock_put (ask); - goto out_put; - } - } - -/* Note: We do not expect errors from this point. */ - llc->dev = dev; -netdev_tracker_alloc (llc->dev, &llc->dev_tracker,GFP_KERNEL ); - dev =NULL ; - - llc->laddr.lsap = addr->sllc_sap; -memcpy (llc->laddr.mac, addr->sllc_mac,IFHWADDRLEN ); -memcpy (&llc->addr, addr,sizeof (llc->addr)); -/* assign new connection to its SAP */ -llc_sap_add_socket (sap, sk); -sock_reset_flag (sk,SOCK_ZAPPED ); - rc =0 ; -out_put: -llc_sap_put (sap); -out: -dev_put (dev); -release_sock (sk); -return rc; -} - -/** -* llc_ui_shutdown - shutdown a connect llc2 socket. -* @sock: Socket to shutdown. -* @how: What part of the socket to shutdown. -* -* Shutdown a connected llc2 socket. Currently this function only supports -* shutting down both sends and receives (2), we could probably make this -* function such that a user can shutdown only half the connection but not -* right now. -* Returns: 0 upon success, negative otherwise. -*/ -static int llc_ui_shutdown (struct socket *sock,int how) -{ -struct sock *sk = sock->sk; -int rc = -ENOTCONN ; - -lock_sock (sk); -if (unlikely (sk->sk_state !=TCP_ESTABLISHED )) - goto out; - rc = -EINVAL ; -if (how !=2 ) - goto out; - rc =llc_send_disc (sk); -if (!rc) - rc =llc_ui_wait_for_disc (sk,READ_ONCE (sk->sk_rcvtimeo)); -/* Wake up anyone sleeping in poll */ - sk->sk_state_change (sk); -out: -release_sock (sk); -return rc; -} - -/** -* llc_ui_connect - Connect to a remote llc2 mac + sap. -* @sock: Socket which will be connected to the remote destination. -* @uaddr: Remote and possibly the local address of the new connection. -* @addrlen: Size of uaddr structure. -* @flags: Operational flags specified by the user. -* -* Connect to a remote llc2 mac + sap. The caller must specify the -* destination mac and address to connect to. If the user hasn't previously -* called bind(2) with a smac the address of the first interface of the -* specified arp type will be used. -* This function will autobind if user did not previously call bind. -* Returns: 0 upon success, negative otherwise. -*/ -static int llc_ui_connect (struct socket *sock,struct sockaddr_unsized *uaddr, -int addrlen,int flags) -{ -struct sock *sk = sock->sk; -struct llc_sock *llc =llc_sk (sk); -struct sockaddr_llc *addr = (struct sockaddr_llc *)uaddr; -int rc = -EINVAL ; - -lock_sock (sk); -if (unlikely (addrlen !=sizeof (*addr))) - goto out; - rc = -EAFNOSUPPORT ; -if (unlikely (addr->sllc_family !=AF_LLC )) - goto out; -if (unlikely (sk->sk_type !=SOCK_STREAM )) - goto out; - rc = -EALREADY ; -if (unlikely (sock->state ==SS_CONNECTING )) - goto out; -/* bind connection to sap if user hasn't done it. */ -if (sock_flag (sk,SOCK_ZAPPED )) { -/* bind to sap with null dev, exclusive */ - rc =llc_ui_autobind (sock, addr); -if (rc) - goto out; - } - llc->daddr.lsap = addr->sllc_sap; -memcpy (llc->daddr.mac, addr->sllc_mac,IFHWADDRLEN ); - sock->state =SS_CONNECTING ; - sk->sk_state =TCP_SYN_SENT ; - llc->link =llc_ui_next_link_no (llc->sap->laddr.lsap); - rc =llc_establish_connection (sk, llc->dev->dev_addr, - addr->sllc_mac, addr->sllc_sap); -if (rc) { -dprintk ("%s: llc_ui_send_conn failed :-(\n" , __func__); - sock->state =SS_UNCONNECTED ; - sk->sk_state =TCP_CLOSE ; - goto out; - } - -if (sk->sk_state ==TCP_SYN_SENT ) { -const long timeo =sock_sndtimeo (sk, flags &O_NONBLOCK ); - -if (!timeo || !llc_ui_wait_for_conn (sk, timeo)) { - rc = -EINPROGRESS ; - goto out; - } - - rc =sock_intr_errno (timeo); -if (signal_pending (current)) - goto out; - } - -if (sk->sk_state ==TCP_CLOSE ) - goto sock_error; - - sock->state =SS_CONNECTED ; - rc =0 ; -out: -release_sock (sk); -return rc; -sock_error: - rc =sock_error (sk) ? : -ECONNABORTED ; - sock->state =SS_UNCONNECTED ; - goto out; -} - -/** -* llc_ui_listen - allow a normal socket to accept incoming connections -* @sock: Socket to allow incoming connections on. -* @backlog: Number of connections to queue. -* -* Allow a normal socket to accept incoming connections. -* Returns 0 upon success, negative otherwise. -*/ -static int llc_ui_listen (struct socket *sock,int backlog) -{ -struct sock *sk = sock->sk; -int rc = -EINVAL ; - -lock_sock (sk); -if (unlikely (sock->state !=SS_UNCONNECTED )) - goto out; - rc = -EOPNOTSUPP ; -if (unlikely (sk->sk_type !=SOCK_STREAM )) - goto out; - rc = -EAGAIN ; -if (sock_flag (sk,SOCK_ZAPPED )) - goto out; - rc =0 ; -if (!(unsigned int )backlog)/* BSDism */ - backlog =1 ; - sk->sk_max_ack_backlog = backlog; -if (sk->sk_state !=TCP_LISTEN ) { - sk->sk_ack_backlog =0 ; - sk->sk_state =TCP_LISTEN ; - } - sk->sk_socket->flags |= __SO_ACCEPTCON; -out: -release_sock (sk); -return rc; -} - -static int llc_ui_wait_for_disc (struct sock *sk,long timeout) -{ -DEFINE_WAIT_FUNC (wait, woken_wake_function); -int rc =0 ; - -add_wait_queue (sk_sleep (sk), &wait); -while (1 ) { -if (sk_wait_event (sk, &timeout, -READ_ONCE (sk->sk_state) ==TCP_CLOSE , &wait)) -break ; - rc = -ERESTARTSYS ; -if (signal_pending (current)) -break ; - rc = -EAGAIN ; -if (!timeout) -break ; - rc =0 ; - } -remove_wait_queue (sk_sleep (sk), &wait); -return rc; -} - -static bool llc_ui_wait_for_conn (struct sock *sk,long timeout) -{ -DEFINE_WAIT_FUNC (wait, woken_wake_function); - -add_wait_queue (sk_sleep (sk), &wait); -while (1 ) { -if (sk_wait_event (sk, &timeout, -READ_ONCE (sk->sk_state) !=TCP_SYN_SENT , &wait)) -break ; -if (signal_pending (current) || !timeout) -break ; - } -remove_wait_queue (sk_sleep (sk), &wait); -return timeout; -} - -static int llc_ui_wait_for_busy_core (struct sock *sk,long timeout) -{ -DEFINE_WAIT_FUNC (wait, woken_wake_function); -struct llc_sock *llc =llc_sk (sk); -int rc; - -add_wait_queue (sk_sleep (sk), &wait); -while (1 ) { - rc =0 ; -if (sk_wait_event (sk, &timeout, - (READ_ONCE (sk->sk_shutdown) &RCV_SHUTDOWN ) || - (!llc_data_accept_state (llc->state) && - !llc->remote_busy_flag && - !llc->p_flag), &wait)) -break ; - rc = -ERESTARTSYS ; -if (signal_pending (current)) -break ; - rc = -EAGAIN ; -if (!timeout) -break ; - } -remove_wait_queue (sk_sleep (sk), &wait); -return rc; -} - -static int llc_wait_data (struct sock *sk,long timeo) -{ -int rc; - -while (1 ) { -/* -* POSIX 1003.1g mandates this order. -*/ - rc =sock_error (sk); -if (rc) -break ; - rc =0 ; -if (sk->sk_shutdown &RCV_SHUTDOWN ) -break ; - rc = -EAGAIN ; -if (!timeo) -break ; - rc =sock_intr_errno (timeo); -if (signal_pending (current)) -break ; - rc =0 ; -if (sk_wait_data (sk, &timeo,NULL )) -break ; - } -return rc; -} - -static void llc_cmsg_rcv (struct msghdr *msg,struct sk_buff *skb) -{ -struct llc_sock *llc =llc_sk (skb->sk); - -if (llc->cmsg_flags &LLC_CMSG_PKTINFO ) { -struct llc_pktinfo info; - -memset (&info,0 ,sizeof (info)); - info.lpi_ifindex =llc_sk (skb->sk)->dev->ifindex; -llc_pdu_decode_dsap (skb, &info.lpi_sap); -llc_pdu_decode_da (skb, info.lpi_mac); -put_cmsg (msg,SOL_LLC ,LLC_OPT_PKTINFO ,sizeof (info), &info); - } -} - -/** -* llc_ui_accept - accept a new incoming connection. -* @sock: Socket which connections arrive on. -* @newsock: Socket to move incoming connection to. -* @arg: User specified arguments -* -* Accept a new incoming connection. -* Returns 0 upon success, negative otherwise. -*/ -static int llc_ui_accept (struct socket *sock,struct socket *newsock, -struct proto_accept_arg *arg) -{ -struct sock *sk = sock->sk, *newsk; -struct llc_sock *llc, *newllc; -struct sk_buff *skb; -int rc = -EOPNOTSUPP ; - -dprintk ("%s: accepting on %02X\n" , __func__, -llc_sk (sk)->laddr.lsap); -lock_sock (sk); -if (unlikely (sk->sk_type !=SOCK_STREAM )) - goto out; - rc = -EINVAL ; -if (unlikely (sock->state !=SS_UNCONNECTED || - sk->sk_state !=TCP_LISTEN )) - goto out; -/* wait for a connection to arrive. */ -if (skb_queue_empty (&sk->sk_receive_queue)) { - rc =llc_wait_data (sk,READ_ONCE (sk->sk_rcvtimeo)); -if (rc) - goto out; - } -dprintk ("%s: got a new connection on %02X\n" , __func__, -llc_sk (sk)->laddr.lsap); - skb =skb_dequeue (&sk->sk_receive_queue); - rc = -EINVAL ; -if (!skb->sk) - goto frees; - rc =0 ; - newsk = skb->sk; -/* attach connection to a new socket. */ -llc_ui_sk_init (newsock, newsk); -sock_reset_flag (newsk,SOCK_ZAPPED ); - newsk->sk_state =TCP_ESTABLISHED ; - newsock->state =SS_CONNECTED ; - llc =llc_sk (sk); - newllc =llc_sk (newsk); -memcpy (&newllc->addr, &llc->addr,sizeof (newllc->addr)); - newllc->link =llc_ui_next_link_no (newllc->laddr.lsap); - -/* put original socket back into a clean listen state. */ - sk->sk_state =TCP_LISTEN ; -sk_acceptq_removed (sk); -dprintk ("%s: ok success on %02X, client on %02X\n" , __func__, -llc_sk (sk)->addr.sllc_sap, newllc->daddr.lsap); -frees: -kfree_skb (skb); -out: -release_sock (sk); -return rc; -} - -/** -* llc_ui_recvmsg - copy received data to the socket user. -* @sock: Socket to copy data from. -* @msg: Various user space related information. -* @len: Size of user buffer. -* @flags: User specified flags. -* -* Copy received data to the socket user. -* Returns non-negative upon success, negative otherwise. -*/ -static int llc_ui_recvmsg (struct socket *sock,struct msghdr *msg,size_t len, -int flags) -{ - DECLARE_SOCKADDR(struct sockaddr_llc *, uaddr, msg->msg_name); -const int nonblock = flags &MSG_DONTWAIT ; -struct sk_buff *skb =NULL ; -struct sock *sk = sock->sk; -struct llc_sock *llc =llc_sk (sk); -size_t copied =0 ; -u32 peek_seq =0 ; -u32 *seq, skb_len; -unsigned long used; -int target;/* Read at least this many bytes */ -long timeo; - -lock_sock (sk); - copied = -ENOTCONN ; -if (unlikely (sk->sk_type ==SOCK_STREAM && sk->sk_state ==TCP_LISTEN )) - goto out; - - timeo =sock_rcvtimeo (sk, nonblock); - - seq = &llc->copied_seq; -if (flags &MSG_PEEK ) { - peek_seq = llc->copied_seq; - seq = &peek_seq; - } - - target =sock_rcvlowat (sk, flags &MSG_WAITALL , len); - copied =0 ; - -do { -u32 offset; - -/* -* We need to check signals first, to get correct SIGURG -* handling. FIXME: Need to check this doesn't impact 1003.1g -* and move it down to the bottom of the loop -*/ -if (signal_pending (current)) { -if (copied) -break ; - copied = timeo ?sock_intr_errno (timeo) : -EAGAIN ; -break ; - } - -/* Next get a buffer. */ - - skb =skb_peek (&sk->sk_receive_queue); -if (skb) { - offset = *seq; - goto found_ok_skb; - } -/* Well, if we have backlog, try to process it now yet. */ - -if (copied >= target && !READ_ONCE (sk->sk_backlog.tail)) -break ; - -if (copied) { -if (sk->sk_err || - sk->sk_state ==TCP_CLOSE || - (sk->sk_shutdown &RCV_SHUTDOWN ) || - !timeo || - (flags &MSG_PEEK )) -break ; - }else { -if (sock_flag (sk,SOCK_DONE )) -break ; - -if (sk->sk_err) { - copied =sock_error (sk); -break ; - } -if (sk->sk_shutdown &RCV_SHUTDOWN ) -break ; - -if (sk->sk_type ==SOCK_STREAM && sk->sk_state ==TCP_CLOSE ) { -if (!sock_flag (sk,SOCK_DONE )) { -/* -* This occurs when user tries to read -* from never connected socket. -*/ - copied = -ENOTCONN ; -break ; - } -break ; - } -if (!timeo) { - copied = -EAGAIN ; -break ; - } - } - -if (copied >= target) {/* Do not sleep, just process backlog. */ -release_sock (sk); -lock_sock (sk); - }else -sk_wait_data (sk, &timeo,NULL ); - -if ((flags &MSG_PEEK ) && peek_seq != llc->copied_seq) { -net_dbg_ratelimited ("LLC(%s:%d): Application bug, race in MSG_PEEK\n" , - current->comm, -task_pid_nr (current)); - peek_seq = llc->copied_seq; - } -continue ; - found_ok_skb: - skb_len = skb->len; -/* Ok so how much can we use? */ - used = skb->len - offset; -if (len < used) - used = len; - -if (!(flags &MSG_TRUNC )) { -int rc =skb_copy_datagram_msg (skb, offset, msg, used); -if (rc) { -/* Exception. Bailout! */ -if (!copied) - copied = -EFAULT ; -break ; - } - } - - *seq += used; - copied += used; - len -= used; - -/* For non stream protcols we get one packet per recvmsg call */ -if (sk->sk_type !=SOCK_STREAM ) - goto copy_uaddr; - -/* Partial read */ -if (used + offset < skb_len) -continue ; - -if (!(flags &MSG_PEEK )) { -skb_unlink (skb, &sk->sk_receive_queue); -kfree_skb (skb); - *seq =0 ; - } - }while (len >0 ); - -out: -release_sock (sk); -return copied; -copy_uaddr: -if (uaddr !=NULL && skb !=NULL ) { -memcpy (uaddr,llc_ui_skb_cb (skb),sizeof (*uaddr)); - msg->msg_namelen =sizeof (*uaddr); - } -if (llc_sk (sk)->cmsg_flags) -llc_cmsg_rcv (msg, skb); - -if (!(flags &MSG_PEEK )) { -skb_unlink (skb, &sk->sk_receive_queue); -kfree_skb (skb); - *seq =0 ; - } - - goto out; -} - -/** -* llc_ui_sendmsg - Transmit data provided by the socket user. -* @sock: Socket to transmit data from. -* @msg: Various user related information. -* @len: Length of data to transmit. -* -* Transmit data provided by the socket user. -* Returns non-negative upon success, negative otherwise. -*/ -static int llc_ui_sendmsg (struct socket *sock,struct msghdr *msg,size_t len) -{ - DECLARE_SOCKADDR(struct sockaddr_llc *, addr, msg->msg_name); -struct sock *sk = sock->sk; -struct llc_sock *llc =llc_sk (sk); -int flags = msg->msg_flags; -int noblock = flags &MSG_DONTWAIT ; -int rc = -EINVAL , copied =0 , hdrlen, hh_len; -struct sk_buff *skb =NULL ; -struct net_device *dev; -size_t size =0 ; - -dprintk ("%s: sending from %02X to %02X\n" , __func__, - llc->laddr.lsap, llc->daddr.lsap); -lock_sock (sk); -if (addr) { -if (msg->msg_namelen <sizeof (*addr)) - goto out; - }else { -if (llc_ui_addr_null (&llc->addr)) - goto out; - addr = &llc->addr; - } -/* must bind connection to sap if user hasn't done it. */ -if (sock_flag (sk,SOCK_ZAPPED )) { -/* bind to sap with null dev, exclusive. */ - rc =llc_ui_autobind (sock, addr); -if (rc) - goto out; - } - dev = llc->dev; - hh_len =LL_RESERVED_SPACE (dev); - hdrlen =llc_ui_header_len (sk, addr); - size = hdrlen + len; - size =min_t (size_t, size,READ_ONCE (dev->mtu)); - copied = size - hdrlen; - rc = -EINVAL ; -if (copied <0 ) - goto out; -release_sock (sk); - skb =sock_alloc_send_skb (sk, hh_len + size, noblock, &rc); -lock_sock (sk); -if (!skb) - goto out; -if (sock_flag (sk,SOCK_ZAPPED ) || - llc->dev != dev || - hdrlen !=llc_ui_header_len (sk, addr) || - hh_len !=LL_RESERVED_SPACE (dev) || - size >READ_ONCE (dev->mtu)) - goto out; - skb->dev = dev; - skb->protocol =llc_proto_type (addr->sllc_arphrd); -skb_reserve (skb, hh_len + hdrlen); - rc =memcpy_from_msg (skb_put (skb, copied), msg, copied); -if (rc) - goto out; -if (sk->sk_type ==SOCK_DGRAM || addr->sllc_ua) { -llc_build_and_send_ui_pkt (llc->sap, skb, addr->sllc_mac, - addr->sllc_sap); - skb =NULL ; - goto out; - } -if (addr->sllc_test) { -llc_build_and_send_test_pkt (llc->sap, skb, addr->sllc_mac, - addr->sllc_sap); - skb =NULL ; - goto out; - } -if (addr->sllc_xid) { -llc_build_and_send_xid_pkt (llc->sap, skb, addr->sllc_mac, - addr->sllc_sap); - skb =NULL ; - goto out; - } - rc = -ENOPROTOOPT ; -if (!(sk->sk_type ==SOCK_STREAM && !addr->sllc_ua)) - goto out; - rc =llc_ui_send_data (sk, skb, noblock); - skb =NULL ; -out: -kfree_skb (skb); -if (rc) -dprintk ("%s: failed sending from %02X to %02X: %d\n" , - __func__, llc->laddr.lsap, llc->daddr.lsap, rc); -release_sock (sk); -return rc ? : copied; -} - -/** -* llc_ui_getname - return the address info of a socket -* @sock: Socket to get address of. -* @uaddr: Address structure to return information. -* @peer: Does user want local or remote address information. -* -* Return the address information of a socket. -*/ -static int llc_ui_getname (struct socket *sock,struct sockaddr *uaddr, -int peer) -{ -struct sockaddr_llc sllc; -struct sock *sk = sock->sk; -struct llc_sock *llc =llc_sk (sk); -int rc = -EBADF ; - -memset (&sllc,0 ,sizeof (sllc)); -lock_sock (sk); -if (sock_flag (sk,SOCK_ZAPPED )) - goto out; -if (peer) { - rc = -ENOTCONN ; -if (sk->sk_state !=TCP_ESTABLISHED ) - goto out; -if (llc->dev) - sllc.sllc_arphrd = llc->dev->type; - sllc.sllc_sap = llc->daddr.lsap; -memcpy (&sllc.sllc_mac, &llc->daddr.mac,IFHWADDRLEN ); - }else { - rc = -EINVAL ; -if (!llc->sap) - goto out; - sllc.sllc_sap = llc->sap->laddr.lsap; - -if (llc->dev) { - sllc.sllc_arphrd = llc->dev->type; -memcpy (&sllc.sllc_mac, llc->dev->dev_addr, -IFHWADDRLEN ); - } - } - sllc.sllc_family =AF_LLC ; -memcpy (uaddr, &sllc,sizeof (sllc)); - rc =sizeof (sllc); -out: -release_sock (sk); -return rc; -} - -/** -* llc_ui_ioctl - io controls for PF_LLC -* @sock: Socket to get/set info -* @cmd: command -* @arg: optional argument for cmd -* -* get/set info on llc sockets -*/ -static int llc_ui_ioctl (struct socket *sock,unsigned int cmd, -unsigned long arg) -{ -return -ENOIOCTLCMD ; -} - -/** -* llc_ui_setsockopt - set various connection specific parameters. -* @sock: Socket to set options on. -* @level: Socket level user is requesting operations on. -* @optname: Operation name. -* @optval: User provided operation data. -* @optlen: Length of optval. -* -* Set various connection specific parameters. -*/ -static int llc_ui_setsockopt (struct socket *sock,int level,int optname, -sockptr_t optval,unsigned int optlen) -{ -struct sock *sk = sock->sk; -struct llc_sock *llc =llc_sk (sk); -unsigned int opt; -int rc = -EINVAL ; - -lock_sock (sk); -if (unlikely (level !=SOL_LLC || optlen !=sizeof (int ))) - goto out; - rc =copy_safe_from_sockptr (&opt,sizeof (opt), optval, optlen); -if (rc) - goto out; - rc = -EINVAL ; -switch (optname) { -case LLC_OPT_RETRY : -if (opt >LLC_OPT_MAX_RETRY ) - goto out; - llc->n2 = opt; -break ; -case LLC_OPT_SIZE : -if (opt >LLC_OPT_MAX_SIZE ) - goto out; - llc->n1 = opt; -break ; -case LLC_OPT_ACK_TMR_EXP : -if (opt >LLC_OPT_MAX_ACK_TMR_EXP ) - goto out; - llc->ack_timer.expire = opt *HZ ; -break ; -case LLC_OPT_P_TMR_EXP : -if (opt >LLC_OPT_MAX_P_TMR_EXP ) - goto out; - llc->pf_cycle_timer.expire = opt *HZ ; -break ; -case LLC_OPT_REJ_TMR_EXP : -if (opt >LLC_OPT_MAX_REJ_TMR_EXP ) - goto out; - llc->rej_sent_timer.expire = opt *HZ ; -break ; -case LLC_OPT_BUSY_TMR_EXP : -if (opt >LLC_OPT_MAX_BUSY_TMR_EXP ) - goto out; - llc->busy_state_timer.expire = opt *HZ ; -break ; -case LLC_OPT_TX_WIN : -if (opt >LLC_OPT_MAX_WIN ) - goto out; - llc->k = opt; -break ; -case LLC_OPT_RX_WIN : -if (opt >LLC_OPT_MAX_WIN ) - goto out; - llc->rw = opt; -break ; -case LLC_OPT_PKTINFO : -if (opt) - llc->cmsg_flags |=LLC_CMSG_PKTINFO ; -else - llc->cmsg_flags &= ~LLC_CMSG_PKTINFO ; -break ; -default : - rc = -ENOPROTOOPT ; - goto out; - } - rc =0 ; -out: -release_sock (sk); -return rc; -} - -/** -* llc_ui_getsockopt - get connection specific socket info -* @sock: Socket to get information from. -* @level: Socket level user is requesting operations on. -* @optname: Operation name. -* @opt: sockopt context with iterator and length for returning data. -* -* Get connection specific socket information. -*/ -static int llc_ui_getsockopt (struct socket *sock,int level,int optname, -sockopt_t *opt) -{ -struct sock *sk = sock->sk; -struct llc_sock *llc =llc_sk (sk); -int val =0 , len, rc = -EINVAL ; - -lock_sock (sk); -if (unlikely (level !=SOL_LLC )) - goto out; - len = opt->optlen; -if (len !=sizeof (int )) - goto out; -switch (optname) { -case LLC_OPT_RETRY : - val = llc->n2;break ; -case LLC_OPT_SIZE : - val = llc->n1;break ; -case LLC_OPT_ACK_TMR_EXP : - val = llc->ack_timer.expire /HZ ;break ; -case LLC_OPT_P_TMR_EXP : - val = llc->pf_cycle_timer.expire /HZ ;break ; -case LLC_OPT_REJ_TMR_EXP : - val = llc->rej_sent_timer.expire /HZ ;break ; -case LLC_OPT_BUSY_TMR_EXP : - val = llc->busy_state_timer.expire /HZ ;break ; -case LLC_OPT_TX_WIN : - val = llc->k;break ; -case LLC_OPT_RX_WIN : - val = llc->rw;break ; -case LLC_OPT_PKTINFO : - val = (llc->cmsg_flags &LLC_CMSG_PKTINFO ) !=0 ; -break ; -default : - rc = -ENOPROTOOPT ; - goto out; - } - rc =0 ; - opt->optlen = len; -if (copy_to_iter (&val, len, &opt->iter_out) != len) - rc = -EFAULT ; -out: -release_sock (sk); -return rc; -} - -static const struct net_proto_family llc_ui_family_ops = { - .family =PF_LLC , - .create = llc_ui_create, - .owner =THIS_MODULE , -}; - -static const struct proto_ops llc_ui_ops = { - .family =PF_LLC , - .owner =THIS_MODULE , - .release = llc_ui_release, - .bind = llc_ui_bind, - .connect = llc_ui_connect, - .socketpair = sock_no_socketpair, - .accept = llc_ui_accept, - .getname = llc_ui_getname, - .poll = datagram_poll, - .ioctl = llc_ui_ioctl, - .listen = llc_ui_listen, - .shutdown = llc_ui_shutdown, - .setsockopt = llc_ui_setsockopt, - .getsockopt_iter = llc_ui_getsockopt, - .sendmsg = llc_ui_sendmsg, - .recvmsg = llc_ui_recvmsg, - .mmap = sock_no_mmap, -}; - -static const char llc_proc_err_msg[]__initconst = -KERN_CRIT "LLC: Unable to register the proc_fs entries\n" ; -static const char llc_sysctl_err_msg[]__initconst = -KERN_CRIT "LLC: Unable to register the sysctl entries\n" ; -static const char llc_sock_err_msg[]__initconst = -KERN_CRIT "LLC: Unable to register the network family\n" ; - -static int __init llc2_init (void ) -{ -int rc =proto_register (&llc_proto,0 ); - -if (rc !=0 ) - goto out; - -llc_build_offset_table (); -llc_station_init (); - llc_ui_sap_last_autoport =LLC_SAP_DYN_START ; - rc =llc_proc_init (); -if (rc !=0 ) { -printk (llc_proc_err_msg); - goto out_station; - } - rc =llc_sysctl_init (); -if (rc) { -printk (llc_sysctl_err_msg); - goto out_proc; - } - rc =sock_register (&llc_ui_family_ops); -if (rc) { -printk (llc_sock_err_msg); - goto out_sysctl; - } -llc_add_pack (LLC_DEST_SAP , llc_sap_handler); -llc_add_pack (LLC_DEST_CONN , llc_conn_handler); -out: -return rc; -out_sysctl: -llc_sysctl_exit (); -out_proc: -llc_proc_exit (); -out_station: -llc_station_exit (); -proto_unregister (&llc_proto); - goto out; -} - -static void __exit llc2_exit(void) -{ -llc_station_exit (); -llc_remove_pack (LLC_DEST_SAP ); -llc_remove_pack (LLC_DEST_CONN ); -sock_unregister (PF_LLC ); -llc_proc_exit (); -llc_sysctl_exit (); -proto_unregister (&llc_proto); -} - -module_init (llc2_init); -module_exit (llc2_exit); - -MODULE_LICENSE ("GPL" ); -MODULE_AUTHOR ("Procom 1997, Jay Schullist 2001, Arnaldo C. Melo 2001-2003" ); -MODULE_DESCRIPTION ("IEEE 802.2 PF_LLC support" ); -MODULE_ALIAS_NETPROTO (PF_LLC );net/llc/llc_c_ac.c deleted +0
-1448@@ -1,1448 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* -* llc_c_ac.c - actions performed during connection state transition. -* -* Description: -* Functions in this module are implementation of connection component actions -* Details of actions can be found in IEEE-802.2 standard document. -* All functions have one connection and one event as input argument. All of -* them return 0 On success and 1 otherwise. -* -* Copyright (c) 1997 by Procom Technology, Inc. -* 2001-2003 by Arnaldo Carvalho de Melo <[email protected]> -*/ -#include <linux/netdevice.h> -#include <linux/slab.h> -#include <net/llc_conn.h> -#include <net/llc_sap.h> -#include <net/sock.h> -#include <net/llc_c_ev.h> -#include <net/llc_c_ac.h> -#include <net/llc_c_st.h> -#include <net/llc_pdu.h> -#include <net/llc.h> - - -static int llc_conn_ac_inc_vs_by_1 (struct sock *sk,struct sk_buff *skb); -static void llc_process_tmr_ev (struct sock *sk,struct sk_buff *skb); -static int llc_conn_ac_data_confirm (struct sock *sk,struct sk_buff *ev); - -static int llc_conn_ac_inc_npta_value (struct sock *sk,struct sk_buff *skb); - -static int llc_conn_ac_send_rr_rsp_f_set_ackpf (struct sock *sk, -struct sk_buff *skb); - -static int llc_conn_ac_set_p_flag_1 (struct sock *sk,struct sk_buff *skb); - -#define INCORRECT 0 - -int llc_conn_ac_clear_remote_busy (struct sock *sk,struct sk_buff *skb) -{ -struct llc_sock *llc =llc_sk (sk); - -if (llc->remote_busy_flag) { -u8 nr; -struct llc_pdu_sn *pdu =llc_pdu_sn_hdr (skb); - - llc->remote_busy_flag =0 ; -timer_delete (&llc->busy_state_timer.timer); - nr =LLC_I_GET_NR (pdu); -llc_conn_resend_i_pdu_as_cmd (sk, nr,0 ); - } -return 0 ; -} - -int llc_conn_ac_conn_ind (struct sock *sk,struct sk_buff *skb) -{ -struct llc_conn_state_ev *ev =llc_conn_ev (skb); - - ev->ind_prim =LLC_CONN_PRIM ; -return 0 ; -} - -int llc_conn_ac_conn_confirm (struct sock *sk,struct sk_buff *skb) -{ -struct llc_conn_state_ev *ev =llc_conn_ev (skb); - - ev->cfm_prim =LLC_CONN_PRIM ; -return 0 ; -} - -static int llc_conn_ac_data_confirm (struct sock *sk,struct sk_buff *skb) -{ -struct llc_conn_state_ev *ev =llc_conn_ev (skb); - - ev->cfm_prim =LLC_DATA_PRIM ; -return 0 ; -} - -int llc_conn_ac_data_ind (struct sock *sk,struct sk_buff *skb) -{ -llc_conn_rtn_pdu (sk, skb); -return 0 ; -} - -int llc_conn_ac_disc_ind (struct sock *sk,struct sk_buff *skb) -{ -struct llc_conn_state_ev *ev =llc_conn_ev (skb); -u8 reason =0 ; -int rc =0 ; - -if (ev->type ==LLC_CONN_EV_TYPE_PDU ) { -struct llc_pdu_un *pdu =llc_pdu_un_hdr (skb); - -if (LLC_PDU_IS_RSP (pdu) && -LLC_PDU_TYPE_IS_U (pdu) && -LLC_U_PDU_RSP (pdu) ==LLC_2_PDU_RSP_DM ) - reason =LLC_DISC_REASON_RX_DM_RSP_PDU ; -else if (LLC_PDU_IS_CMD (pdu) && -LLC_PDU_TYPE_IS_U (pdu) && -LLC_U_PDU_CMD (pdu) ==LLC_2_PDU_CMD_DISC ) - reason =LLC_DISC_REASON_RX_DISC_CMD_PDU ; - }else if (ev->type ==LLC_CONN_EV_TYPE_ACK_TMR ) - reason =LLC_DISC_REASON_ACK_TMR_EXP ; -else - rc = -EINVAL ; -if (!rc) { - ev->reason = reason; - ev->ind_prim =LLC_DISC_PRIM ; - } -return rc; -} - -int llc_conn_ac_disc_confirm (struct sock *sk,struct sk_buff *skb) -{ -struct llc_conn_state_ev *ev =llc_conn_ev (skb); - - ev->reason = ev->status; - ev->cfm_prim =LLC_DISC_PRIM ; -return 0 ; -} - -int llc_conn_ac_rst_ind (struct sock *sk,struct sk_buff *skb) -{ -u8 reason =0 ; -int rc =1 ; -struct llc_conn_state_ev *ev =llc_conn_ev (skb); -struct llc_pdu_un *pdu =llc_pdu_un_hdr (skb); -struct llc_sock *llc =llc_sk (sk); - -switch (ev->type) { -case LLC_CONN_EV_TYPE_PDU : -if (LLC_PDU_IS_RSP (pdu) && -LLC_PDU_TYPE_IS_U (pdu) && -LLC_U_PDU_RSP (pdu) ==LLC_2_PDU_RSP_FRMR ) { - reason =LLC_RESET_REASON_LOCAL ; - rc =0 ; - }else if (LLC_PDU_IS_CMD (pdu) && -LLC_PDU_TYPE_IS_U (pdu) && -LLC_U_PDU_CMD (pdu) ==LLC_2_PDU_CMD_SABME ) { - reason =LLC_RESET_REASON_REMOTE ; - rc =0 ; - } -break ; -case LLC_CONN_EV_TYPE_ACK_TMR : -case LLC_CONN_EV_TYPE_P_TMR : -case LLC_CONN_EV_TYPE_REJ_TMR : -case LLC_CONN_EV_TYPE_BUSY_TMR : -if (llc->retry_count > llc->n2) { - reason =LLC_RESET_REASON_LOCAL ; - rc =0 ; - } -break ; - } -if (!rc) { - ev->reason = reason; - ev->ind_prim =LLC_RESET_PRIM ; - } -return rc; -} - -int llc_conn_ac_rst_confirm (struct sock *sk,struct sk_buff *skb) -{ -struct llc_conn_state_ev *ev =llc_conn_ev (skb); - - ev->reason =0 ; - ev->cfm_prim =LLC_RESET_PRIM ; -return 0 ; -} - -int llc_conn_ac_clear_remote_busy_if_f_eq_1 (struct sock *sk, -struct sk_buff *skb) -{ -struct llc_pdu_sn *pdu =llc_pdu_sn_hdr (skb); - -if (LLC_PDU_IS_RSP (pdu) && -LLC_PDU_TYPE_IS_I (pdu) && -LLC_I_PF_IS_1 (pdu) &&llc_sk (sk)->ack_pf) -llc_conn_ac_clear_remote_busy (sk, skb); -return 0 ; -} - -int llc_conn_ac_stop_rej_tmr_if_data_flag_eq_2 (struct sock *sk, -struct sk_buff *skb) -{ -struct llc_sock *llc =llc_sk (sk); - -if (llc->data_flag ==2 ) -timer_delete (&llc->rej_sent_timer.timer); -return 0 ; -} - -int llc_conn_ac_send_disc_cmd_p_set_x (struct sock *sk,struct sk_buff *skb) -{ -int rc = -ENOBUFS ; -struct llc_sock *llc =llc_sk (sk); -struct sk_buff *nskb =llc_alloc_frame (sk, llc->dev,LLC_PDU_TYPE_U ,0 ); - -if (nskb) { -struct llc_sap *sap = llc->sap; - -llc_pdu_header_init (nskb,LLC_PDU_TYPE_U , sap->laddr.lsap, - llc->daddr.lsap,LLC_PDU_CMD ); -llc_pdu_init_as_disc_cmd (nskb,1 ); - rc =llc_mac_hdr_init (nskb, llc->dev->dev_addr, llc->daddr.mac); -if (unlikely (rc)) - goto free; -llc_conn_send_pdu (sk, nskb); -llc_conn_ac_set_p_flag_1 (sk, skb); - } -out: -return rc; -free: -kfree_skb (nskb); - goto out; -} - -int llc_conn_ac_send_dm_rsp_f_set_p (struct sock *sk,struct sk_buff *skb) -{ -int rc = -ENOBUFS ; -struct llc_sock *llc =llc_sk (sk); -struct sk_buff *nskb =llc_alloc_frame (sk, llc->dev,LLC_PDU_TYPE_U ,0 ); - -if (nskb) { -struct llc_sap *sap = llc->sap; -u8 f_bit; - -llc_pdu_decode_pf_bit (skb, &f_bit); -llc_pdu_header_init (nskb,LLC_PDU_TYPE_U , sap->laddr.lsap, - llc->daddr.lsap,LLC_PDU_RSP ); -llc_pdu_init_as_dm_rsp (nskb, f_bit); - rc =llc_mac_hdr_init (nskb, llc->dev->dev_addr, llc->daddr.mac); -if (unlikely (rc)) - goto free; -llc_conn_send_pdu (sk, nskb); - } -out: -return rc; -free: -kfree_skb (nskb); - goto out; -} - -int llc_conn_ac_send_dm_rsp_f_set_1 (struct sock *sk,struct sk_buff *skb) -{ -int rc = -ENOBUFS ; -struct llc_sock *llc =llc_sk (sk); -struct sk_buff *nskb =llc_alloc_frame (sk, llc->dev,LLC_PDU_TYPE_U ,0 ); - -if (nskb) { -struct llc_sap *sap = llc->sap; - -llc_pdu_header_init (nskb,LLC_PDU_TYPE_U , sap->laddr.lsap, - llc->daddr.lsap,LLC_PDU_RSP ); -llc_pdu_init_as_dm_rsp (nskb,1 ); - rc =llc_mac_hdr_init (nskb, llc->dev->dev_addr, llc->daddr.mac); -if (unlikely (rc)) - goto free; -llc_conn_send_pdu (sk, nskb); - } -out: -return rc; -free: -kfree_skb (nskb); - goto out; -} - -int llc_conn_ac_send_frmr_rsp_f_set_x (struct sock *sk,struct sk_buff *skb) -{ -u8 f_bit; -int rc = -ENOBUFS ; -struct sk_buff *nskb; -struct llc_pdu_sn *pdu =llc_pdu_sn_hdr (skb); -struct llc_sock *llc =llc_sk (sk); - - llc->rx_pdu_hdr = *((u32 *)pdu); -if (LLC_PDU_IS_CMD (pdu)) -llc_pdu_decode_pf_bit (skb, &f_bit); -else - f_bit =0 ; - nskb =llc_alloc_frame (sk, llc->dev,LLC_PDU_TYPE_U , -sizeof (struct llc_frmr_info )); -if (nskb) { -struct llc_sap *sap = llc->sap; - -llc_pdu_header_init (nskb,LLC_PDU_TYPE_U , sap->laddr.lsap, - llc->daddr.lsap,LLC_PDU_RSP ); -llc_pdu_init_as_frmr_rsp (nskb, pdu, f_bit, llc->vS, - llc->vR,INCORRECT ); - rc =llc_mac_hdr_init (nskb, llc->dev->dev_addr, llc->daddr.mac); -if (unlikely (rc)) - goto free; -llc_conn_send_pdu (sk, nskb); - } -out: -return rc; -free: -kfree_skb (nskb); - goto out; -} - -int llc_conn_ac_resend_frmr_rsp_f_set_0 (struct sock *sk,struct sk_buff *skb) -{ -int rc = -ENOBUFS ; -struct llc_sock *llc =llc_sk (sk); -struct sk_buff *nskb =llc_alloc_frame (sk, llc->dev,LLC_PDU_TYPE_U , -sizeof (struct llc_frmr_info )); - -if (nskb) { -struct llc_sap *sap = llc->sap; -struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)&llc->rx_pdu_hdr; - -llc_pdu_header_init (nskb,LLC_PDU_TYPE_U , sap->laddr.lsap, - llc->daddr.lsap,LLC_PDU_RSP ); -llc_pdu_init_as_frmr_rsp (nskb, pdu,0 , llc->vS, - llc->vR,INCORRECT ); - rc =llc_mac_hdr_init (nskb, llc->dev->dev_addr, llc->daddr.mac); -if (unlikely (rc)) - goto free; -llc_conn_send_pdu (sk, nskb); - } -out: -return rc; -free: -kfree_skb (nskb); - goto out; -} - -int llc_conn_ac_resend_frmr_rsp_f_set_p (struct sock *sk,struct sk_buff *skb) -{ -u8 f_bit; -int rc = -ENOBUFS ; -struct sk_buff *nskb; -struct llc_sock *llc =llc_sk (sk); - -llc_pdu_decode_pf_bit (skb, &f_bit); - nskb =llc_alloc_frame (sk, llc->dev,LLC_PDU_TYPE_U , -sizeof (struct llc_frmr_info )); -if (nskb) { -struct llc_sap *sap = llc->sap; -struct llc_pdu_sn *pdu =llc_pdu_sn_hdr (skb); - -llc_pdu_header_init (nskb,LLC_PDU_TYPE_U , sap->laddr.lsap, - llc->daddr.lsap,LLC_PDU_RSP ); -llc_pdu_init_as_frmr_rsp (nskb, pdu, f_bit, llc->vS, - llc->vR,INCORRECT ); - rc =llc_mac_hdr_init (nskb, llc->dev->dev_addr, llc->daddr.mac); -if (unlikely (rc)) - goto free; -llc_conn_send_pdu (sk, nskb); - } -out: -return rc; -free: -kfree_skb (nskb); - goto out; -} - -int llc_conn_ac_send_i_cmd_p_set_1 (struct sock *sk,struct sk_buff *skb) -{ -int rc; -struct llc_sock *llc =llc_sk (sk); -struct llc_sap *sap = llc->sap; - -llc_pdu_header_init (skb,LLC_PDU_TYPE_I , sap->laddr.lsap, - llc->daddr.lsap,LLC_PDU_CMD ); -llc_pdu_init_as_i_cmd (skb,1 , llc->vS, llc->vR); - rc =llc_mac_hdr_init (skb, llc->dev->dev_addr, llc->daddr.mac); -if (likely (!rc)) { -skb_get (skb); -llc_conn_send_pdu (sk, skb); -llc_conn_ac_inc_vs_by_1 (sk, skb); - } -return rc; -} - -static int llc_conn_ac_send_i_cmd_p_set_0 (struct sock *sk,struct sk_buff *skb) -{ -int rc; -struct llc_sock *llc =llc_sk (sk); -struct llc_sap *sap = llc->sap; - -llc_pdu_header_init (skb,LLC_PDU_TYPE_I , sap->laddr.lsap, - llc->daddr.lsap,LLC_PDU_CMD ); -llc_pdu_init_as_i_cmd (skb,0 , llc->vS, llc->vR); - rc =llc_mac_hdr_init (skb, llc->dev->dev_addr, llc->daddr.mac); -if (likely (!rc)) { -skb_get (skb); -llc_conn_send_pdu (sk, skb); -llc_conn_ac_inc_vs_by_1 (sk, skb); - } -return rc; -} - -int llc_conn_ac_send_i_xxx_x_set_0 (struct sock *sk,struct sk_buff *skb) -{ -int rc; -struct llc_sock *llc =llc_sk (sk); -struct llc_sap *sap = llc->sap; - -llc_pdu_header_init (skb,LLC_PDU_TYPE_I , sap->laddr.lsap, - llc->daddr.lsap,LLC_PDU_CMD ); -llc_pdu_init_as_i_cmd (skb,0 , llc->vS, llc->vR); - rc =llc_mac_hdr_init (skb, llc->dev->dev_addr, llc->daddr.mac); -if (likely (!rc)) { -skb_get (skb); -llc_conn_send_pdu (sk, skb); -llc_conn_ac_inc_vs_by_1 (sk, skb); - } -return 0 ; -} - -int llc_conn_ac_resend_i_xxx_x_set_0 (struct sock *sk,struct sk_buff *skb) -{ -struct llc_pdu_sn *pdu =llc_pdu_sn_hdr (skb); -u8 nr =LLC_I_GET_NR (pdu); - -llc_conn_resend_i_pdu_as_cmd (sk, nr,0 ); -return 0 ; -} - -int llc_conn_ac_resend_i_xxx_x_set_0_or_send_rr (struct sock *sk, -struct sk_buff *skb) -{ -u8 nr; -struct llc_pdu_sn *pdu =llc_pdu_sn_hdr (skb); -int rc = -ENOBUFS ; -struct llc_sock *llc =llc_sk (sk); -struct sk_buff *nskb =llc_alloc_frame (sk, llc->dev,LLC_PDU_TYPE_U ,0 ); - -if (nskb) { -struct llc_sap *sap = llc->sap; - -llc_pdu_header_init (nskb,LLC_PDU_TYPE_U , sap->laddr.lsap, - llc->daddr.lsap,LLC_PDU_RSP ); -llc_pdu_init_as_rr_rsp (nskb,0 , llc->vR); - rc =llc_mac_hdr_init (nskb, llc->dev->dev_addr, llc->daddr.mac); -if (likely (!rc)) -llc_conn_send_pdu (sk, nskb); -else -kfree_skb (nskb); - } -if (rc) { - nr =LLC_I_GET_NR (pdu); - rc =0 ; -llc_conn_resend_i_pdu_as_cmd (sk, nr,0 ); - } -return rc; -} - -int llc_conn_ac_resend_i_rsp_f_set_1 (struct sock *sk,struct sk_buff *skb) -{ -struct llc_pdu_sn *pdu =llc_pdu_sn_hdr (skb); -u8 nr =LLC_I_GET_NR (pdu); - -llc_conn_resend_i_pdu_as_rsp (sk, nr,1 ); -return 0 ; -} - -int llc_conn_ac_send_rej_cmd_p_set_1 (struct sock *sk,struct sk_buff *skb) -{ -int rc = -ENOBUFS ; -struct llc_sock *llc =llc_sk (sk); -struct sk_buff *nskb =llc_alloc_frame (sk, llc->dev,LLC_PDU_TYPE_S ,0 ); - -if (nskb) { -struct llc_sap *sap = llc->sap; - -llc_pdu_header_init (nskb,LLC_PDU_TYPE_S , sap->laddr.lsap, - llc->daddr.lsap,LLC_PDU_CMD ); -llc_pdu_init_as_rej_cmd (nskb,1 , llc->vR); - rc =llc_mac_hdr_init (nskb, llc->dev->dev_addr, llc->daddr.mac); -if (unlikely (rc)) - goto free; -llc_conn_send_pdu (sk, nskb); - } -out: -return rc; -free: -kfree_skb (nskb); - goto out; -} - -int llc_conn_ac_send_rej_rsp_f_set_1 (struct sock *sk,struct sk_buff *skb) -{ -int rc = -ENOBUFS ; -struct llc_sock *llc =llc_sk (sk); -struct sk_buff *nskb =llc_alloc_frame (sk, llc->dev,LLC_PDU_TYPE_S ,0 ); - -if (nskb) { -struct llc_sap *sap = llc->sap; - -llc_pdu_header_init (nskb,LLC_PDU_TYPE_S , sap->laddr.lsap, - llc->daddr.lsap,LLC_PDU_RSP ); -llc_pdu_init_as_rej_rsp (nskb,1 , llc->vR); - rc =llc_mac_hdr_init (nskb, llc->dev->dev_addr, llc->daddr.mac); -if (unlikely (rc)) - goto free; -llc_conn_send_pdu (sk, nskb); - } -out: -return rc; -free: -kfree_skb (nskb); - goto out; -} - -int llc_conn_ac_send_rej_xxx_x_set_0 (struct sock *sk,struct sk_buff *skb) -{ -int rc = -ENOBUFS ; -struct llc_sock *llc =llc_sk (sk); -struct sk_buff *nskb =llc_alloc_frame (sk, llc->dev,LLC_PDU_TYPE_S ,0 ); - -if (nskb) { -struct llc_sap *sap = llc->sap; - -llc_pdu_header_init (nskb,LLC_PDU_TYPE_S , sap->laddr.lsap, - llc->daddr.lsap,LLC_PDU_RSP ); -llc_pdu_init_as_rej_rsp (nskb,0 , llc->vR); - rc =llc_mac_hdr_init (nskb, llc->dev->dev_addr, llc->daddr.mac); -if (unlikely (rc)) - goto free; -llc_conn_send_pdu (sk, nskb); - } -out: -return rc; -free: -kfree_skb (nskb); - goto out; -} - -int llc_conn_ac_send_rnr_cmd_p_set_1 (struct sock *sk,struct sk_buff *skb) -{ -int rc = -ENOBUFS ; -struct llc_sock *llc =llc_sk (sk); -struct sk_buff *nskb =llc_alloc_frame (sk, llc->dev,LLC_PDU_TYPE_S ,0 ); - -if (nskb) { -struct llc_sap *sap = llc->sap; - -llc_pdu_header_init (nskb,LLC_PDU_TYPE_S , sap->laddr.lsap, - llc->daddr.lsap,LLC_PDU_CMD ); -llc_pdu_init_as_rnr_cmd (nskb,1 , llc->vR); - rc =llc_mac_hdr_init (nskb, llc->dev->dev_addr, llc->daddr.mac); -if (unlikely (rc)) - goto free; -llc_conn_send_pdu (sk, nskb); - } -out: -return rc; -free: -kfree_skb (nskb); - goto out; -} - -int llc_conn_ac_send_rnr_rsp_f_set_1 (struct sock *sk,struct sk_buff *skb) -{ -int rc = -ENOBUFS ; -struct llc_sock *llc =llc_sk (sk); -struct sk_buff *nskb =llc_alloc_frame (sk, llc->dev,LLC_PDU_TYPE_S ,0 ); - -if (nskb) { -struct llc_sap *sap = llc->sap; - -llc_pdu_header_init (nskb,LLC_PDU_TYPE_S , sap->laddr.lsap, - llc->daddr.lsap,LLC_PDU_RSP ); -llc_pdu_init_as_rnr_rsp (nskb,1 , llc->vR); - rc =llc_mac_hdr_init (nskb, llc->dev->dev_addr, llc->daddr.mac); -if (unlikely (rc)) - goto free; -llc_conn_send_pdu (sk, nskb); - } -out: -return rc; -free: -kfree_skb (nskb); - goto out; -} - -int llc_conn_ac_send_rnr_xxx_x_set_0 (struct sock *sk,struct sk_buff *skb) -{ -int rc = -ENOBUFS ; -struct llc_sock *llc =llc_sk (sk); -struct sk_buff *nskb =llc_alloc_frame (sk, llc->dev,LLC_PDU_TYPE_S ,0 ); - -if (nskb) { -struct llc_sap *sap = llc->sap; - -llc_pdu_header_init (nskb,LLC_PDU_TYPE_S , sap->laddr.lsap, - llc->daddr.lsap,LLC_PDU_RSP ); -llc_pdu_init_as_rnr_rsp (nskb,0 , llc->vR); - rc =llc_mac_hdr_init (nskb, llc->dev->dev_addr, llc->daddr.mac); -if (unlikely (rc)) - goto free; -llc_conn_send_pdu (sk, nskb); - } -out: -return rc; -free: -kfree_skb (nskb); - goto out; -} - -int llc_conn_ac_set_remote_busy (struct sock *sk,struct sk_buff *skb) -{ -struct llc_sock *llc =llc_sk (sk); - -if (!llc->remote_busy_flag) { - llc->remote_busy_flag =1 ; -mod_timer (&llc->busy_state_timer.timer, - jiffies + llc->busy_state_timer.expire); - } -return 0 ; -} - -int llc_conn_ac_opt_send_rnr_xxx_x_set_0 (struct sock *sk,struct sk_buff *skb) -{ -int rc = -ENOBUFS ; -struct llc_sock *llc =llc_sk (sk); -struct sk_buff *nskb =llc_alloc_frame (sk, llc->dev,LLC_PDU_TYPE_S ,0 ); - -if (nskb) { -struct llc_sap *sap = llc->sap; - -llc_pdu_header_init (nskb,LLC_PDU_TYPE_S , sap->laddr.lsap, - llc->daddr.lsap,LLC_PDU_RSP ); -llc_pdu_init_as_rnr_rsp (nskb,0 , llc->vR); - rc =llc_mac_hdr_init (nskb, llc->dev->dev_addr, llc->daddr.mac); -if (unlikely (rc)) - goto free; -llc_conn_send_pdu (sk, nskb); - } -out: -return rc; -free: -kfree_skb (nskb); - goto out; -} - -int llc_conn_ac_send_rr_cmd_p_set_1 (struct sock *sk,struct sk_buff *skb) -{ -int rc = -ENOBUFS ; -struct llc_sock *llc =llc_sk (sk); -struct sk_buff *nskb =llc_alloc_frame (sk, llc->dev,LLC_PDU_TYPE_S ,0 ); - -if (nskb) { -struct llc_sap *sap = llc->sap; - -llc_pdu_header_init (nskb,LLC_PDU_TYPE_S , sap->laddr.lsap, - llc->daddr.lsap,LLC_PDU_CMD ); -llc_pdu_init_as_rr_cmd (nskb,1 , llc->vR); - rc =llc_mac_hdr_init (nskb, llc->dev->dev_addr, llc->daddr.mac); -if (unlikely (rc)) - goto free; -llc_conn_send_pdu (sk, nskb); - } -out: -return rc; -free: -kfree_skb (nskb); - goto out; -} - -int llc_conn_ac_send_rr_rsp_f_set_1 (struct sock *sk,struct sk_buff *skb) -{ -int rc = -ENOBUFS ; -struct llc_sock *llc =llc_sk (sk); -struct sk_buff *nskb =llc_alloc_frame (sk, llc->dev,LLC_PDU_TYPE_S ,0 ); - -if (nskb) { -struct llc_sap *sap = llc->sap; -u8 f_bit =1 ; - -llc_pdu_header_init (nskb,LLC_PDU_TYPE_S , sap->laddr.lsap, - llc->daddr.lsap,LLC_PDU_RSP ); -llc_pdu_init_as_rr_rsp (nskb, f_bit, llc->vR); - rc =llc_mac_hdr_init (nskb, llc->dev->dev_addr, llc->daddr.mac); -if (unlikely (rc)) - goto free; -llc_conn_send_pdu (sk, nskb); - } -out: -return rc; -free: -kfree_skb (nskb); - goto out; -} - -int llc_conn_ac_send_ack_rsp_f_set_1 (struct sock *sk,struct sk_buff *skb) -{ -int rc = -ENOBUFS ; -struct llc_sock *llc =llc_sk (sk); -struct sk_buff *nskb =llc_alloc_frame (sk, llc->dev,LLC_PDU_TYPE_S ,0 ); - -if (nskb) { -struct llc_sap *sap = llc->sap; - -llc_pdu_header_init (nskb,LLC_PDU_TYPE_S , sap->laddr.lsap, - llc->daddr.lsap,LLC_PDU_RSP ); -llc_pdu_init_as_rr_rsp (nskb,1 , llc->vR); - rc =llc_mac_hdr_init (nskb, llc->dev->dev_addr, llc->daddr.mac); -if (unlikely (rc)) - goto free; -llc_conn_send_pdu (sk, nskb); - } -out: -return rc; -free: -kfree_skb (nskb); - goto out; -} - -int llc_conn_ac_send_rr_xxx_x_set_0 (struct sock *sk,struct sk_buff *skb) -{ -int rc = -ENOBUFS ; -struct llc_sock *llc =llc_sk (sk); -struct sk_buff *nskb =llc_alloc_frame (sk, llc->dev,LLC_PDU_TYPE_S ,0 ); - -if (nskb) { -struct llc_sap *sap = llc->sap; - -llc_pdu_header_init (nskb,LLC_PDU_TYPE_S , sap->laddr.lsap, - llc->daddr.lsap,LLC_PDU_RSP ); -llc_pdu_init_as_rr_rsp (nskb,0 , llc->vR); - rc =llc_mac_hdr_init (nskb, llc->dev->dev_addr, llc->daddr.mac); -if (unlikely (rc)) - goto free; -llc_conn_send_pdu (sk, nskb); - } -out: -return rc; -free: -kfree_skb (nskb); - goto out; -} - -int llc_conn_ac_send_ack_xxx_x_set_0 (struct sock *sk,struct sk_buff *skb) -{ -int rc = -ENOBUFS ; -struct llc_sock *llc =llc_sk (sk); -struct sk_buff *nskb =llc_alloc_frame (sk, llc->dev,LLC_PDU_TYPE_S ,0 ); - -if (nskb) { -struct llc_sap *sap = llc->sap; - -llc_pdu_header_init (nskb,LLC_PDU_TYPE_S , sap->laddr.lsap, - llc->daddr.lsap,LLC_PDU_RSP ); -llc_pdu_init_as_rr_rsp (nskb,0 , llc->vR); - rc =llc_mac_hdr_init (nskb, llc->dev->dev_addr, llc->daddr.mac); -if (unlikely (rc)) - goto free; -llc_conn_send_pdu (sk, nskb); - } -out: -return rc; -free: -kfree_skb (nskb); - goto out; -} - -void llc_conn_set_p_flag (struct sock *sk,u8 value) -{ -int state_changed =llc_sk (sk)->p_flag && !value; - -llc_sk (sk)->p_flag = value; - -if (state_changed) - sk->sk_state_change (sk); -} - -int llc_conn_ac_send_sabme_cmd_p_set_x (struct sock *sk,struct sk_buff *skb) -{ -int rc = -ENOBUFS ; -struct llc_sock *llc =llc_sk (sk); -struct sk_buff *nskb =llc_alloc_frame (sk, llc->dev,LLC_PDU_TYPE_U ,0 ); - -if (nskb) { -struct llc_sap *sap = llc->sap; -const u8 *dmac = llc->daddr.mac; - -if (llc->dev->flags &IFF_LOOPBACK ) - dmac = llc->dev->dev_addr; -llc_pdu_header_init (nskb,LLC_PDU_TYPE_U , sap->laddr.lsap, - llc->daddr.lsap,LLC_PDU_CMD ); -llc_pdu_init_as_sabme_cmd (nskb,1 ); - rc =llc_mac_hdr_init (nskb, llc->dev->dev_addr, dmac); -if (unlikely (rc)) - goto free; -llc_conn_send_pdu (sk, nskb); -llc_conn_set_p_flag (sk,1 ); - } -out: -return rc; -free: -kfree_skb (nskb); - goto out; -} - -int llc_conn_ac_send_ua_rsp_f_set_p (struct sock *sk,struct sk_buff *skb) -{ -u8 f_bit; -int rc = -ENOBUFS ; -struct llc_sock *llc =llc_sk (sk); -struct sk_buff *nskb =llc_alloc_frame (sk, llc->dev,LLC_PDU_TYPE_U ,0 ); - -llc_pdu_decode_pf_bit (skb, &f_bit); -if (nskb) { -struct llc_sap *sap = llc->sap; - - nskb->dev = llc->dev; -llc_pdu_header_init (nskb,LLC_PDU_TYPE_U , sap->laddr.lsap, - llc->daddr.lsap,LLC_PDU_RSP ); -llc_pdu_init_as_ua_rsp (nskb, f_bit); - rc =llc_mac_hdr_init (nskb, llc->dev->dev_addr, llc->daddr.mac); -if (unlikely (rc)) - goto free; -llc_conn_send_pdu (sk, nskb); - } -out: -return rc; -free: -kfree_skb (nskb); - goto out; -} - -int llc_conn_ac_set_s_flag_0 (struct sock *sk,struct sk_buff *skb) -{ -llc_sk (sk)->s_flag =0 ; -return 0 ; -} - -int llc_conn_ac_set_s_flag_1 (struct sock *sk,struct sk_buff *skb) -{ -llc_sk (sk)->s_flag =1 ; -return 0 ; -} - -int llc_conn_ac_start_p_timer (struct sock *sk,struct sk_buff *skb) -{ -struct llc_sock *llc =llc_sk (sk); - -llc_conn_set_p_flag (sk,1 ); -mod_timer (&llc->pf_cycle_timer.timer, - jiffies + llc->pf_cycle_timer.expire); -return 0 ; -} - -/** -* llc_conn_ac_send_ack_if_needed - check if ack is needed -* @sk: current connection structure -* @skb: current event -* -* Checks number of received PDUs which have not been acknowledged, yet, -* If number of them reaches to "npta"(Number of PDUs To Acknowledge) then -* sends an RR response as acknowledgement for them. Returns 0 for -* success, 1 otherwise. Lines of this file are not shown. View the raw message.
arch/loongarch/configs/loongson32_defconfig +0
-1Lines of this file are not shown. View the raw message.
arch/loongarch/configs/loongson64_defconfig +0
-1Lines of this file are not shown. View the raw message.
arch/parisc/configs/generic-32bit_defconfig +0
-1Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.