mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-05 10:29:37 +00:00
![Linus Torvalds](/assets/img/avatar_default.png)
Core ---- - Allow live renaming when an interface is up - Add retpoline wrappers for tc, improving considerably the performances of complex queue discipline configurations. - Add inet drop monitor support. - A few GRO performance improvements. - Add infrastructure for atomic dev stats, addressing long standing data races. - De-duplicate common code between OVS and conntrack offloading infrastructure. - A bunch of UBSAN_BOUNDS/FORTIFY_SOURCE improvements. - Netfilter: introduce packet parser for tunneled packets - Replace IPVS timer-based estimators with kthreads to scale up the workload with the number of available CPUs. - Add the helper support for connection-tracking OVS offload. BPF --- - Support for user defined BPF objects: the use case is to allocate own objects, build own object hierarchies and use the building blocks to build own data structures flexibly, for example, linked lists in BPF. - Make cgroup local storage available to non-cgroup attached BPF programs. - Avoid unnecessary deadlock detection and failures wrt BPF task storage helpers. - A relevant bunch of BPF verifier fixes and improvements. - Veristat tool improvements to support custom filtering, sorting, and replay of results. - Add LLVM disassembler as default library for dumping JITed code. - Lots of new BPF documentation for various BPF maps. - Add bpf_rcu_read_{,un}lock() support for sleepable programs. - Add RCU grace period chaining to BPF to wait for the completion of access from both sleepable and non-sleepable BPF programs. - Add support storing struct task_struct objects as kptrs in maps. - Improve helper UAPI by explicitly defining BPF_FUNC_xxx integer values. - Add libbpf *_opts API-variants for bpf_*_get_fd_by_id() functions. Protocols --------- - TCP: implement Protective Load Balancing across switch links. - TCP: allow dynamically disabling TCP-MD5 static key, reverting back to fast[er]-path. - UDP: Introduce optional per-netns hash lookup table. - IPv6: simplify and cleanup sockets disposal. - Netlink: support different type policies for each generic netlink operation. - MPTCP: add MSG_FASTOPEN and FastOpen listener side support. - MPTCP: add netlink notification support for listener sockets events. - SCTP: add VRF support, allowing sctp sockets binding to VRF devices. - Add bridging MAC Authentication Bypass (MAB) support. - Extensions for Ethernet VPN bridging implementation to better support multicast scenarios. - More work for Wi-Fi 7 support, comprising conversion of all the existing drivers to internal TX queue usage. - IPSec: introduce a new offload type (packet offload) allowing complete header processing and crypto offloading. - IPSec: extended ack support for more descriptive XFRM error reporting. - RXRPC: increase SACK table size and move processing into a per-local endpoint kernel thread, reducing considerably the required locking. - IEEE 802154: synchronous send frame and extended filtering support, initial support for scanning available 15.4 networks. - Tun: bump the link speed from 10Mbps to 10Gbps. - Tun/VirtioNet: implement UDP segmentation offload support. Driver API ---------- - PHY/SFP: improve power level switching between standard level 1 and the higher power levels. - New API for netdev <-> devlink_port linkage. - PTP: convert existing drivers to new frequency adjustment implementation. - DSA: add support for rx offloading. - Autoload DSA tagging driver when dynamically changing protocol. - Add new PCP and APPTRUST attributes to Data Center Bridging. - Add configuration support for 800Gbps link speed. - Add devlink port function attribute to enable/disable RoCE and migratable. - Extend devlink-rate to support strict prioriry and weighted fair queuing. - Add devlink support to directly reading from region memory. - New device tree helper to fetch MAC address from nvmem. - New big TCP helper to simplify temporary header stripping. New hardware / drivers ---------------------- - Ethernet: - Marvel Octeon CNF95N and CN10KB Ethernet Switches. - Marvel Prestera AC5X Ethernet Switch. - WangXun 10 Gigabit NIC. - Motorcomm yt8521 Gigabit Ethernet. - Microchip ksz9563 Gigabit Ethernet Switch. - Microsoft Azure Network Adapter. - Linux Automation 10Base-T1L adapter. - PHY: - Aquantia AQR112 and AQR412. - Motorcomm YT8531S. - PTP: - Orolia ART-CARD. - WiFi: - MediaTek Wi-Fi 7 (802.11be) devices. - RealTek rtw8821cu, rtw8822bu, rtw8822cu and rtw8723du USB devices. - Bluetooth: - Broadcom BCM4377/4378/4387 Bluetooth chipsets. - Realtek RTL8852BE and RTL8723DS. - Cypress.CYW4373A0 WiFi + Bluetooth combo device. Drivers ------- - CAN: - gs_usb: bus error reporting support. - kvaser_usb: listen only and bus error reporting support. - Ethernet NICs: - Intel (100G): - extend action skbedit to RX queue mapping. - implement devlink-rate support. - support direct read from memory. - nVidia/Mellanox (mlx5): - SW steering improvements, increasing rules update rate. - Support for enhanced events compression. - extend H/W offload packet manipulation capabilities. - implement IPSec packet offload mode. - nVidia/Mellanox (mlx4): - better big TCP support. - Netronome Ethernet NICs (nfp): - IPsec offload support. - add support for multicast filter. - Broadcom: - RSS and PTP support improvements. - AMD/SolarFlare: - netlink extened ack improvements. - add basic flower matches to offload, and related stats. - Virtual NICs: - ibmvnic: introduce affinity hint support. - small / embedded: - FreeScale fec: add initial XDP support. - Marvel mv643xx_eth: support MII/GMII/RGMII modes for Kirkwood. - TI am65-cpsw: add suspend/resume support. - Mediatek MT7986: add RX wireless wthernet dispatch support. - Realtek 8169: enable GRO software interrupt coalescing per default. - Ethernet high-speed switches: - Microchip (sparx5): - add support for Sparx5 TC/flower H/W offload via VCAP. - Mellanox mlxsw: - add 802.1X and MAC Authentication Bypass offload support. - add ip6gre support. - Embedded Ethernet switches: - Mediatek (mtk_eth_soc): - improve PCS implementation, add DSA untag support. - enable flow offload support. - Renesas: - add rswitch R-Car Gen4 gPTP support. - Microchip (lan966x): - add full XDP support. - add TC H/W offload via VCAP. - enable PTP on bridge interfaces. - Microchip (ksz8): - add MTU support for KSZ8 series. - Qualcomm 802.11ax WiFi (ath11k): - support configuring channel dwell time during scan. - MediaTek WiFi (mt76): - enable Wireless Ethernet Dispatch (WED) offload support. - add ack signal support. - enable coredump support. - remain_on_channel support. - Intel WiFi (iwlwifi): - enable Wi-Fi 7 Extremely High Throughput (EHT) PHY capabilities. - 320 MHz channels support. - RealTek WiFi (rtw89): - new dynamic header firmware format support. - wake-over-WLAN support. Signed-off-by: Paolo Abeni <pabeni@redhat.com> -----BEGIN PGP SIGNATURE----- iQJGBAABCAAwFiEEg1AjqC77wbdLX2LbKSR5jcyPE6QFAmOYXUcSHHBhYmVuaUBy ZWRoYXQuY29tAAoJECkkeY3MjxOk8zQP/R7BZtbJMTPiWkRnSoKHnAyupDVwrz5U ktukLkwPsCyJuEbAjgxrxf4EEEQ9uq2FFlxNSYuKiiQMqIpFxV6KED7LCUygn4Tc kxtkp0Q+5XiqisWlQmtfExf2OjuuPqcjV9tWCDBI6GebKUbfNwY/eI44RcMu4BSv DzIlW5GkX/kZAPqnnuqaLsN3FudDTJHGEAD7NbA++7wJ076RWYSLXlFv0Z+SCSPS H8/PEG0/ZK/65rIWMAFRClJ9BNIDwGVgp0GrsIvs1gqbRUOlA1hl1rDM21TqtNFf 5QPQT7sIfTcCE/nerxKJD5JE3JyP+XRlRn96PaRw3rt4MgI6I/EOj/HOKQ5tMCNc oPiqb7N70+hkLZyr42qX+vN9eDPjp2koEQm7EO2Zs+/534/zWDs24Zfk/Aa1ps0I Fa82oGjAgkBhGe/FZ6i5cYoLcyxqRqZV1Ws9XQMl72qRC7/BwvNbIW6beLpCRyeM yYIU+0e9dEm+wHQEdh2niJuVtR63hy8tvmPx56lyh+6u0+pondkwbfSiC5aD3kAC ikKsN5DyEsdXyiBAlytCEBxnaOjQy4RAz+3YXSiS0eBNacXp03UUrNGx4Pzpu/D0 QLFJhBnMFFCgy5to8/DvKnrTPgZdSURwqbIUcZdvU21f1HLR8tUTpaQnYffc/Whm V8gnt1EL+0cc =CbJC -----END PGP SIGNATURE----- Merge tag 'net-next-6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next Pull networking updates from Paolo Abeni: "Core: - Allow live renaming when an interface is up - Add retpoline wrappers for tc, improving considerably the performances of complex queue discipline configurations - Add inet drop monitor support - A few GRO performance improvements - Add infrastructure for atomic dev stats, addressing long standing data races - De-duplicate common code between OVS and conntrack offloading infrastructure - A bunch of UBSAN_BOUNDS/FORTIFY_SOURCE improvements - Netfilter: introduce packet parser for tunneled packets - Replace IPVS timer-based estimators with kthreads to scale up the workload with the number of available CPUs - Add the helper support for connection-tracking OVS offload BPF: - Support for user defined BPF objects: the use case is to allocate own objects, build own object hierarchies and use the building blocks to build own data structures flexibly, for example, linked lists in BPF - Make cgroup local storage available to non-cgroup attached BPF programs - Avoid unnecessary deadlock detection and failures wrt BPF task storage helpers - A relevant bunch of BPF verifier fixes and improvements - Veristat tool improvements to support custom filtering, sorting, and replay of results - Add LLVM disassembler as default library for dumping JITed code - Lots of new BPF documentation for various BPF maps - Add bpf_rcu_read_{,un}lock() support for sleepable programs - Add RCU grace period chaining to BPF to wait for the completion of access from both sleepable and non-sleepable BPF programs - Add support storing struct task_struct objects as kptrs in maps - Improve helper UAPI by explicitly defining BPF_FUNC_xxx integer values - Add libbpf *_opts API-variants for bpf_*_get_fd_by_id() functions Protocols: - TCP: implement Protective Load Balancing across switch links - TCP: allow dynamically disabling TCP-MD5 static key, reverting back to fast[er]-path - UDP: Introduce optional per-netns hash lookup table - IPv6: simplify and cleanup sockets disposal - Netlink: support different type policies for each generic netlink operation - MPTCP: add MSG_FASTOPEN and FastOpen listener side support - MPTCP: add netlink notification support for listener sockets events - SCTP: add VRF support, allowing sctp sockets binding to VRF devices - Add bridging MAC Authentication Bypass (MAB) support - Extensions for Ethernet VPN bridging implementation to better support multicast scenarios - More work for Wi-Fi 7 support, comprising conversion of all the existing drivers to internal TX queue usage - IPSec: introduce a new offload type (packet offload) allowing complete header processing and crypto offloading - IPSec: extended ack support for more descriptive XFRM error reporting - RXRPC: increase SACK table size and move processing into a per-local endpoint kernel thread, reducing considerably the required locking - IEEE 802154: synchronous send frame and extended filtering support, initial support for scanning available 15.4 networks - Tun: bump the link speed from 10Mbps to 10Gbps - Tun/VirtioNet: implement UDP segmentation offload support Driver API: - PHY/SFP: improve power level switching between standard level 1 and the higher power levels - New API for netdev <-> devlink_port linkage - PTP: convert existing drivers to new frequency adjustment implementation - DSA: add support for rx offloading - Autoload DSA tagging driver when dynamically changing protocol - Add new PCP and APPTRUST attributes to Data Center Bridging - Add configuration support for 800Gbps link speed - Add devlink port function attribute to enable/disable RoCE and migratable - Extend devlink-rate to support strict prioriry and weighted fair queuing - Add devlink support to directly reading from region memory - New device tree helper to fetch MAC address from nvmem - New big TCP helper to simplify temporary header stripping New hardware / drivers: - Ethernet: - Marvel Octeon CNF95N and CN10KB Ethernet Switches - Marvel Prestera AC5X Ethernet Switch - WangXun 10 Gigabit NIC - Motorcomm yt8521 Gigabit Ethernet - Microchip ksz9563 Gigabit Ethernet Switch - Microsoft Azure Network Adapter - Linux Automation 10Base-T1L adapter - PHY: - Aquantia AQR112 and AQR412 - Motorcomm YT8531S - PTP: - Orolia ART-CARD - WiFi: - MediaTek Wi-Fi 7 (802.11be) devices - RealTek rtw8821cu, rtw8822bu, rtw8822cu and rtw8723du USB devices - Bluetooth: - Broadcom BCM4377/4378/4387 Bluetooth chipsets - Realtek RTL8852BE and RTL8723DS - Cypress.CYW4373A0 WiFi + Bluetooth combo device Drivers: - CAN: - gs_usb: bus error reporting support - kvaser_usb: listen only and bus error reporting support - Ethernet NICs: - Intel (100G): - extend action skbedit to RX queue mapping - implement devlink-rate support - support direct read from memory - nVidia/Mellanox (mlx5): - SW steering improvements, increasing rules update rate - Support for enhanced events compression - extend H/W offload packet manipulation capabilities - implement IPSec packet offload mode - nVidia/Mellanox (mlx4): - better big TCP support - Netronome Ethernet NICs (nfp): - IPsec offload support - add support for multicast filter - Broadcom: - RSS and PTP support improvements - AMD/SolarFlare: - netlink extened ack improvements - add basic flower matches to offload, and related stats - Virtual NICs: - ibmvnic: introduce affinity hint support - small / embedded: - FreeScale fec: add initial XDP support - Marvel mv643xx_eth: support MII/GMII/RGMII modes for Kirkwood - TI am65-cpsw: add suspend/resume support - Mediatek MT7986: add RX wireless wthernet dispatch support - Realtek 8169: enable GRO software interrupt coalescing per default - Ethernet high-speed switches: - Microchip (sparx5): - add support for Sparx5 TC/flower H/W offload via VCAP - Mellanox mlxsw: - add 802.1X and MAC Authentication Bypass offload support - add ip6gre support - Embedded Ethernet switches: - Mediatek (mtk_eth_soc): - improve PCS implementation, add DSA untag support - enable flow offload support - Renesas: - add rswitch R-Car Gen4 gPTP support - Microchip (lan966x): - add full XDP support - add TC H/W offload via VCAP - enable PTP on bridge interfaces - Microchip (ksz8): - add MTU support for KSZ8 series - Qualcomm 802.11ax WiFi (ath11k): - support configuring channel dwell time during scan - MediaTek WiFi (mt76): - enable Wireless Ethernet Dispatch (WED) offload support - add ack signal support - enable coredump support - remain_on_channel support - Intel WiFi (iwlwifi): - enable Wi-Fi 7 Extremely High Throughput (EHT) PHY capabilities - 320 MHz channels support - RealTek WiFi (rtw89): - new dynamic header firmware format support - wake-over-WLAN support" * tag 'net-next-6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next: (2002 commits) ipvs: fix type warning in do_div() on 32 bit net: lan966x: Remove a useless test in lan966x_ptp_add_trap() net: ipa: add IPA v4.7 support dt-bindings: net: qcom,ipa: Add SM6350 compatible bnxt: Use generic HBH removal helper in tx path IPv6/GRO: generic helper to remove temporary HBH/jumbo header in driver selftests: forwarding: Add bridge MDB test selftests: forwarding: Rename bridge_mdb test bridge: mcast: Support replacement of MDB port group entries bridge: mcast: Allow user space to specify MDB entry routing protocol bridge: mcast: Allow user space to add (*, G) with a source list and filter mode bridge: mcast: Add support for (*, G) with a source list and filter mode bridge: mcast: Avoid arming group timer when (S, G) corresponds to a source bridge: mcast: Add a flag for user installed source entries bridge: mcast: Expose __br_multicast_del_group_src() bridge: mcast: Expose br_multicast_new_group_src() bridge: mcast: Add a centralized error path bridge: mcast: Place netlink policy before validation functions bridge: mcast: Split (*, G) and (S, G) addition into different functions bridge: mcast: Do not derive entry type from its filter mode ...
340 lines
8.5 KiB
C
340 lines
8.5 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* net/sched/act_gact.c Generic actions
|
|
*
|
|
* copyright Jamal Hadi Salim (2002-4)
|
|
*/
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/string.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/skbuff.h>
|
|
#include <linux/rtnetlink.h>
|
|
#include <linux/module.h>
|
|
#include <linux/init.h>
|
|
#include <net/netlink.h>
|
|
#include <net/pkt_sched.h>
|
|
#include <net/pkt_cls.h>
|
|
#include <linux/tc_act/tc_gact.h>
|
|
#include <net/tc_act/tc_gact.h>
|
|
#include <net/tc_wrapper.h>
|
|
|
|
static struct tc_action_ops act_gact_ops;
|
|
|
|
#ifdef CONFIG_GACT_PROB
|
|
static int gact_net_rand(struct tcf_gact *gact)
|
|
{
|
|
smp_rmb(); /* coupled with smp_wmb() in tcf_gact_init() */
|
|
if (get_random_u32_below(gact->tcfg_pval))
|
|
return gact->tcf_action;
|
|
return gact->tcfg_paction;
|
|
}
|
|
|
|
static int gact_determ(struct tcf_gact *gact)
|
|
{
|
|
u32 pack = atomic_inc_return(&gact->packets);
|
|
|
|
smp_rmb(); /* coupled with smp_wmb() in tcf_gact_init() */
|
|
if (pack % gact->tcfg_pval)
|
|
return gact->tcf_action;
|
|
return gact->tcfg_paction;
|
|
}
|
|
|
|
typedef int (*g_rand)(struct tcf_gact *gact);
|
|
static g_rand gact_rand[MAX_RAND] = { NULL, gact_net_rand, gact_determ };
|
|
#endif /* CONFIG_GACT_PROB */
|
|
|
|
static const struct nla_policy gact_policy[TCA_GACT_MAX + 1] = {
|
|
[TCA_GACT_PARMS] = { .len = sizeof(struct tc_gact) },
|
|
[TCA_GACT_PROB] = { .len = sizeof(struct tc_gact_p) },
|
|
};
|
|
|
|
static int tcf_gact_init(struct net *net, struct nlattr *nla,
|
|
struct nlattr *est, struct tc_action **a,
|
|
struct tcf_proto *tp, u32 flags,
|
|
struct netlink_ext_ack *extack)
|
|
{
|
|
struct tc_action_net *tn = net_generic(net, act_gact_ops.net_id);
|
|
bool bind = flags & TCA_ACT_FLAGS_BIND;
|
|
struct nlattr *tb[TCA_GACT_MAX + 1];
|
|
struct tcf_chain *goto_ch = NULL;
|
|
struct tc_gact *parm;
|
|
struct tcf_gact *gact;
|
|
int ret = 0;
|
|
u32 index;
|
|
int err;
|
|
#ifdef CONFIG_GACT_PROB
|
|
struct tc_gact_p *p_parm = NULL;
|
|
#endif
|
|
|
|
if (nla == NULL)
|
|
return -EINVAL;
|
|
|
|
err = nla_parse_nested_deprecated(tb, TCA_GACT_MAX, nla, gact_policy,
|
|
NULL);
|
|
if (err < 0)
|
|
return err;
|
|
|
|
if (tb[TCA_GACT_PARMS] == NULL)
|
|
return -EINVAL;
|
|
parm = nla_data(tb[TCA_GACT_PARMS]);
|
|
index = parm->index;
|
|
|
|
#ifndef CONFIG_GACT_PROB
|
|
if (tb[TCA_GACT_PROB] != NULL)
|
|
return -EOPNOTSUPP;
|
|
#else
|
|
if (tb[TCA_GACT_PROB]) {
|
|
p_parm = nla_data(tb[TCA_GACT_PROB]);
|
|
if (p_parm->ptype >= MAX_RAND)
|
|
return -EINVAL;
|
|
if (TC_ACT_EXT_CMP(p_parm->paction, TC_ACT_GOTO_CHAIN)) {
|
|
NL_SET_ERR_MSG(extack,
|
|
"goto chain not allowed on fallback");
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
#endif
|
|
|
|
err = tcf_idr_check_alloc(tn, &index, a, bind);
|
|
if (!err) {
|
|
ret = tcf_idr_create_from_flags(tn, index, est, a,
|
|
&act_gact_ops, bind, flags);
|
|
if (ret) {
|
|
tcf_idr_cleanup(tn, index);
|
|
return ret;
|
|
}
|
|
ret = ACT_P_CREATED;
|
|
} else if (err > 0) {
|
|
if (bind)/* dont override defaults */
|
|
return 0;
|
|
if (!(flags & TCA_ACT_FLAGS_REPLACE)) {
|
|
tcf_idr_release(*a, bind);
|
|
return -EEXIST;
|
|
}
|
|
} else {
|
|
return err;
|
|
}
|
|
|
|
err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack);
|
|
if (err < 0)
|
|
goto release_idr;
|
|
gact = to_gact(*a);
|
|
|
|
spin_lock_bh(&gact->tcf_lock);
|
|
goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch);
|
|
#ifdef CONFIG_GACT_PROB
|
|
if (p_parm) {
|
|
gact->tcfg_paction = p_parm->paction;
|
|
gact->tcfg_pval = max_t(u16, 1, p_parm->pval);
|
|
/* Make sure tcfg_pval is written before tcfg_ptype
|
|
* coupled with smp_rmb() in gact_net_rand() & gact_determ()
|
|
*/
|
|
smp_wmb();
|
|
gact->tcfg_ptype = p_parm->ptype;
|
|
}
|
|
#endif
|
|
spin_unlock_bh(&gact->tcf_lock);
|
|
|
|
if (goto_ch)
|
|
tcf_chain_put_by_act(goto_ch);
|
|
|
|
return ret;
|
|
release_idr:
|
|
tcf_idr_release(*a, bind);
|
|
return err;
|
|
}
|
|
|
|
TC_INDIRECT_SCOPE int tcf_gact_act(struct sk_buff *skb,
|
|
const struct tc_action *a,
|
|
struct tcf_result *res)
|
|
{
|
|
struct tcf_gact *gact = to_gact(a);
|
|
int action = READ_ONCE(gact->tcf_action);
|
|
|
|
#ifdef CONFIG_GACT_PROB
|
|
{
|
|
u32 ptype = READ_ONCE(gact->tcfg_ptype);
|
|
|
|
if (ptype)
|
|
action = gact_rand[ptype](gact);
|
|
}
|
|
#endif
|
|
tcf_action_update_bstats(&gact->common, skb);
|
|
if (action == TC_ACT_SHOT)
|
|
tcf_action_inc_drop_qstats(&gact->common);
|
|
|
|
tcf_lastuse_update(&gact->tcf_tm);
|
|
|
|
return action;
|
|
}
|
|
|
|
static void tcf_gact_stats_update(struct tc_action *a, u64 bytes, u64 packets,
|
|
u64 drops, u64 lastuse, bool hw)
|
|
{
|
|
struct tcf_gact *gact = to_gact(a);
|
|
int action = READ_ONCE(gact->tcf_action);
|
|
struct tcf_t *tm = &gact->tcf_tm;
|
|
|
|
tcf_action_update_stats(a, bytes, packets,
|
|
action == TC_ACT_SHOT ? packets : drops, hw);
|
|
tm->lastuse = max_t(u64, tm->lastuse, lastuse);
|
|
}
|
|
|
|
static int tcf_gact_dump(struct sk_buff *skb, struct tc_action *a,
|
|
int bind, int ref)
|
|
{
|
|
unsigned char *b = skb_tail_pointer(skb);
|
|
struct tcf_gact *gact = to_gact(a);
|
|
struct tc_gact opt = {
|
|
.index = gact->tcf_index,
|
|
.refcnt = refcount_read(&gact->tcf_refcnt) - ref,
|
|
.bindcnt = atomic_read(&gact->tcf_bindcnt) - bind,
|
|
};
|
|
struct tcf_t t;
|
|
|
|
spin_lock_bh(&gact->tcf_lock);
|
|
opt.action = gact->tcf_action;
|
|
if (nla_put(skb, TCA_GACT_PARMS, sizeof(opt), &opt))
|
|
goto nla_put_failure;
|
|
#ifdef CONFIG_GACT_PROB
|
|
if (gact->tcfg_ptype) {
|
|
struct tc_gact_p p_opt = {
|
|
.paction = gact->tcfg_paction,
|
|
.pval = gact->tcfg_pval,
|
|
.ptype = gact->tcfg_ptype,
|
|
};
|
|
|
|
if (nla_put(skb, TCA_GACT_PROB, sizeof(p_opt), &p_opt))
|
|
goto nla_put_failure;
|
|
}
|
|
#endif
|
|
tcf_tm_dump(&t, &gact->tcf_tm);
|
|
if (nla_put_64bit(skb, TCA_GACT_TM, sizeof(t), &t, TCA_GACT_PAD))
|
|
goto nla_put_failure;
|
|
spin_unlock_bh(&gact->tcf_lock);
|
|
|
|
return skb->len;
|
|
|
|
nla_put_failure:
|
|
spin_unlock_bh(&gact->tcf_lock);
|
|
nlmsg_trim(skb, b);
|
|
return -1;
|
|
}
|
|
|
|
static size_t tcf_gact_get_fill_size(const struct tc_action *act)
|
|
{
|
|
size_t sz = nla_total_size(sizeof(struct tc_gact)); /* TCA_GACT_PARMS */
|
|
|
|
#ifdef CONFIG_GACT_PROB
|
|
if (to_gact(act)->tcfg_ptype)
|
|
/* TCA_GACT_PROB */
|
|
sz += nla_total_size(sizeof(struct tc_gact_p));
|
|
#endif
|
|
|
|
return sz;
|
|
}
|
|
|
|
static int tcf_gact_offload_act_setup(struct tc_action *act, void *entry_data,
|
|
u32 *index_inc, bool bind,
|
|
struct netlink_ext_ack *extack)
|
|
{
|
|
if (bind) {
|
|
struct flow_action_entry *entry = entry_data;
|
|
|
|
if (is_tcf_gact_ok(act)) {
|
|
entry->id = FLOW_ACTION_ACCEPT;
|
|
} else if (is_tcf_gact_shot(act)) {
|
|
entry->id = FLOW_ACTION_DROP;
|
|
} else if (is_tcf_gact_trap(act)) {
|
|
entry->id = FLOW_ACTION_TRAP;
|
|
} else if (is_tcf_gact_goto_chain(act)) {
|
|
entry->id = FLOW_ACTION_GOTO;
|
|
entry->chain_index = tcf_gact_goto_chain_index(act);
|
|
} else if (is_tcf_gact_continue(act)) {
|
|
NL_SET_ERR_MSG_MOD(extack, "Offload of \"continue\" action is not supported");
|
|
return -EOPNOTSUPP;
|
|
} else if (is_tcf_gact_reclassify(act)) {
|
|
NL_SET_ERR_MSG_MOD(extack, "Offload of \"reclassify\" action is not supported");
|
|
return -EOPNOTSUPP;
|
|
} else if (is_tcf_gact_pipe(act)) {
|
|
NL_SET_ERR_MSG_MOD(extack, "Offload of \"pipe\" action is not supported");
|
|
return -EOPNOTSUPP;
|
|
} else {
|
|
NL_SET_ERR_MSG_MOD(extack, "Unsupported generic action offload");
|
|
return -EOPNOTSUPP;
|
|
}
|
|
*index_inc = 1;
|
|
} else {
|
|
struct flow_offload_action *fl_action = entry_data;
|
|
|
|
if (is_tcf_gact_ok(act))
|
|
fl_action->id = FLOW_ACTION_ACCEPT;
|
|
else if (is_tcf_gact_shot(act))
|
|
fl_action->id = FLOW_ACTION_DROP;
|
|
else if (is_tcf_gact_trap(act))
|
|
fl_action->id = FLOW_ACTION_TRAP;
|
|
else if (is_tcf_gact_goto_chain(act))
|
|
fl_action->id = FLOW_ACTION_GOTO;
|
|
else
|
|
return -EOPNOTSUPP;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static struct tc_action_ops act_gact_ops = {
|
|
.kind = "gact",
|
|
.id = TCA_ID_GACT,
|
|
.owner = THIS_MODULE,
|
|
.act = tcf_gact_act,
|
|
.stats_update = tcf_gact_stats_update,
|
|
.dump = tcf_gact_dump,
|
|
.init = tcf_gact_init,
|
|
.get_fill_size = tcf_gact_get_fill_size,
|
|
.offload_act_setup = tcf_gact_offload_act_setup,
|
|
.size = sizeof(struct tcf_gact),
|
|
};
|
|
|
|
static __net_init int gact_init_net(struct net *net)
|
|
{
|
|
struct tc_action_net *tn = net_generic(net, act_gact_ops.net_id);
|
|
|
|
return tc_action_net_init(net, tn, &act_gact_ops);
|
|
}
|
|
|
|
static void __net_exit gact_exit_net(struct list_head *net_list)
|
|
{
|
|
tc_action_net_exit(net_list, act_gact_ops.net_id);
|
|
}
|
|
|
|
static struct pernet_operations gact_net_ops = {
|
|
.init = gact_init_net,
|
|
.exit_batch = gact_exit_net,
|
|
.id = &act_gact_ops.net_id,
|
|
.size = sizeof(struct tc_action_net),
|
|
};
|
|
|
|
MODULE_AUTHOR("Jamal Hadi Salim(2002-4)");
|
|
MODULE_DESCRIPTION("Generic Classifier actions");
|
|
MODULE_LICENSE("GPL");
|
|
|
|
static int __init gact_init_module(void)
|
|
{
|
|
#ifdef CONFIG_GACT_PROB
|
|
pr_info("GACT probability on\n");
|
|
#else
|
|
pr_info("GACT probability NOT on\n");
|
|
#endif
|
|
|
|
return tcf_register_action(&act_gact_ops, &gact_net_ops);
|
|
}
|
|
|
|
static void __exit gact_cleanup_module(void)
|
|
{
|
|
tcf_unregister_action(&act_gact_ops, &gact_net_ops);
|
|
}
|
|
|
|
module_init(gact_init_module);
|
|
module_exit(gact_cleanup_module);
|