Merge 46dc11bee2 ("Merge branch 'address-remaining-wtautological-constant-out-of-range-compare'") into android-mainline

Steps on the way to 6.10-rc1

Change-Id: I911ccebad271060bbb0caecbd55f0854e4d88f21
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Greg Kroah-Hartman
2024-07-26 05:55:45 +00:00
committed by Treehugger Robot
23 changed files with 1313 additions and 97 deletions
@@ -0,0 +1,56 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/net/airoha,en8811h.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Airoha EN8811H PHY
maintainers:
- Eric Woudstra <ericwouds@gmail.com>
description:
The Airoha EN8811H PHY has the ability to reverse polarity
on the lines to and/or from the MAC. It is reversed by
the booleans in the devicetree node of the phy.
allOf:
- $ref: ethernet-phy.yaml#
properties:
compatible:
enum:
- ethernet-phy-id03a2.a411
reg:
maxItems: 1
airoha,pnswap-rx:
type: boolean
description:
Reverse rx polarity of the SERDES. This is the receiving
side of the lines from the MAC towards the EN881H.
airoha,pnswap-tx:
type: boolean
description:
Reverse tx polarity of SERDES. This is the transmitting
side of the lines from EN8811H towards the MAC.
required:
- reg
unevaluatedProperties: false
examples:
- |
mdio {
#address-cells = <1>;
#size-cells = <0>;
ethernet-phy@1 {
compatible = "ethernet-phy-id03a2.a411";
reg = <1>;
airoha,pnswap-rx;
};
};
+1 -1
View File
@@ -2769,7 +2769,7 @@ static int enetc_setup_xdp_prog(struct net_device *ndev, struct bpf_prog *prog,
if (priv->min_num_stack_tx_queues + num_xdp_tx_queues >
priv->num_tx_rings) {
NL_SET_ERR_MSG_FMT_MOD(extack,
"Reserving %d XDP TXQs does not leave a minimum of %d for stack (total %d)",
"Reserving %d XDP TXQs leaves under %d for stack (total %d)",
num_xdp_tx_queues,
priv->min_num_stack_tx_queues,
priv->num_tx_rings);
@@ -1213,10 +1213,8 @@ struct nix_bp_cfg_req {
/* bpid_per_chan = 1 assigns separate bp id for each channel */
};
/* PF can be mapped to either CGX or LBK interface,
* so maximum 64 channels are possible.
*/
#define NIX_MAX_BPID_CHAN 64
/* Maximum channels any single NIX interface can have */
#define NIX_MAX_BPID_CHAN 256
struct nix_bp_cfg_rsp {
struct mbox_msghdr hdr;
u16 chan_bpid[NIX_MAX_BPID_CHAN]; /* Channel and bpid mapping */
@@ -450,7 +450,6 @@ static void otx2_pfvf_mbox_handler(struct work_struct *work)
struct mbox_msghdr *msg = NULL;
int offset, vf_idx, id, err;
struct otx2_mbox_dev *mdev;
struct mbox_hdr *req_hdr;
struct otx2_mbox *mbox;
struct mbox *vf_mbox;
struct otx2_nic *pf;
@@ -461,9 +460,8 @@ static void otx2_pfvf_mbox_handler(struct work_struct *work)
mbox = &pf->mbox_pfvf[0].mbox;
mdev = &mbox->dev[vf_idx];
req_hdr = (struct mbox_hdr *)(mdev->mbase + mbox->rx_start);
offset = ALIGN(sizeof(*req_hdr), MBOX_MSG_ALIGN);
offset = ALIGN(sizeof(struct mbox_hdr), MBOX_MSG_ALIGN);
for (id = 0; id < vf_mbox->num_msgs; id++) {
msg = (struct mbox_msghdr *)(mdev->mbase + mbox->rx_start +
@@ -494,7 +492,6 @@ static void otx2_pfvf_mbox_up_handler(struct work_struct *work)
struct otx2_nic *pf = vf_mbox->pfvf;
struct otx2_mbox_dev *mdev;
int offset, id, vf_idx = 0;
struct mbox_hdr *rsp_hdr;
struct mbox_msghdr *msg;
struct otx2_mbox *mbox;
@@ -502,8 +499,7 @@ static void otx2_pfvf_mbox_up_handler(struct work_struct *work)
mbox = &pf->mbox_pfvf[0].mbox_up;
mdev = &mbox->dev[vf_idx];
rsp_hdr = (struct mbox_hdr *)(mdev->mbase + mbox->rx_start);
offset = mbox->rx_start + ALIGN(sizeof(*rsp_hdr), MBOX_MSG_ALIGN);
offset = mbox->rx_start + ALIGN(sizeof(struct mbox_hdr), MBOX_MSG_ALIGN);
for (id = 0; id < vf_mbox->up_num_msgs; id++) {
msg = mdev->mbase + offset;
@@ -28,8 +28,10 @@ bool mlx5e_validate_xsk_param(struct mlx5e_params *params,
struct mlx5e_xsk_param *xsk,
struct mlx5_core_dev *mdev)
{
/* AF_XDP doesn't support frames larger than PAGE_SIZE. */
if (xsk->chunk_size > PAGE_SIZE || xsk->chunk_size < MLX5E_MIN_XSK_CHUNK_SIZE) {
/* AF_XDP doesn't support frames larger than PAGE_SIZE,
* and xsk->chunk_size is limited to 65535 bytes.
*/
if ((size_t)xsk->chunk_size > PAGE_SIZE || xsk->chunk_size < MLX5E_MIN_XSK_CHUNK_SIZE) {
mlx5_core_err(mdev, "XSK chunk size %u out of bounds [%u, %lu]\n", xsk->chunk_size,
MLX5E_MIN_XSK_CHUNK_SIZE, PAGE_SIZE);
return false;
@@ -1874,7 +1874,7 @@ int mlx5_esw_bridge_port_mdb_add(struct net_device *dev, u16 vport_num, u16 esw_
"Failed to lookup bridge port vlan metadata to create MDB (MAC=%pM,vid=%u,vport=%u)\n",
addr, vid, vport_num);
NL_SET_ERR_MSG_FMT_MOD(extack,
"Failed to lookup bridge port vlan metadata to create MDB (MAC=%pM,vid=%u,vport=%u)\n",
"Failed to lookup vlan metadata for MDB (MAC=%pM,vid=%u,vport=%u)\n",
addr, vid, vport_num);
return -EINVAL;
}
@@ -1112,7 +1112,6 @@ MODULE_DEVICE_TABLE(spi, encx24j600_spi_id_table);
static struct spi_driver encx24j600_spi_net_driver = {
.driver = {
.name = DRV_NAME,
.owner = THIS_MODULE,
.bus = &spi_bus_type,
},
.probe = encx24j600_spi_probe,
+4 -5
View File
@@ -1205,7 +1205,6 @@ out:
static int qed_slowpath_wq_start(struct qed_dev *cdev)
{
struct qed_hwfn *hwfn;
char name[NAME_SIZE];
int i;
if (IS_VF(cdev))
@@ -1214,11 +1213,11 @@ static int qed_slowpath_wq_start(struct qed_dev *cdev)
for_each_hwfn(cdev, i) {
hwfn = &cdev->hwfns[i];
snprintf(name, NAME_SIZE, "slowpath-%02x:%02x.%02x",
cdev->pdev->bus->number,
PCI_SLOT(cdev->pdev->devfn), hwfn->abs_pf_id);
hwfn->slowpath_wq = alloc_workqueue("slowpath-%02x:%02x.%02x",
0, 0, cdev->pdev->bus->number,
PCI_SLOT(cdev->pdev->devfn),
hwfn->abs_pf_id);
hwfn->slowpath_wq = alloc_workqueue(name, 0, 0);
if (!hwfn->slowpath_wq) {
DP_NOTICE(hwfn, "Cannot create slowpath workqueue\n");
return -ENOMEM;
+2 -2
View File
@@ -359,6 +359,7 @@
* @app2: MM2S/S2MM User Application Field 2.
* @app3: MM2S/S2MM User Application Field 3.
* @app4: MM2S/S2MM User Application Field 4.
* @skb: Pointer to SKB transferred using DMA
*/
struct axidma_bd {
u32 next; /* Physical address of next buffer descriptor */
@@ -399,7 +400,6 @@ struct skbuf_dma_descriptor {
* struct axienet_local - axienet private per device data
* @ndev: Pointer for net_device to which it will be attached.
* @dev: Pointer to device structure
* @phy_node: Pointer to device node structure
* @phylink: Pointer to phylink instance
* @phylink_config: phylink configuration settings
* @pcs_phy: Reference to PCS/PMA PHY if used
@@ -537,7 +537,7 @@ struct axienet_local {
};
/**
* struct axiethernet_option - Used to set axi ethernet hardware options
* struct axienet_option - Used to set axi ethernet hardware options
* @opt: Option to be set.
* @reg: Register offset to be written for setting the option
* @m_or: Mask to be ORed for setting the option in the register
@@ -20,7 +20,14 @@
#define DEFAULT_MDIO_FREQ 2500000 /* 2.5 MHz */
#define DEFAULT_HOST_CLOCK 150000000 /* 150 MHz */
/* Wait till MDIO interface is ready to accept a new transaction.*/
/**
* axienet_mdio_wait_until_ready - MDIO wait function
* @lp: Pointer to axienet local data structure.
*
* Return : 0 on success, Negative value on errors
*
* Wait till MDIO interface is ready to accept a new transaction.
*/
static int axienet_mdio_wait_until_ready(struct axienet_local *lp)
{
u32 val;
@@ -30,14 +37,24 @@ static int axienet_mdio_wait_until_ready(struct axienet_local *lp)
1, 20000);
}
/* Enable the MDIO MDC. Called prior to a read/write operation */
/**
* axienet_mdio_mdc_enable - MDIO MDC enable function
* @lp: Pointer to axienet local data structure.
*
* Enable the MDIO MDC. Called prior to a read/write operation
*/
static void axienet_mdio_mdc_enable(struct axienet_local *lp)
{
axienet_iow(lp, XAE_MDIO_MC_OFFSET,
((u32)lp->mii_clk_div | XAE_MDIO_MC_MDIOEN_MASK));
}
/* Disable the MDIO MDC. Called after a read/write operation*/
/**
* axienet_mdio_mdc_disable - MDIO MDC disable function
* @lp: Pointer to axienet local data structure.
*
* Disable the MDIO MDC. Called after a read/write operation
*/
static void axienet_mdio_mdc_disable(struct axienet_local *lp)
{
u32 mc_reg;
+5
View File
@@ -76,6 +76,11 @@ config SFP
comment "MII PHY device drivers"
config AIR_EN8811H_PHY
tristate "Airoha EN8811H 2.5 Gigabit PHY"
help
Currently supports the Airoha EN8811H PHY.
config AMD_PHY
tristate "AMD and Altima PHYs"
help
+1
View File
@@ -34,6 +34,7 @@ obj-y += $(sfp-obj-y) $(sfp-obj-m)
obj-$(CONFIG_ADIN_PHY) += adin.o
obj-$(CONFIG_ADIN1100_PHY) += adin1100.o
obj-$(CONFIG_AIR_EN8811H_PHY) += air_en8811h.o
obj-$(CONFIG_AMD_PHY) += amd.o
obj-$(CONFIG_AQUANTIA_PHY) += aquantia/
ifdef CONFIG_AX88796B_RUST_PHY
File diff suppressed because it is too large Load Diff
-1
View File
@@ -648,7 +648,6 @@ static struct mhi_driver mhi_mbim_driver = {
.id_table = mhi_mbim_id_table,
.driver = {
.name = "mhi_wwan_mbim",
.owner = THIS_MODULE,
},
};
-1
View File
@@ -199,7 +199,6 @@ static struct spi_driver nfcmrvl_spi_driver = {
.id_table = nfcmrvl_spi_id_table,
.driver = {
.name = "nfcmrvl_spi",
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(of_nfcmrvl_spi_match),
},
};
+11 -17
View File
@@ -7,14 +7,13 @@
*/
#include <linux/err.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/nfc.h>
#include <linux/of_gpio.h>
#include <linux/of.h>
#include <linux/property.h>
#include <linux/regulator/consumer.h>
@@ -196,7 +195,7 @@ struct st95_digital_cmd_complete_arg {
* for spi communication between st95hf and host.
* @ddev: nfc digital device object.
* @nfcdev: nfc device object.
* @enable_gpio: gpio used to enable st95hf transceiver.
* @enable_gpiod: gpio used to enable st95hf transceiver.
* @complete_cb_arg: structure to store various context information
* that is passed from nfc requesting thread to the threaded ISR.
* @st95hf_supply: regulator "consumer" for NFC device.
@@ -219,7 +218,7 @@ struct st95hf_context {
struct st95hf_spi_context spicontext;
struct nfc_digital_dev *ddev;
struct nfc_dev *nfcdev;
unsigned int enable_gpio;
struct gpio_desc *enable_gpiod;
struct st95_digital_cmd_complete_arg complete_cb_arg;
struct regulator *st95hf_supply;
unsigned char sendrcv_trflag;
@@ -451,19 +450,19 @@ static int st95hf_select_protocol(struct st95hf_context *stcontext, int type)
static void st95hf_send_st95enable_negativepulse(struct st95hf_context *st95con)
{
/* First make irq_in pin high */
gpio_set_value(st95con->enable_gpio, HIGH);
gpiod_set_value(st95con->enable_gpiod, HIGH);
/* wait for 1 milisecond */
usleep_range(1000, 2000);
/* Make irq_in pin low */
gpio_set_value(st95con->enable_gpio, LOW);
gpiod_set_value(st95con->enable_gpiod, LOW);
/* wait for minimum interrupt pulse to make st95 active */
usleep_range(1000, 2000);
/* At end make it high */
gpio_set_value(st95con->enable_gpio, HIGH);
gpiod_set_value(st95con->enable_gpiod, HIGH);
}
/*
@@ -1063,6 +1062,7 @@ MODULE_DEVICE_TABLE(of, st95hf_spi_of_match);
static int st95hf_probe(struct spi_device *nfc_spi_dev)
{
struct device *dev = &nfc_spi_dev->dev;
int ret;
struct st95hf_context *st95context;
@@ -1108,19 +1108,14 @@ static int st95hf_probe(struct spi_device *nfc_spi_dev)
*/
dev_set_drvdata(&nfc_spi_dev->dev, spicontext);
st95context->enable_gpio =
of_get_named_gpio(nfc_spi_dev->dev.of_node,
"enable-gpio",
0);
if (!gpio_is_valid(st95context->enable_gpio)) {
st95context->enable_gpiod = devm_gpiod_get(dev, "enable", GPIOD_OUT_HIGH);
if (IS_ERR(st95context->enable_gpiod)) {
ret = PTR_ERR(st95context->enable_gpiod);
dev_err(&nfc_spi_dev->dev, "No valid enable gpio\n");
ret = st95context->enable_gpio;
goto err_disable_regulator;
}
ret = devm_gpio_request_one(&nfc_spi_dev->dev, st95context->enable_gpio,
GPIOF_DIR_OUT | GPIOF_INIT_HIGH,
"enable_gpio");
ret = gpiod_set_consumer_name(st95context->enable_gpiod, "enable_gpio");
if (ret)
goto err_disable_regulator;
@@ -1242,7 +1237,6 @@ static void st95hf_remove(struct spi_device *nfc_spi_dev)
static struct spi_driver st95hf_driver = {
.driver = {
.name = "st95hf",
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(st95hf_spi_of_match),
},
.id_table = st95hf_id,
+40
View File
@@ -70,4 +70,44 @@
TP_STORE_V4MAPPED(__entry, saddr, daddr)
#endif
#define TP_STORE_ADDR_PORTS_SKB_V4(__entry, skb, protoh) \
do { \
struct sockaddr_in *v4 = (void *)__entry->saddr; \
\
v4->sin_family = AF_INET; \
v4->sin_port = protoh->source; \
v4->sin_addr.s_addr = ip_hdr(skb)->saddr; \
v4 = (void *)__entry->daddr; \
v4->sin_family = AF_INET; \
v4->sin_port = protoh->dest; \
v4->sin_addr.s_addr = ip_hdr(skb)->daddr; \
} while (0)
#if IS_ENABLED(CONFIG_IPV6)
#define TP_STORE_ADDR_PORTS_SKB(__entry, skb, protoh) \
do { \
const struct iphdr *iph = ip_hdr(skb); \
\
if (iph->version == 6) { \
struct sockaddr_in6 *v6 = (void *)__entry->saddr; \
\
v6->sin6_family = AF_INET6; \
v6->sin6_port = protoh->source; \
v6->sin6_addr = ipv6_hdr(skb)->saddr; \
v6 = (void *)__entry->daddr; \
v6->sin6_family = AF_INET6; \
v6->sin6_port = protoh->dest; \
v6->sin6_addr = ipv6_hdr(skb)->daddr; \
} else \
TP_STORE_ADDR_PORTS_SKB_V4(__entry, skb, protoh); \
} while (0)
#else
#define TP_STORE_ADDR_PORTS_SKB(__entry, skb, protoh) \
TP_STORE_ADDR_PORTS_SKB_V4(__entry, skb, protoh)
#endif
#endif
+2 -43
View File
@@ -273,48 +273,6 @@ TRACE_EVENT(tcp_probe,
__entry->skbaddr, __entry->skaddr)
);
#define TP_STORE_ADDR_PORTS_SKB_V4(__entry, skb) \
do { \
const struct tcphdr *th = (const struct tcphdr *)skb->data; \
struct sockaddr_in *v4 = (void *)__entry->saddr; \
\
v4->sin_family = AF_INET; \
v4->sin_port = th->source; \
v4->sin_addr.s_addr = ip_hdr(skb)->saddr; \
v4 = (void *)__entry->daddr; \
v4->sin_family = AF_INET; \
v4->sin_port = th->dest; \
v4->sin_addr.s_addr = ip_hdr(skb)->daddr; \
} while (0)
#if IS_ENABLED(CONFIG_IPV6)
#define TP_STORE_ADDR_PORTS_SKB(__entry, skb) \
do { \
const struct iphdr *iph = ip_hdr(skb); \
\
if (iph->version == 6) { \
const struct tcphdr *th = (const struct tcphdr *)skb->data; \
struct sockaddr_in6 *v6 = (void *)__entry->saddr; \
\
v6->sin6_family = AF_INET6; \
v6->sin6_port = th->source; \
v6->sin6_addr = ipv6_hdr(skb)->saddr; \
v6 = (void *)__entry->daddr; \
v6->sin6_family = AF_INET6; \
v6->sin6_port = th->dest; \
v6->sin6_addr = ipv6_hdr(skb)->daddr; \
} else \
TP_STORE_ADDR_PORTS_SKB_V4(__entry, skb); \
} while (0)
#else
#define TP_STORE_ADDR_PORTS_SKB(__entry, skb) \
TP_STORE_ADDR_PORTS_SKB_V4(__entry, skb)
#endif
/*
* tcp event with only skb
*/
@@ -331,12 +289,13 @@ DECLARE_EVENT_CLASS(tcp_event_skb,
),
TP_fast_assign(
const struct tcphdr *th = (const struct tcphdr *)skb->data;
__entry->skbaddr = skb;
memset(__entry->saddr, 0, sizeof(struct sockaddr_in6));
memset(__entry->daddr, 0, sizeof(struct sockaddr_in6));
TP_STORE_ADDR_PORTS_SKB(__entry, skb);
TP_STORE_ADDR_PORTS_SKB(__entry, skb, th);
),
TP_printk("skbaddr=%p src=%pISpc dest=%pISpc",
+24 -5
View File
@@ -7,24 +7,43 @@
#include <linux/udp.h>
#include <linux/tracepoint.h>
#include <trace/events/net_probe_common.h>
TRACE_EVENT(udp_fail_queue_rcv_skb,
TP_PROTO(int rc, struct sock *sk),
TP_PROTO(int rc, struct sock *sk, struct sk_buff *skb),
TP_ARGS(rc, sk),
TP_ARGS(rc, sk, skb),
TP_STRUCT__entry(
__field(int, rc)
__field(__u16, lport)
__field(__u16, sport)
__field(__u16, dport)
__field(__u16, family)
__array(__u8, saddr, sizeof(struct sockaddr_in6))
__array(__u8, daddr, sizeof(struct sockaddr_in6))
),
TP_fast_assign(
const struct udphdr *uh = (const struct udphdr *)udp_hdr(skb);
__entry->rc = rc;
__entry->lport = inet_sk(sk)->inet_num;
/* for filtering use */
__entry->sport = ntohs(uh->source);
__entry->dport = ntohs(uh->dest);
__entry->family = sk->sk_family;
memset(__entry->saddr, 0, sizeof(struct sockaddr_in6));
memset(__entry->daddr, 0, sizeof(struct sockaddr_in6));
TP_STORE_ADDR_PORTS_SKB(__entry, skb, uh);
),
TP_printk("rc=%d port=%hu", __entry->rc, __entry->lport)
TP_printk("rc=%d family=%s src=%pISpc dest=%pISpc", __entry->rc,
show_family_name(__entry->family),
__entry->saddr, __entry->daddr)
);
#endif /* _TRACE_UDP_H */
+3 -3
View File
@@ -314,7 +314,7 @@ static void devlink_release(struct work_struct *work)
mutex_destroy(&devlink->lock);
lockdep_unregister_key(&devlink->lock_key);
put_device(devlink->dev);
kfree(devlink);
kvfree(devlink);
}
void devlink_put(struct devlink *devlink)
@@ -420,7 +420,7 @@ struct devlink *devlink_alloc_ns(const struct devlink_ops *ops,
if (!devlink_reload_actions_valid(ops))
return NULL;
devlink = kzalloc(sizeof(*devlink) + priv_size, GFP_KERNEL);
devlink = kvzalloc(struct_size(devlink, priv, priv_size), GFP_KERNEL);
if (!devlink)
return NULL;
@@ -455,7 +455,7 @@ struct devlink *devlink_alloc_ns(const struct devlink_ops *ops,
return devlink;
err_xa_alloc:
kfree(devlink);
kvfree(devlink);
return NULL;
}
EXPORT_SYMBOL_GPL(devlink_alloc_ns);
+1 -1
View File
@@ -2058,8 +2058,8 @@ static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
drop_reason = SKB_DROP_REASON_PROTO_MEM;
}
UDP_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
trace_udp_fail_queue_rcv_skb(rc, sk, skb);
kfree_skb_reason(skb, drop_reason);
trace_udp_fail_queue_rcv_skb(rc, sk);
return -1;
}
+2 -1
View File
@@ -34,6 +34,7 @@
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/indirect_call_wrapper.h>
#include <trace/events/udp.h>
#include <net/addrconf.h>
#include <net/ndisc.h>
@@ -659,8 +660,8 @@ static int __udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
drop_reason = SKB_DROP_REASON_PROTO_MEM;
}
UDP6_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
trace_udp_fail_queue_rcv_skb(rc, sk, skb);
kfree_skb_reason(skb, drop_reason);
trace_udp_fail_queue_rcv_skb(rc, sk);
return -1;
}
+46
View File
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
from collections import namedtuple
from enum import Enum
import functools
import os
import random
@@ -76,6 +77,25 @@ class Netlink:
NLMSGERR_ATTR_MISS_TYPE = 5
NLMSGERR_ATTR_MISS_NEST = 6
# Policy types
NL_POLICY_TYPE_ATTR_TYPE = 1
NL_POLICY_TYPE_ATTR_MIN_VALUE_S = 2
NL_POLICY_TYPE_ATTR_MAX_VALUE_S = 3
NL_POLICY_TYPE_ATTR_MIN_VALUE_U = 4
NL_POLICY_TYPE_ATTR_MAX_VALUE_U = 5
NL_POLICY_TYPE_ATTR_MIN_LENGTH = 6
NL_POLICY_TYPE_ATTR_MAX_LENGTH = 7
NL_POLICY_TYPE_ATTR_POLICY_IDX = 8
NL_POLICY_TYPE_ATTR_POLICY_MAXTYPE = 9
NL_POLICY_TYPE_ATTR_BITFIELD32_MASK = 10
NL_POLICY_TYPE_ATTR_PAD = 11
NL_POLICY_TYPE_ATTR_MASK = 12
AttrType = Enum('AttrType', ['flag', 'u8', 'u16', 'u32', 'u64',
's8', 's16', 's32', 's64',
'binary', 'string', 'nul-string',
'nested', 'nested-array',
'bitfield32', 'sint', 'uint'])
class NlError(Exception):
def __init__(self, nl_msg):
@@ -199,6 +219,8 @@ class NlMsg:
self.extack['miss-nest'] = extack.as_scalar('u32')
elif extack.type == Netlink.NLMSGERR_ATTR_OFFS:
self.extack['bad-attr-offs'] = extack.as_scalar('u32')
elif extack.type == Netlink.NLMSGERR_ATTR_POLICY:
self.extack['policy'] = self._decode_policy(extack.raw)
else:
if 'unknown' not in self.extack:
self.extack['unknown'] = []
@@ -215,6 +237,30 @@ class NlMsg:
desc += f" ({spec['doc']})"
self.extack['miss-type'] = desc
def _decode_policy(self, raw):
policy = {}
for attr in NlAttrs(raw):
if attr.type == Netlink.NL_POLICY_TYPE_ATTR_TYPE:
type = attr.as_scalar('u32')
policy['type'] = Netlink.AttrType(type).name
elif attr.type == Netlink.NL_POLICY_TYPE_ATTR_MIN_VALUE_S:
policy['min-value'] = attr.as_scalar('s64')
elif attr.type == Netlink.NL_POLICY_TYPE_ATTR_MAX_VALUE_S:
policy['max-value'] = attr.as_scalar('s64')
elif attr.type == Netlink.NL_POLICY_TYPE_ATTR_MIN_VALUE_U:
policy['min-value'] = attr.as_scalar('u64')
elif attr.type == Netlink.NL_POLICY_TYPE_ATTR_MAX_VALUE_U:
policy['max-value'] = attr.as_scalar('u64')
elif attr.type == Netlink.NL_POLICY_TYPE_ATTR_MIN_LENGTH:
policy['min-length'] = attr.as_scalar('u32')
elif attr.type == Netlink.NL_POLICY_TYPE_ATTR_MAX_LENGTH:
policy['max-length'] = attr.as_scalar('u32')
elif attr.type == Netlink.NL_POLICY_TYPE_ATTR_BITFIELD32_MASK:
policy['bitfield32-mask'] = attr.as_scalar('u32')
elif attr.type == Netlink.NL_POLICY_TYPE_ATTR_MASK:
policy['mask'] = attr.as_scalar('u64')
return policy
def cmd(self):
return self.nl_type