Fixes from the main networking tree only.
Current release - regressions: - fix unwanted sign extension in netdev_stats_to_stats64() Current release - new code bugs: - initialize net->notrefcnt_tracker earlier - devlink: fix netdev notifier chain corruption - nfp: make sure mbox accesses in IPsec code are atomic - ice: fix check for weight and priority of a scheduling node Previous releases - regressions: - ice: xsk: fix cleaning of XDP_TX frame, prevent inf loop - igb: fix I2C bit banging config with external thermal sensor Previous releases - always broken: - sched: tcindex: update imperfect hash filters respecting rcu - mpls: fix stale pointer if allocation fails during device rename - dccp/tcp: avoid negative sk_forward_alloc by ipv6_pinfo.pktoptions - remove WARN_ON_ONCE(sk->sk_forward_alloc) from sk_stream_kill_queues() - af_key: fix heap information leak - ipv6: fix socket connection with DSCP (correct interpretation of the tclass field vs fib rule matching) - tipc: fix kernel warning when sending SYN message - vmxnet3: read RSS information from the correct descriptor (eop) Signed-off-by: Jakub Kicinski <kuba@kernel.org> -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEE6jPA+I1ugmIBA4hXMUZtbf5SIrsFAmPueVYACgkQMUZtbf5S IrudBg/9ENOTSK4LeUE0If6Mr/DBUje6OwUX29/prxJz+PfU+XTNZqFf9xfVC5tX FnRAf7SxC4d4hmaA7JdOTFMyyDyZqQP1t13s0FSWAa5VbW3pnrqOXTyxCc9g3cZk 7m2co3XTH/U0FnbAZ6uzaoz7/NU+7UHYMVo5bCwLgB6YB31JWIcyTYKdYzl+xBFX y0GNkLLDJOo6cSpA5VRDMit42XmIUk1C4uuMPN0M6Q2U2xnYg2nYqlSXvaW2Y9CN NZgCCTp3AcKNqTU4zpjR6eyHK0xNgSCT4WJlx2tbnErdEo6gf8/Kw0PbbYAe/euk hgZQ0I8JxujskJFuA7S4u+VaPG92ycAyKMZFIucwepKSqtAjjA+XxTs8jxyVJIwZ +jwHnayEomlgnel+q+hE+XkNg3OdengTaudWn3vO2EtJrWyZh3nVP2krgxFlh8vY qwSqhSiXi+sjxspYgeIyyu2XGfWdY1sKNRgkGqisTyfBIMRK/jRhas5kyKOAOiYo 32xuvXzVouxXipVZhE5RVoR1VpeKl6OXlCIVVDvT6el2Y5bkbEmkCgEyIPfv1xBX 17C9a1IhvTfHU8uJ11Mbi7jxRCC3ELi7JHNdht0/WZtdVNppcwALuK+xGjHwR67H VWwWKO/M/ggd2OF1jW9eLzcJIixxCJjpu+VJFImd8aIUUw0LKy8= =r2l1 -----END PGP SIGNATURE----- Merge tag 'net-6.2-final' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net Pull networking fixes from Jakub Kicinski: "Fixes from the main networking tree only, probably because all sub-trees have backed off and haven't submitted their changes. None of the fixes here are particularly scary and no outstanding regressions. In an ideal world the "current release" sections would be empty at this stage but that never happens. Current release - regressions: - fix unwanted sign extension in netdev_stats_to_stats64() Current release - new code bugs: - initialize net->notrefcnt_tracker earlier - devlink: fix netdev notifier chain corruption - nfp: make sure mbox accesses in IPsec code are atomic - ice: fix check for weight and priority of a scheduling node Previous releases - regressions: - ice: xsk: fix cleaning of XDP_TX frame, prevent inf loop - igb: fix I2C bit banging config with external thermal sensor Previous releases - always broken: - sched: tcindex: update imperfect hash filters respecting rcu - mpls: fix stale pointer if allocation fails during device rename - dccp/tcp: avoid negative sk_forward_alloc by ipv6_pinfo.pktoptions - remove WARN_ON_ONCE(sk->sk_forward_alloc) from sk_stream_kill_queues() - af_key: fix heap information leak - ipv6: fix socket connection with DSCP (correct interpretation of the tclass field vs fib rule matching) - tipc: fix kernel warning when sending SYN message - vmxnet3: read RSS information from the correct descriptor (eop)" * tag 'net-6.2-final' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (35 commits) devlink: Fix netdev notifier chain corruption igb: conditionalize I2C bit banging on external thermal sensor support net: mpls: fix stale pointer if allocation fails during device rename net/sched: tcindex: search key must be 16 bits tipc: fix kernel warning when sending SYN message igb: Fix PPS input and output using 3rd and 4th SDP net: use a bounce buffer for copying skb->mark ixgbe: add double of VLAN header when computing the max MTU i40e: add double of VLAN header when computing the max MTU ixgbe: allow to increase MTU to 3K with XDP enabled net: stmmac: Restrict warning on disabling DMA store and fwd mode net/sched: act_ctinfo: use percpu stats net: stmmac: fix order of dwmac5 FlexPPS parametrization sequence ice: fix lost multicast packets in promisc mode ice: Fix check for weight and priority of a scheduling node bnxt_en: Fix mqprio and XDP ring checking logic net: Fix unwanted sign extension in netdev_stats_to_stats64() net/usb: kalmia: Don't pass act_len in usb_bulk_msg error path net: openvswitch: fix possible memory leak in ovs_meter_cmd_set() af_key: Fix heap information leak ...
This commit is contained in:
commit
3ac88fa460
|
@ -240,12 +240,12 @@ static int bgmac_probe(struct bcma_device *core)
|
|||
bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
|
||||
bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1;
|
||||
bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY;
|
||||
if (ci->pkg == BCMA_PKG_ID_BCM47188 ||
|
||||
ci->pkg == BCMA_PKG_ID_BCM47186) {
|
||||
if ((ci->id == BCMA_CHIP_ID_BCM5357 && ci->pkg == BCMA_PKG_ID_BCM47186) ||
|
||||
(ci->id == BCMA_CHIP_ID_BCM53572 && ci->pkg == BCMA_PKG_ID_BCM47188)) {
|
||||
bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII;
|
||||
bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
|
||||
}
|
||||
if (ci->pkg == BCMA_PKG_ID_BCM5358)
|
||||
if (ci->id == BCMA_CHIP_ID_BCM5357 && ci->pkg == BCMA_PKG_ID_BCM5358)
|
||||
bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_EPHYRMII;
|
||||
break;
|
||||
case BCMA_CHIP_ID_BCM53573:
|
||||
|
|
|
@ -9274,10 +9274,14 @@ int bnxt_reserve_rings(struct bnxt *bp, bool irq_re_init)
|
|||
netdev_err(bp->dev, "ring reservation/IRQ init failure rc: %d\n", rc);
|
||||
return rc;
|
||||
}
|
||||
if (tcs && (bp->tx_nr_rings_per_tc * tcs != bp->tx_nr_rings)) {
|
||||
if (tcs && (bp->tx_nr_rings_per_tc * tcs !=
|
||||
bp->tx_nr_rings - bp->tx_nr_rings_xdp)) {
|
||||
netdev_err(bp->dev, "tx ring reservation failure\n");
|
||||
netdev_reset_tc(bp->dev);
|
||||
bp->tx_nr_rings_per_tc = bp->tx_nr_rings;
|
||||
if (bp->tx_nr_rings_xdp)
|
||||
bp->tx_nr_rings_per_tc = bp->tx_nr_rings_xdp;
|
||||
else
|
||||
bp->tx_nr_rings_per_tc = bp->tx_nr_rings;
|
||||
return -ENOMEM;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -2921,7 +2921,7 @@ static int i40e_change_mtu(struct net_device *netdev, int new_mtu)
|
|||
struct i40e_pf *pf = vsi->back;
|
||||
|
||||
if (i40e_enabled_xdp_vsi(vsi)) {
|
||||
int frame_size = new_mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN;
|
||||
int frame_size = new_mtu + I40E_PACKET_HDR_PAD;
|
||||
|
||||
if (frame_size > i40e_max_xdp_frame_size(vsi))
|
||||
return -EINVAL;
|
||||
|
@ -13167,6 +13167,8 @@ static int i40e_ndo_bridge_setlink(struct net_device *dev,
|
|||
}
|
||||
|
||||
br_spec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC);
|
||||
if (!br_spec)
|
||||
return -EINVAL;
|
||||
|
||||
nla_for_each_nested(attr, br_spec, rem) {
|
||||
__u16 mode;
|
||||
|
|
|
@ -899,7 +899,7 @@ static int ice_set_object_tx_priority(struct ice_port_info *pi, struct ice_sched
|
|||
{
|
||||
int status;
|
||||
|
||||
if (node->tx_priority >= 8) {
|
||||
if (priority >= 8) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "Priority should be less than 8");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -929,7 +929,7 @@ static int ice_set_object_tx_weight(struct ice_port_info *pi, struct ice_sched_n
|
|||
{
|
||||
int status;
|
||||
|
||||
if (node->tx_weight > 200 || node->tx_weight < 1) {
|
||||
if (weight > 200 || weight < 1) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "Weight must be between 1 and 200");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
@ -275,6 +275,8 @@ static int ice_set_promisc(struct ice_vsi *vsi, u8 promisc_m)
|
|||
if (status && status != -EEXIST)
|
||||
return status;
|
||||
|
||||
netdev_dbg(vsi->netdev, "set promisc filter bits for VSI %i: 0x%x\n",
|
||||
vsi->vsi_num, promisc_m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -300,6 +302,8 @@ static int ice_clear_promisc(struct ice_vsi *vsi, u8 promisc_m)
|
|||
promisc_m, 0);
|
||||
}
|
||||
|
||||
netdev_dbg(vsi->netdev, "clear promisc filter bits for VSI %i: 0x%x\n",
|
||||
vsi->vsi_num, promisc_m);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -414,6 +418,16 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi)
|
|||
}
|
||||
err = 0;
|
||||
vlan_ops->dis_rx_filtering(vsi);
|
||||
|
||||
/* promiscuous mode implies allmulticast so
|
||||
* that VSIs that are in promiscuous mode are
|
||||
* subscribed to multicast packets coming to
|
||||
* the port
|
||||
*/
|
||||
err = ice_set_promisc(vsi,
|
||||
ICE_MCAST_PROMISC_BITS);
|
||||
if (err)
|
||||
goto out_promisc;
|
||||
}
|
||||
} else {
|
||||
/* Clear Rx filter to remove traffic from wire */
|
||||
|
@ -430,6 +444,18 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi)
|
|||
NETIF_F_HW_VLAN_CTAG_FILTER)
|
||||
vlan_ops->ena_rx_filtering(vsi);
|
||||
}
|
||||
|
||||
/* disable allmulti here, but only if allmulti is not
|
||||
* still enabled for the netdev
|
||||
*/
|
||||
if (!(vsi->current_netdev_flags & IFF_ALLMULTI)) {
|
||||
err = ice_clear_promisc(vsi,
|
||||
ICE_MCAST_PROMISC_BITS);
|
||||
if (err) {
|
||||
netdev_err(netdev, "Error %d clearing multicast promiscuous on VSI %i\n",
|
||||
err, vsi->vsi_num);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
goto exit;
|
||||
|
|
|
@ -800,6 +800,7 @@ static void ice_clean_xdp_irq_zc(struct ice_tx_ring *xdp_ring)
|
|||
struct ice_tx_desc *tx_desc;
|
||||
u16 cnt = xdp_ring->count;
|
||||
struct ice_tx_buf *tx_buf;
|
||||
u16 completed_frames = 0;
|
||||
u16 xsk_frames = 0;
|
||||
u16 last_rs;
|
||||
int i;
|
||||
|
@ -809,19 +810,21 @@ static void ice_clean_xdp_irq_zc(struct ice_tx_ring *xdp_ring)
|
|||
if ((tx_desc->cmd_type_offset_bsz &
|
||||
cpu_to_le64(ICE_TX_DESC_DTYPE_DESC_DONE))) {
|
||||
if (last_rs >= ntc)
|
||||
xsk_frames = last_rs - ntc + 1;
|
||||
completed_frames = last_rs - ntc + 1;
|
||||
else
|
||||
xsk_frames = last_rs + cnt - ntc + 1;
|
||||
completed_frames = last_rs + cnt - ntc + 1;
|
||||
}
|
||||
|
||||
if (!xsk_frames)
|
||||
if (!completed_frames)
|
||||
return;
|
||||
|
||||
if (likely(!xdp_ring->xdp_tx_active))
|
||||
if (likely(!xdp_ring->xdp_tx_active)) {
|
||||
xsk_frames = completed_frames;
|
||||
goto skip;
|
||||
}
|
||||
|
||||
ntc = xdp_ring->next_to_clean;
|
||||
for (i = 0; i < xsk_frames; i++) {
|
||||
for (i = 0; i < completed_frames; i++) {
|
||||
tx_buf = &xdp_ring->tx_buf[ntc];
|
||||
|
||||
if (tx_buf->raw_buf) {
|
||||
|
@ -837,7 +840,7 @@ static void ice_clean_xdp_irq_zc(struct ice_tx_ring *xdp_ring)
|
|||
}
|
||||
skip:
|
||||
tx_desc->cmd_type_offset_bsz = 0;
|
||||
xdp_ring->next_to_clean += xsk_frames;
|
||||
xdp_ring->next_to_clean += completed_frames;
|
||||
if (xdp_ring->next_to_clean >= cnt)
|
||||
xdp_ring->next_to_clean -= cnt;
|
||||
if (xsk_frames)
|
||||
|
|
|
@ -2256,6 +2256,30 @@ static void igb_enable_mas(struct igb_adapter *adapter)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_IGB_HWMON
|
||||
/**
|
||||
* igb_set_i2c_bb - Init I2C interface
|
||||
* @hw: pointer to hardware structure
|
||||
**/
|
||||
static void igb_set_i2c_bb(struct e1000_hw *hw)
|
||||
{
|
||||
u32 ctrl_ext;
|
||||
s32 i2cctl;
|
||||
|
||||
ctrl_ext = rd32(E1000_CTRL_EXT);
|
||||
ctrl_ext |= E1000_CTRL_I2C_ENA;
|
||||
wr32(E1000_CTRL_EXT, ctrl_ext);
|
||||
wrfl();
|
||||
|
||||
i2cctl = rd32(E1000_I2CPARAMS);
|
||||
i2cctl |= E1000_I2CBB_EN
|
||||
| E1000_I2C_CLK_OE_N
|
||||
| E1000_I2C_DATA_OE_N;
|
||||
wr32(E1000_I2CPARAMS, i2cctl);
|
||||
wrfl();
|
||||
}
|
||||
#endif
|
||||
|
||||
void igb_reset(struct igb_adapter *adapter)
|
||||
{
|
||||
struct pci_dev *pdev = adapter->pdev;
|
||||
|
@ -2400,7 +2424,8 @@ void igb_reset(struct igb_adapter *adapter)
|
|||
* interface.
|
||||
*/
|
||||
if (adapter->ets)
|
||||
mac->ops.init_thermal_sensor_thresh(hw);
|
||||
igb_set_i2c_bb(hw);
|
||||
mac->ops.init_thermal_sensor_thresh(hw);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -3117,21 +3142,12 @@ static void igb_init_mas(struct igb_adapter *adapter)
|
|||
**/
|
||||
static s32 igb_init_i2c(struct igb_adapter *adapter)
|
||||
{
|
||||
struct e1000_hw *hw = &adapter->hw;
|
||||
s32 status = 0;
|
||||
s32 i2cctl;
|
||||
|
||||
/* I2C interface supported on i350 devices */
|
||||
if (adapter->hw.mac.type != e1000_i350)
|
||||
return 0;
|
||||
|
||||
i2cctl = rd32(E1000_I2CPARAMS);
|
||||
i2cctl |= E1000_I2CBB_EN
|
||||
| E1000_I2C_CLK_OUT | E1000_I2C_CLK_OE_N
|
||||
| E1000_I2C_DATA_OUT | E1000_I2C_DATA_OE_N;
|
||||
wr32(E1000_I2CPARAMS, i2cctl);
|
||||
wrfl();
|
||||
|
||||
/* Initialize the i2c bus which is controlled by the registers.
|
||||
* This bus will use the i2c_algo_bit structure that implements
|
||||
* the protocol through toggling of the 4 bits in the register.
|
||||
|
@ -3521,6 +3537,12 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||
adapter->ets = true;
|
||||
else
|
||||
adapter->ets = false;
|
||||
/* Only enable I2C bit banging if an external thermal
|
||||
* sensor is supported.
|
||||
*/
|
||||
if (adapter->ets)
|
||||
igb_set_i2c_bb(hw);
|
||||
hw->mac.ops.init_thermal_sensor_thresh(hw);
|
||||
if (igb_sysfs_init(adapter))
|
||||
dev_err(&pdev->dev,
|
||||
"failed to allocate sysfs resources\n");
|
||||
|
@ -6794,7 +6816,7 @@ static void igb_perout(struct igb_adapter *adapter, int tsintr_tt)
|
|||
struct timespec64 ts;
|
||||
u32 tsauxc;
|
||||
|
||||
if (pin < 0 || pin >= IGB_N_PEROUT)
|
||||
if (pin < 0 || pin >= IGB_N_SDP)
|
||||
return;
|
||||
|
||||
spin_lock(&adapter->tmreg_lock);
|
||||
|
@ -6802,7 +6824,7 @@ static void igb_perout(struct igb_adapter *adapter, int tsintr_tt)
|
|||
if (hw->mac.type == e1000_82580 ||
|
||||
hw->mac.type == e1000_i354 ||
|
||||
hw->mac.type == e1000_i350) {
|
||||
s64 ns = timespec64_to_ns(&adapter->perout[pin].period);
|
||||
s64 ns = timespec64_to_ns(&adapter->perout[tsintr_tt].period);
|
||||
u32 systiml, systimh, level_mask, level, rem;
|
||||
u64 systim, now;
|
||||
|
||||
|
@ -6850,8 +6872,8 @@ static void igb_perout(struct igb_adapter *adapter, int tsintr_tt)
|
|||
ts.tv_nsec = (u32)systim;
|
||||
ts.tv_sec = ((u32)(systim >> 32)) & 0xFF;
|
||||
} else {
|
||||
ts = timespec64_add(adapter->perout[pin].start,
|
||||
adapter->perout[pin].period);
|
||||
ts = timespec64_add(adapter->perout[tsintr_tt].start,
|
||||
adapter->perout[tsintr_tt].period);
|
||||
}
|
||||
|
||||
/* u32 conversion of tv_sec is safe until y2106 */
|
||||
|
@ -6860,7 +6882,7 @@ static void igb_perout(struct igb_adapter *adapter, int tsintr_tt)
|
|||
tsauxc = rd32(E1000_TSAUXC);
|
||||
tsauxc |= TSAUXC_EN_TT0;
|
||||
wr32(E1000_TSAUXC, tsauxc);
|
||||
adapter->perout[pin].start = ts;
|
||||
adapter->perout[tsintr_tt].start = ts;
|
||||
|
||||
spin_unlock(&adapter->tmreg_lock);
|
||||
}
|
||||
|
@ -6874,7 +6896,7 @@ static void igb_extts(struct igb_adapter *adapter, int tsintr_tt)
|
|||
struct ptp_clock_event event;
|
||||
struct timespec64 ts;
|
||||
|
||||
if (pin < 0 || pin >= IGB_N_EXTTS)
|
||||
if (pin < 0 || pin >= IGB_N_SDP)
|
||||
return;
|
||||
|
||||
if (hw->mac.type == e1000_82580 ||
|
||||
|
|
|
@ -73,6 +73,8 @@
|
|||
#define IXGBE_RXBUFFER_4K 4096
|
||||
#define IXGBE_MAX_RXBUFFER 16384 /* largest size for a single descriptor */
|
||||
|
||||
#define IXGBE_PKT_HDR_PAD (ETH_HLEN + ETH_FCS_LEN + (VLAN_HLEN * 2))
|
||||
|
||||
/* Attempt to maximize the headroom available for incoming frames. We
|
||||
* use a 2K buffer for receives and need 1536/1534 to store the data for
|
||||
* the frame. This leaves us with 512 bytes of room. From that we need
|
||||
|
|
|
@ -6777,6 +6777,18 @@ static void ixgbe_free_all_rx_resources(struct ixgbe_adapter *adapter)
|
|||
ixgbe_free_rx_resources(adapter->rx_ring[i]);
|
||||
}
|
||||
|
||||
/**
|
||||
* ixgbe_max_xdp_frame_size - returns the maximum allowed frame size for XDP
|
||||
* @adapter: device handle, pointer to adapter
|
||||
*/
|
||||
static int ixgbe_max_xdp_frame_size(struct ixgbe_adapter *adapter)
|
||||
{
|
||||
if (PAGE_SIZE >= 8192 || adapter->flags2 & IXGBE_FLAG2_RX_LEGACY)
|
||||
return IXGBE_RXBUFFER_2K;
|
||||
else
|
||||
return IXGBE_RXBUFFER_3K;
|
||||
}
|
||||
|
||||
/**
|
||||
* ixgbe_change_mtu - Change the Maximum Transfer Unit
|
||||
* @netdev: network interface device structure
|
||||
|
@ -6788,18 +6800,12 @@ static int ixgbe_change_mtu(struct net_device *netdev, int new_mtu)
|
|||
{
|
||||
struct ixgbe_adapter *adapter = netdev_priv(netdev);
|
||||
|
||||
if (adapter->xdp_prog) {
|
||||
int new_frame_size = new_mtu + ETH_HLEN + ETH_FCS_LEN +
|
||||
VLAN_HLEN;
|
||||
int i;
|
||||
if (ixgbe_enabled_xdp_adapter(adapter)) {
|
||||
int new_frame_size = new_mtu + IXGBE_PKT_HDR_PAD;
|
||||
|
||||
for (i = 0; i < adapter->num_rx_queues; i++) {
|
||||
struct ixgbe_ring *ring = adapter->rx_ring[i];
|
||||
|
||||
if (new_frame_size > ixgbe_rx_bufsz(ring)) {
|
||||
e_warn(probe, "Requested MTU size is not supported with XDP\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (new_frame_size > ixgbe_max_xdp_frame_size(adapter)) {
|
||||
e_warn(probe, "Requested MTU size is not supported with XDP\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -129,26 +129,31 @@ struct nfp_ipsec_cfg_mssg {
|
|||
};
|
||||
};
|
||||
|
||||
static int nfp_ipsec_cfg_cmd_issue(struct nfp_net *nn, int type, int saidx,
|
||||
struct nfp_ipsec_cfg_mssg *msg)
|
||||
static int nfp_net_ipsec_cfg(struct nfp_net *nn, struct nfp_mbox_amsg_entry *entry)
|
||||
{
|
||||
unsigned int offset = nn->tlv_caps.mbox_off + NFP_NET_CFG_MBOX_SIMPLE_VAL;
|
||||
struct nfp_ipsec_cfg_mssg *msg = (struct nfp_ipsec_cfg_mssg *)entry->msg;
|
||||
int i, msg_size, ret;
|
||||
|
||||
msg->cmd = type;
|
||||
msg->sa_idx = saidx;
|
||||
msg->rsp = 0;
|
||||
msg_size = ARRAY_SIZE(msg->raw);
|
||||
|
||||
for (i = 0; i < msg_size; i++)
|
||||
nn_writel(nn, NFP_NET_CFG_MBOX_VAL + 4 * i, msg->raw[i]);
|
||||
|
||||
ret = nfp_net_mbox_reconfig(nn, NFP_NET_CFG_MBOX_CMD_IPSEC);
|
||||
if (ret < 0)
|
||||
ret = nfp_net_mbox_lock(nn, sizeof(*msg));
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
msg_size = ARRAY_SIZE(msg->raw);
|
||||
for (i = 0; i < msg_size; i++)
|
||||
nn_writel(nn, offset + 4 * i, msg->raw[i]);
|
||||
|
||||
ret = nfp_net_mbox_reconfig(nn, entry->cmd);
|
||||
if (ret < 0) {
|
||||
nn_ctrl_bar_unlock(nn);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* For now we always read the whole message response back */
|
||||
for (i = 0; i < msg_size; i++)
|
||||
msg->raw[i] = nn_readl(nn, NFP_NET_CFG_MBOX_VAL + 4 * i);
|
||||
msg->raw[i] = nn_readl(nn, offset + 4 * i);
|
||||
|
||||
nn_ctrl_bar_unlock(nn);
|
||||
|
||||
switch (msg->rsp) {
|
||||
case NFP_IPSEC_CFG_MSSG_OK:
|
||||
|
@ -477,7 +482,10 @@ static int nfp_net_xfrm_add_state(struct xfrm_state *x)
|
|||
}
|
||||
|
||||
/* Allocate saidx and commit the SA */
|
||||
err = nfp_ipsec_cfg_cmd_issue(nn, NFP_IPSEC_CFG_MSSG_ADD_SA, saidx, &msg);
|
||||
msg.cmd = NFP_IPSEC_CFG_MSSG_ADD_SA;
|
||||
msg.sa_idx = saidx;
|
||||
err = nfp_net_sched_mbox_amsg_work(nn, NFP_NET_CFG_MBOX_CMD_IPSEC, &msg,
|
||||
sizeof(msg), nfp_net_ipsec_cfg);
|
||||
if (err) {
|
||||
xa_erase(&nn->xa_ipsec, saidx);
|
||||
nn_err(nn, "Failed to issue IPsec command err ret=%d\n", err);
|
||||
|
@ -491,14 +499,17 @@ static int nfp_net_xfrm_add_state(struct xfrm_state *x)
|
|||
|
||||
static void nfp_net_xfrm_del_state(struct xfrm_state *x)
|
||||
{
|
||||
struct nfp_ipsec_cfg_mssg msg = {
|
||||
.cmd = NFP_IPSEC_CFG_MSSG_INV_SA,
|
||||
.sa_idx = x->xso.offload_handle - 1,
|
||||
};
|
||||
struct net_device *netdev = x->xso.dev;
|
||||
struct nfp_ipsec_cfg_mssg msg;
|
||||
struct nfp_net *nn;
|
||||
int err;
|
||||
|
||||
nn = netdev_priv(netdev);
|
||||
err = nfp_ipsec_cfg_cmd_issue(nn, NFP_IPSEC_CFG_MSSG_INV_SA,
|
||||
x->xso.offload_handle - 1, &msg);
|
||||
err = nfp_net_sched_mbox_amsg_work(nn, NFP_NET_CFG_MBOX_CMD_IPSEC, &msg,
|
||||
sizeof(msg), nfp_net_ipsec_cfg);
|
||||
if (err)
|
||||
nn_warn(nn, "Failed to invalidate SA in hardware\n");
|
||||
|
||||
|
|
|
@ -617,9 +617,10 @@ struct nfp_net_dp {
|
|||
* @vnic_no_name: For non-port PF vNIC make ndo_get_phys_port_name return
|
||||
* -EOPNOTSUPP to keep backwards compatibility (set by app)
|
||||
* @port: Pointer to nfp_port structure if vNIC is a port
|
||||
* @mc_lock: Protect mc_addrs list
|
||||
* @mc_addrs: List of mc addrs to add/del to HW
|
||||
* @mc_work: Work to update mc addrs
|
||||
* @mbox_amsg: Asynchronously processed message via mailbox
|
||||
* @mbox_amsg.lock: Protect message list
|
||||
* @mbox_amsg.list: List of message to process
|
||||
* @mbox_amsg.work: Work to process message asynchronously
|
||||
* @app_priv: APP private data for this vNIC
|
||||
*/
|
||||
struct nfp_net {
|
||||
|
@ -721,13 +722,25 @@ struct nfp_net {
|
|||
|
||||
struct nfp_port *port;
|
||||
|
||||
spinlock_t mc_lock;
|
||||
struct list_head mc_addrs;
|
||||
struct work_struct mc_work;
|
||||
struct {
|
||||
spinlock_t lock;
|
||||
struct list_head list;
|
||||
struct work_struct work;
|
||||
} mbox_amsg;
|
||||
|
||||
void *app_priv;
|
||||
};
|
||||
|
||||
struct nfp_mbox_amsg_entry {
|
||||
struct list_head list;
|
||||
int (*cfg)(struct nfp_net *nn, struct nfp_mbox_amsg_entry *entry);
|
||||
u32 cmd;
|
||||
char msg[];
|
||||
};
|
||||
|
||||
int nfp_net_sched_mbox_amsg_work(struct nfp_net *nn, u32 cmd, const void *data, size_t len,
|
||||
int (*cb)(struct nfp_net *, struct nfp_mbox_amsg_entry *));
|
||||
|
||||
/* Functions to read/write from/to a BAR
|
||||
* Performs any endian conversion necessary.
|
||||
*/
|
||||
|
|
|
@ -1334,14 +1334,54 @@ err_unlock:
|
|||
return err;
|
||||
}
|
||||
|
||||
struct nfp_mc_addr_entry {
|
||||
u8 addr[ETH_ALEN];
|
||||
u32 cmd;
|
||||
struct list_head list;
|
||||
};
|
||||
|
||||
static int nfp_net_mc_cfg(struct nfp_net *nn, const unsigned char *addr, const u32 cmd)
|
||||
int nfp_net_sched_mbox_amsg_work(struct nfp_net *nn, u32 cmd, const void *data, size_t len,
|
||||
int (*cb)(struct nfp_net *, struct nfp_mbox_amsg_entry *))
|
||||
{
|
||||
struct nfp_mbox_amsg_entry *entry;
|
||||
|
||||
entry = kmalloc(sizeof(*entry) + len, GFP_ATOMIC);
|
||||
if (!entry)
|
||||
return -ENOMEM;
|
||||
|
||||
memcpy(entry->msg, data, len);
|
||||
entry->cmd = cmd;
|
||||
entry->cfg = cb;
|
||||
|
||||
spin_lock_bh(&nn->mbox_amsg.lock);
|
||||
list_add_tail(&entry->list, &nn->mbox_amsg.list);
|
||||
spin_unlock_bh(&nn->mbox_amsg.lock);
|
||||
|
||||
schedule_work(&nn->mbox_amsg.work);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void nfp_net_mbox_amsg_work(struct work_struct *work)
|
||||
{
|
||||
struct nfp_net *nn = container_of(work, struct nfp_net, mbox_amsg.work);
|
||||
struct nfp_mbox_amsg_entry *entry, *tmp;
|
||||
struct list_head tmp_list;
|
||||
|
||||
INIT_LIST_HEAD(&tmp_list);
|
||||
|
||||
spin_lock_bh(&nn->mbox_amsg.lock);
|
||||
list_splice_init(&nn->mbox_amsg.list, &tmp_list);
|
||||
spin_unlock_bh(&nn->mbox_amsg.lock);
|
||||
|
||||
list_for_each_entry_safe(entry, tmp, &tmp_list, list) {
|
||||
int err = entry->cfg(nn, entry);
|
||||
|
||||
if (err)
|
||||
nn_err(nn, "Config cmd %d to HW failed %d.\n", entry->cmd, err);
|
||||
|
||||
list_del(&entry->list);
|
||||
kfree(entry);
|
||||
}
|
||||
}
|
||||
|
||||
static int nfp_net_mc_cfg(struct nfp_net *nn, struct nfp_mbox_amsg_entry *entry)
|
||||
{
|
||||
unsigned char *addr = entry->msg;
|
||||
int ret;
|
||||
|
||||
ret = nfp_net_mbox_lock(nn, NFP_NET_CFG_MULTICAST_SZ);
|
||||
|
@ -1353,26 +1393,7 @@ static int nfp_net_mc_cfg(struct nfp_net *nn, const unsigned char *addr, const u
|
|||
nn_writew(nn, nn->tlv_caps.mbox_off + NFP_NET_CFG_MULTICAST_MAC_LO,
|
||||
get_unaligned_be16(addr + 4));
|
||||
|
||||
return nfp_net_mbox_reconfig_and_unlock(nn, cmd);
|
||||
}
|
||||
|
||||
static int nfp_net_mc_prep(struct nfp_net *nn, const unsigned char *addr, const u32 cmd)
|
||||
{
|
||||
struct nfp_mc_addr_entry *entry;
|
||||
|
||||
entry = kmalloc(sizeof(*entry), GFP_ATOMIC);
|
||||
if (!entry)
|
||||
return -ENOMEM;
|
||||
|
||||
ether_addr_copy(entry->addr, addr);
|
||||
entry->cmd = cmd;
|
||||
spin_lock_bh(&nn->mc_lock);
|
||||
list_add_tail(&entry->list, &nn->mc_addrs);
|
||||
spin_unlock_bh(&nn->mc_lock);
|
||||
|
||||
schedule_work(&nn->mc_work);
|
||||
|
||||
return 0;
|
||||
return nfp_net_mbox_reconfig_and_unlock(nn, entry->cmd);
|
||||
}
|
||||
|
||||
static int nfp_net_mc_sync(struct net_device *netdev, const unsigned char *addr)
|
||||
|
@ -1385,35 +1406,16 @@ static int nfp_net_mc_sync(struct net_device *netdev, const unsigned char *addr)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
return nfp_net_mc_prep(nn, addr, NFP_NET_CFG_MBOX_CMD_MULTICAST_ADD);
|
||||
return nfp_net_sched_mbox_amsg_work(nn, NFP_NET_CFG_MBOX_CMD_MULTICAST_ADD, addr,
|
||||
NFP_NET_CFG_MULTICAST_SZ, nfp_net_mc_cfg);
|
||||
}
|
||||
|
||||
static int nfp_net_mc_unsync(struct net_device *netdev, const unsigned char *addr)
|
||||
{
|
||||
struct nfp_net *nn = netdev_priv(netdev);
|
||||
|
||||
return nfp_net_mc_prep(nn, addr, NFP_NET_CFG_MBOX_CMD_MULTICAST_DEL);
|
||||
}
|
||||
|
||||
static void nfp_net_mc_addr_config(struct work_struct *work)
|
||||
{
|
||||
struct nfp_net *nn = container_of(work, struct nfp_net, mc_work);
|
||||
struct nfp_mc_addr_entry *entry, *tmp;
|
||||
struct list_head tmp_list;
|
||||
|
||||
INIT_LIST_HEAD(&tmp_list);
|
||||
|
||||
spin_lock_bh(&nn->mc_lock);
|
||||
list_splice_init(&nn->mc_addrs, &tmp_list);
|
||||
spin_unlock_bh(&nn->mc_lock);
|
||||
|
||||
list_for_each_entry_safe(entry, tmp, &tmp_list, list) {
|
||||
if (nfp_net_mc_cfg(nn, entry->addr, entry->cmd))
|
||||
nn_err(nn, "Config mc address to HW failed.\n");
|
||||
|
||||
list_del(&entry->list);
|
||||
kfree(entry);
|
||||
}
|
||||
return nfp_net_sched_mbox_amsg_work(nn, NFP_NET_CFG_MBOX_CMD_MULTICAST_DEL, addr,
|
||||
NFP_NET_CFG_MULTICAST_SZ, nfp_net_mc_cfg);
|
||||
}
|
||||
|
||||
static void nfp_net_set_rx_mode(struct net_device *netdev)
|
||||
|
@ -2681,9 +2683,9 @@ int nfp_net_init(struct nfp_net *nn)
|
|||
if (!nn->dp.netdev)
|
||||
return 0;
|
||||
|
||||
spin_lock_init(&nn->mc_lock);
|
||||
INIT_LIST_HEAD(&nn->mc_addrs);
|
||||
INIT_WORK(&nn->mc_work, nfp_net_mc_addr_config);
|
||||
spin_lock_init(&nn->mbox_amsg.lock);
|
||||
INIT_LIST_HEAD(&nn->mbox_amsg.list);
|
||||
INIT_WORK(&nn->mbox_amsg.work, nfp_net_mbox_amsg_work);
|
||||
|
||||
return register_netdev(nn->dp.netdev);
|
||||
|
||||
|
@ -2704,6 +2706,6 @@ void nfp_net_clean(struct nfp_net *nn)
|
|||
unregister_netdev(nn->dp.netdev);
|
||||
nfp_net_ipsec_clean(nn);
|
||||
nfp_ccm_mbox_clean(nn);
|
||||
flush_work(&nn->mc_work);
|
||||
flush_work(&nn->mbox_amsg.work);
|
||||
nfp_net_reconfig_wait_posted(nn);
|
||||
}
|
||||
|
|
|
@ -403,7 +403,6 @@
|
|||
*/
|
||||
#define NFP_NET_CFG_MBOX_BASE 0x1800
|
||||
#define NFP_NET_CFG_MBOX_VAL_MAX_SZ 0x1F8
|
||||
#define NFP_NET_CFG_MBOX_VAL 0x1808
|
||||
#define NFP_NET_CFG_MBOX_SIMPLE_CMD 0x0
|
||||
#define NFP_NET_CFG_MBOX_SIMPLE_RET 0x4
|
||||
#define NFP_NET_CFG_MBOX_SIMPLE_VAL 0x8
|
||||
|
|
|
@ -541,9 +541,9 @@ int dwmac5_flex_pps_config(void __iomem *ioaddr, int index,
|
|||
return 0;
|
||||
}
|
||||
|
||||
val |= PPSCMDx(index, 0x2);
|
||||
val |= TRGTMODSELx(index, 0x2);
|
||||
val |= PPSEN0;
|
||||
writel(val, ioaddr + MAC_PPS_CONTROL);
|
||||
|
||||
writel(cfg->start.tv_sec, ioaddr + MAC_PPSx_TARGET_TIME_SEC(index));
|
||||
|
||||
|
@ -568,6 +568,7 @@ int dwmac5_flex_pps_config(void __iomem *ioaddr, int index,
|
|||
writel(period - 1, ioaddr + MAC_PPSx_WIDTH(index));
|
||||
|
||||
/* Finally, activate it */
|
||||
val |= PPSCMDx(index, 0x2);
|
||||
writel(val, ioaddr + MAC_PPS_CONTROL);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -559,7 +559,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac)
|
|||
dma_cfg->mixed_burst = of_property_read_bool(np, "snps,mixed-burst");
|
||||
|
||||
plat->force_thresh_dma_mode = of_property_read_bool(np, "snps,force_thresh_dma_mode");
|
||||
if (plat->force_thresh_dma_mode) {
|
||||
if (plat->force_thresh_dma_mode && plat->force_sf_dma_mode) {
|
||||
plat->force_sf_dma_mode = 0;
|
||||
dev_warn(&pdev->dev,
|
||||
"force_sf_dma_mode is ignored if force_thresh_dma_mode is set.\n");
|
||||
|
|
|
@ -501,7 +501,15 @@ static int am65_cpsw_nuss_common_stop(struct am65_cpsw_common *common)
|
|||
k3_udma_glue_disable_tx_chn(common->tx_chns[i].tx_chn);
|
||||
}
|
||||
|
||||
reinit_completion(&common->tdown_complete);
|
||||
k3_udma_glue_tdown_rx_chn(common->rx_chns.rx_chn, true);
|
||||
|
||||
if (common->pdata.quirks & AM64_CPSW_QUIRK_DMA_RX_TDOWN_IRQ) {
|
||||
i = wait_for_completion_timeout(&common->tdown_complete, msecs_to_jiffies(1000));
|
||||
if (!i)
|
||||
dev_err(common->dev, "rx teardown timeout\n");
|
||||
}
|
||||
|
||||
napi_disable(&common->napi_rx);
|
||||
|
||||
for (i = 0; i < AM65_CPSW_MAX_RX_FLOWS; i++)
|
||||
|
@ -721,6 +729,8 @@ static int am65_cpsw_nuss_rx_packets(struct am65_cpsw_common *common,
|
|||
|
||||
if (cppi5_desc_is_tdcm(desc_dma)) {
|
||||
dev_dbg(dev, "%s RX tdown flow: %u\n", __func__, flow_idx);
|
||||
if (common->pdata.quirks & AM64_CPSW_QUIRK_DMA_RX_TDOWN_IRQ)
|
||||
complete(&common->tdown_complete);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2672,7 +2682,7 @@ static const struct am65_cpsw_pdata j721e_pdata = {
|
|||
};
|
||||
|
||||
static const struct am65_cpsw_pdata am64x_cpswxg_pdata = {
|
||||
.quirks = 0,
|
||||
.quirks = AM64_CPSW_QUIRK_DMA_RX_TDOWN_IRQ,
|
||||
.ale_dev_id = "am64-cpswxg",
|
||||
.fdqring_mode = K3_RINGACC_RING_MODE_RING,
|
||||
};
|
||||
|
|
|
@ -90,6 +90,7 @@ struct am65_cpsw_rx_chn {
|
|||
};
|
||||
|
||||
#define AM65_CPSW_QUIRK_I2027_NO_TX_CSUM BIT(0)
|
||||
#define AM64_CPSW_QUIRK_DMA_RX_TDOWN_IRQ BIT(1)
|
||||
|
||||
struct am65_cpsw_pdata {
|
||||
u32 quirks;
|
||||
|
|
|
@ -65,8 +65,8 @@ kalmia_send_init_packet(struct usbnet *dev, u8 *init_msg, u8 init_msg_len,
|
|||
init_msg, init_msg_len, &act_len, KALMIA_USB_TIMEOUT);
|
||||
if (status != 0) {
|
||||
netdev_err(dev->net,
|
||||
"Error sending init packet. Status %i, length %i\n",
|
||||
status, act_len);
|
||||
"Error sending init packet. Status %i\n",
|
||||
status);
|
||||
return status;
|
||||
}
|
||||
else if (act_len != init_msg_len) {
|
||||
|
@ -83,8 +83,8 @@ kalmia_send_init_packet(struct usbnet *dev, u8 *init_msg, u8 init_msg_len,
|
|||
|
||||
if (status != 0)
|
||||
netdev_err(dev->net,
|
||||
"Error receiving init result. Status %i, length %i\n",
|
||||
status, act_len);
|
||||
"Error receiving init result. Status %i\n",
|
||||
status);
|
||||
else if (act_len != expected_len)
|
||||
netdev_err(dev->net, "Unexpected init result length: %i\n",
|
||||
act_len);
|
||||
|
|
|
@ -1546,31 +1546,6 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
|
|||
rxd->len = rbi->len;
|
||||
}
|
||||
|
||||
#ifdef VMXNET3_RSS
|
||||
if (rcd->rssType != VMXNET3_RCD_RSS_TYPE_NONE &&
|
||||
(adapter->netdev->features & NETIF_F_RXHASH)) {
|
||||
enum pkt_hash_types hash_type;
|
||||
|
||||
switch (rcd->rssType) {
|
||||
case VMXNET3_RCD_RSS_TYPE_IPV4:
|
||||
case VMXNET3_RCD_RSS_TYPE_IPV6:
|
||||
hash_type = PKT_HASH_TYPE_L3;
|
||||
break;
|
||||
case VMXNET3_RCD_RSS_TYPE_TCPIPV4:
|
||||
case VMXNET3_RCD_RSS_TYPE_TCPIPV6:
|
||||
case VMXNET3_RCD_RSS_TYPE_UDPIPV4:
|
||||
case VMXNET3_RCD_RSS_TYPE_UDPIPV6:
|
||||
hash_type = PKT_HASH_TYPE_L4;
|
||||
break;
|
||||
default:
|
||||
hash_type = PKT_HASH_TYPE_L3;
|
||||
break;
|
||||
}
|
||||
skb_set_hash(ctx->skb,
|
||||
le32_to_cpu(rcd->rssHash),
|
||||
hash_type);
|
||||
}
|
||||
#endif
|
||||
skb_record_rx_queue(ctx->skb, rq->qid);
|
||||
skb_put(ctx->skb, rcd->len);
|
||||
|
||||
|
@ -1653,6 +1628,31 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
|
|||
u32 mtu = adapter->netdev->mtu;
|
||||
skb->len += skb->data_len;
|
||||
|
||||
#ifdef VMXNET3_RSS
|
||||
if (rcd->rssType != VMXNET3_RCD_RSS_TYPE_NONE &&
|
||||
(adapter->netdev->features & NETIF_F_RXHASH)) {
|
||||
enum pkt_hash_types hash_type;
|
||||
|
||||
switch (rcd->rssType) {
|
||||
case VMXNET3_RCD_RSS_TYPE_IPV4:
|
||||
case VMXNET3_RCD_RSS_TYPE_IPV6:
|
||||
hash_type = PKT_HASH_TYPE_L3;
|
||||
break;
|
||||
case VMXNET3_RCD_RSS_TYPE_TCPIPV4:
|
||||
case VMXNET3_RCD_RSS_TYPE_TCPIPV6:
|
||||
case VMXNET3_RCD_RSS_TYPE_UDPIPV4:
|
||||
case VMXNET3_RCD_RSS_TYPE_UDPIPV6:
|
||||
hash_type = PKT_HASH_TYPE_L4;
|
||||
break;
|
||||
default:
|
||||
hash_type = PKT_HASH_TYPE_L3;
|
||||
break;
|
||||
}
|
||||
skb_set_hash(skb,
|
||||
le32_to_cpu(rcd->rssHash),
|
||||
hash_type);
|
||||
}
|
||||
#endif
|
||||
vmxnet3_rx_csum(adapter, skb,
|
||||
(union Vmxnet3_GenericDesc *)rcd);
|
||||
skb->protocol = eth_type_trans(skb, adapter->netdev);
|
||||
|
|
|
@ -2839,8 +2839,6 @@ int unregister_netdevice_notifier(struct notifier_block *nb);
|
|||
int register_netdevice_notifier_net(struct net *net, struct notifier_block *nb);
|
||||
int unregister_netdevice_notifier_net(struct net *net,
|
||||
struct notifier_block *nb);
|
||||
void move_netdevice_notifier_net(struct net *src_net, struct net *dst_net,
|
||||
struct notifier_block *nb);
|
||||
int register_netdevice_notifier_dev_net(struct net_device *dev,
|
||||
struct notifier_block *nb,
|
||||
struct netdev_net_notifier *nn);
|
||||
|
|
|
@ -2434,6 +2434,19 @@ static inline __must_check bool skb_set_owner_sk_safe(struct sk_buff *skb, struc
|
|||
return false;
|
||||
}
|
||||
|
||||
static inline struct sk_buff *skb_clone_and_charge_r(struct sk_buff *skb, struct sock *sk)
|
||||
{
|
||||
skb = skb_clone(skb, sk_gfp_mask(sk, GFP_ATOMIC));
|
||||
if (skb) {
|
||||
if (sk_rmem_schedule(sk, skb, skb->truesize)) {
|
||||
skb_set_owner_r(skb, sk);
|
||||
return skb;
|
||||
}
|
||||
__kfree_skb(skb);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline void skb_prepare_for_gro(struct sk_buff *skb)
|
||||
{
|
||||
if (skb->destructor != sock_wfree) {
|
||||
|
|
|
@ -1015,6 +1015,7 @@ static void caif_sock_destructor(struct sock *sk)
|
|||
return;
|
||||
}
|
||||
sk_stream_kill_queues(&cf_sk->sk);
|
||||
WARN_ON_ONCE(sk->sk_forward_alloc);
|
||||
caif_free_client(&cf_sk->layer);
|
||||
}
|
||||
|
||||
|
|
|
@ -1869,14 +1869,6 @@ static void __move_netdevice_notifier_net(struct net *src_net,
|
|||
__register_netdevice_notifier_net(dst_net, nb, true);
|
||||
}
|
||||
|
||||
void move_netdevice_notifier_net(struct net *src_net, struct net *dst_net,
|
||||
struct notifier_block *nb)
|
||||
{
|
||||
rtnl_lock();
|
||||
__move_netdevice_notifier_net(src_net, dst_net, nb);
|
||||
rtnl_unlock();
|
||||
}
|
||||
|
||||
int register_netdevice_notifier_dev_net(struct net_device *dev,
|
||||
struct notifier_block *nb,
|
||||
struct netdev_net_notifier *nn)
|
||||
|
@ -10375,7 +10367,7 @@ void netdev_stats_to_stats64(struct rtnl_link_stats64 *stats64,
|
|||
|
||||
BUILD_BUG_ON(n > sizeof(*stats64) / sizeof(u64));
|
||||
for (i = 0; i < n; i++)
|
||||
dst[i] = atomic_long_read(&src[i]);
|
||||
dst[i] = (unsigned long)atomic_long_read(&src[i]);
|
||||
/* zero out counters that only exist in rtnl_link_stats64 */
|
||||
memset((char *)stats64 + n * sizeof(u64), 0,
|
||||
sizeof(*stats64) - n * sizeof(u64));
|
||||
|
|
|
@ -4742,11 +4742,8 @@ static int devlink_reload(struct devlink *devlink, struct net *dest_net,
|
|||
if (err)
|
||||
return err;
|
||||
|
||||
if (dest_net && !net_eq(dest_net, curr_net)) {
|
||||
move_netdevice_notifier_net(curr_net, dest_net,
|
||||
&devlink->netdevice_nb);
|
||||
if (dest_net && !net_eq(dest_net, curr_net))
|
||||
write_pnet(&devlink->_net, dest_net);
|
||||
}
|
||||
|
||||
err = devlink->ops->reload_up(devlink, action, limit, actions_performed, extack);
|
||||
devlink_reload_failed_set(devlink, !!err);
|
||||
|
|
|
@ -304,6 +304,12 @@ struct net *get_net_ns_by_id(const struct net *net, int id)
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(get_net_ns_by_id);
|
||||
|
||||
/* init code that must occur even if setup_net() is not called. */
|
||||
static __net_init void preinit_net(struct net *net)
|
||||
{
|
||||
ref_tracker_dir_init(&net->notrefcnt_tracker, 128);
|
||||
}
|
||||
|
||||
/*
|
||||
* setup_net runs the initializers for the network namespace object.
|
||||
*/
|
||||
|
@ -316,7 +322,6 @@ static __net_init int setup_net(struct net *net, struct user_namespace *user_ns)
|
|||
|
||||
refcount_set(&net->ns.count, 1);
|
||||
ref_tracker_dir_init(&net->refcnt_tracker, 128);
|
||||
ref_tracker_dir_init(&net->notrefcnt_tracker, 128);
|
||||
|
||||
refcount_set(&net->passive, 1);
|
||||
get_random_bytes(&net->hash_mix, sizeof(u32));
|
||||
|
@ -472,6 +477,8 @@ struct net *copy_net_ns(unsigned long flags,
|
|||
rv = -ENOMEM;
|
||||
goto dec_ucounts;
|
||||
}
|
||||
|
||||
preinit_net(net);
|
||||
refcount_set(&net->passive, 1);
|
||||
net->ucounts = ucounts;
|
||||
get_user_ns(user_ns);
|
||||
|
@ -1118,6 +1125,7 @@ void __init net_ns_init(void)
|
|||
init_net.key_domain = &init_net_key_domain;
|
||||
#endif
|
||||
down_write(&pernet_ops_rwsem);
|
||||
preinit_net(&init_net);
|
||||
if (setup_net(&init_net, &init_user_ns))
|
||||
panic("Could not setup the initial network namespace");
|
||||
|
||||
|
|
|
@ -209,7 +209,6 @@ void sk_stream_kill_queues(struct sock *sk)
|
|||
sk_mem_reclaim_final(sk);
|
||||
|
||||
WARN_ON_ONCE(sk->sk_wmem_queued);
|
||||
WARN_ON_ONCE(sk->sk_forward_alloc);
|
||||
|
||||
/* It is _impossible_ for the backlog to contain anything
|
||||
* when we get here. All user references to this socket
|
||||
|
|
|
@ -551,11 +551,9 @@ static struct sock *dccp_v6_request_recv_sock(const struct sock *sk,
|
|||
*own_req = inet_ehash_nolisten(newsk, req_to_sk(req_unhash), NULL);
|
||||
/* Clone pktoptions received with SYN, if we own the req */
|
||||
if (*own_req && ireq->pktopts) {
|
||||
newnp->pktoptions = skb_clone(ireq->pktopts, GFP_ATOMIC);
|
||||
newnp->pktoptions = skb_clone_and_charge_r(ireq->pktopts, newsk);
|
||||
consume_skb(ireq->pktopts);
|
||||
ireq->pktopts = NULL;
|
||||
if (newnp->pktoptions)
|
||||
skb_set_owner_r(newnp->pktoptions, newsk);
|
||||
}
|
||||
|
||||
return newsk;
|
||||
|
@ -615,7 +613,7 @@ static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
|
|||
--ANK (980728)
|
||||
*/
|
||||
if (np->rxopt.all)
|
||||
opt_skb = skb_clone(skb, GFP_ATOMIC);
|
||||
opt_skb = skb_clone_and_charge_r(skb, sk);
|
||||
|
||||
if (sk->sk_state == DCCP_OPEN) { /* Fast path */
|
||||
if (dccp_rcv_established(sk, skb, dccp_hdr(skb), skb->len))
|
||||
|
@ -679,7 +677,6 @@ ipv6_pktoptions:
|
|||
np->flow_label = ip6_flowlabel(ipv6_hdr(opt_skb));
|
||||
if (ipv6_opt_accepted(sk, opt_skb,
|
||||
&DCCP_SKB_CB(opt_skb)->header.h6)) {
|
||||
skb_set_owner_r(opt_skb, sk);
|
||||
memmove(IP6CB(opt_skb),
|
||||
&DCCP_SKB_CB(opt_skb)->header.h6,
|
||||
sizeof(struct inet6_skb_parm));
|
||||
|
|
|
@ -51,7 +51,7 @@ static void ip6_datagram_flow_key_init(struct flowi6 *fl6, struct sock *sk)
|
|||
fl6->flowi6_mark = sk->sk_mark;
|
||||
fl6->fl6_dport = inet->inet_dport;
|
||||
fl6->fl6_sport = inet->inet_sport;
|
||||
fl6->flowlabel = np->flow_label;
|
||||
fl6->flowlabel = ip6_make_flowinfo(np->tclass, np->flow_label);
|
||||
fl6->flowi6_uid = sk->sk_uid;
|
||||
|
||||
if (!oif)
|
||||
|
|
|
@ -272,6 +272,7 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
|
|||
fl6.flowi6_proto = IPPROTO_TCP;
|
||||
fl6.daddr = sk->sk_v6_daddr;
|
||||
fl6.saddr = saddr ? *saddr : np->saddr;
|
||||
fl6.flowlabel = ip6_make_flowinfo(np->tclass, np->flow_label);
|
||||
fl6.flowi6_oif = sk->sk_bound_dev_if;
|
||||
fl6.flowi6_mark = sk->sk_mark;
|
||||
fl6.fl6_dport = usin->sin6_port;
|
||||
|
@ -1387,14 +1388,11 @@ static struct sock *tcp_v6_syn_recv_sock(const struct sock *sk, struct sk_buff *
|
|||
|
||||
/* Clone pktoptions received with SYN, if we own the req */
|
||||
if (ireq->pktopts) {
|
||||
newnp->pktoptions = skb_clone(ireq->pktopts,
|
||||
sk_gfp_mask(sk, GFP_ATOMIC));
|
||||
newnp->pktoptions = skb_clone_and_charge_r(ireq->pktopts, newsk);
|
||||
consume_skb(ireq->pktopts);
|
||||
ireq->pktopts = NULL;
|
||||
if (newnp->pktoptions) {
|
||||
if (newnp->pktoptions)
|
||||
tcp_v6_restore_cb(newnp->pktoptions);
|
||||
skb_set_owner_r(newnp->pktoptions, newsk);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!req_unhash && found_dup_sk) {
|
||||
|
@ -1466,7 +1464,7 @@ int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
|
|||
--ANK (980728)
|
||||
*/
|
||||
if (np->rxopt.all)
|
||||
opt_skb = skb_clone(skb, sk_gfp_mask(sk, GFP_ATOMIC));
|
||||
opt_skb = skb_clone_and_charge_r(skb, sk);
|
||||
|
||||
reason = SKB_DROP_REASON_NOT_SPECIFIED;
|
||||
if (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */
|
||||
|
@ -1552,7 +1550,6 @@ ipv6_pktoptions:
|
|||
if (np->repflow)
|
||||
np->flow_label = ip6_flowlabel(ipv6_hdr(opt_skb));
|
||||
if (ipv6_opt_accepted(sk, opt_skb, &TCP_SKB_CB(opt_skb)->header.h6)) {
|
||||
skb_set_owner_r(opt_skb, sk);
|
||||
tcp_v6_restore_cb(opt_skb);
|
||||
opt_skb = xchg(&np->pktoptions, opt_skb);
|
||||
} else {
|
||||
|
|
|
@ -1261,7 +1261,7 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct net *net,
|
|||
const struct sadb_x_nat_t_type* n_type;
|
||||
struct xfrm_encap_tmpl *natt;
|
||||
|
||||
x->encap = kmalloc(sizeof(*x->encap), GFP_KERNEL);
|
||||
x->encap = kzalloc(sizeof(*x->encap), GFP_KERNEL);
|
||||
if (!x->encap) {
|
||||
err = -ENOMEM;
|
||||
goto out;
|
||||
|
|
|
@ -1428,6 +1428,7 @@ static int mpls_dev_sysctl_register(struct net_device *dev,
|
|||
free:
|
||||
kfree(table);
|
||||
out:
|
||||
mdev->sysctl = NULL;
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
|
@ -1437,6 +1438,9 @@ static void mpls_dev_sysctl_unregister(struct net_device *dev,
|
|||
struct net *net = dev_net(dev);
|
||||
struct ctl_table *table;
|
||||
|
||||
if (!mdev->sysctl)
|
||||
return;
|
||||
|
||||
table = mdev->sysctl->ctl_table_arg;
|
||||
unregister_net_sysctl_table(mdev->sysctl);
|
||||
kfree(table);
|
||||
|
|
|
@ -449,7 +449,7 @@ static int ovs_meter_cmd_set(struct sk_buff *skb, struct genl_info *info)
|
|||
|
||||
err = attach_meter(meter_tbl, meter);
|
||||
if (err)
|
||||
goto exit_unlock;
|
||||
goto exit_free_old_meter;
|
||||
|
||||
ovs_unlock();
|
||||
|
||||
|
@ -472,6 +472,8 @@ static int ovs_meter_cmd_set(struct sk_buff *skb, struct genl_info *info)
|
|||
genlmsg_end(reply, ovs_reply_header);
|
||||
return genlmsg_reply(reply, info);
|
||||
|
||||
exit_free_old_meter:
|
||||
ovs_meter_free(old_meter);
|
||||
exit_unlock:
|
||||
ovs_unlock();
|
||||
nlmsg_free(reply);
|
||||
|
|
|
@ -93,7 +93,7 @@ TC_INDIRECT_SCOPE int tcf_ctinfo_act(struct sk_buff *skb,
|
|||
cp = rcu_dereference_bh(ca->params);
|
||||
|
||||
tcf_lastuse_update(&ca->tcf_tm);
|
||||
bstats_update(&ca->tcf_bstats, skb);
|
||||
tcf_action_update_bstats(&ca->common, skb);
|
||||
action = READ_ONCE(ca->tcf_action);
|
||||
|
||||
wlen = skb_network_offset(skb);
|
||||
|
@ -212,8 +212,8 @@ static int tcf_ctinfo_init(struct net *net, struct nlattr *nla,
|
|||
index = actparm->index;
|
||||
err = tcf_idr_check_alloc(tn, &index, a, bind);
|
||||
if (!err) {
|
||||
ret = tcf_idr_create(tn, index, est, a,
|
||||
&act_ctinfo_ops, bind, false, flags);
|
||||
ret = tcf_idr_create_from_flags(tn, index, est, a,
|
||||
&act_ctinfo_ops, bind, flags);
|
||||
if (ret) {
|
||||
tcf_idr_cleanup(tn, index);
|
||||
return ret;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <linux/errno.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/refcount.h>
|
||||
#include <linux/rcupdate.h>
|
||||
#include <net/act_api.h>
|
||||
#include <net/netlink.h>
|
||||
#include <net/pkt_cls.h>
|
||||
|
@ -339,6 +340,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
|
|||
struct tcf_result cr = {};
|
||||
int err, balloc = 0;
|
||||
struct tcf_exts e;
|
||||
bool update_h = false;
|
||||
|
||||
err = tcf_exts_init(&e, net, TCA_TCINDEX_ACT, TCA_TCINDEX_POLICE);
|
||||
if (err < 0)
|
||||
|
@ -456,10 +458,13 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
|
|||
}
|
||||
}
|
||||
|
||||
if (cp->perfect)
|
||||
if (cp->perfect) {
|
||||
r = cp->perfect + handle;
|
||||
else
|
||||
r = tcindex_lookup(cp, handle) ? : &new_filter_result;
|
||||
} else {
|
||||
/* imperfect area is updated in-place using rcu */
|
||||
update_h = !!tcindex_lookup(cp, handle);
|
||||
r = &new_filter_result;
|
||||
}
|
||||
|
||||
if (r == &new_filter_result) {
|
||||
f = kzalloc(sizeof(*f), GFP_KERNEL);
|
||||
|
@ -485,7 +490,28 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
|
|||
|
||||
rcu_assign_pointer(tp->root, cp);
|
||||
|
||||
if (r == &new_filter_result) {
|
||||
if (update_h) {
|
||||
struct tcindex_filter __rcu **fp;
|
||||
struct tcindex_filter *cf;
|
||||
|
||||
f->result.res = r->res;
|
||||
tcf_exts_change(&f->result.exts, &r->exts);
|
||||
|
||||
/* imperfect area bucket */
|
||||
fp = cp->h + (handle % cp->hash);
|
||||
|
||||
/* lookup the filter, guaranteed to exist */
|
||||
for (cf = rcu_dereference_bh_rtnl(*fp); cf;
|
||||
fp = &cf->next, cf = rcu_dereference_bh_rtnl(*fp))
|
||||
if (cf->key == (u16)handle)
|
||||
break;
|
||||
|
||||
f->next = cf->next;
|
||||
|
||||
cf = rcu_replace_pointer(*fp, f, 1);
|
||||
tcf_exts_get_net(&cf->result.exts);
|
||||
tcf_queue_work(&cf->rwork, tcindex_destroy_fexts_work);
|
||||
} else if (r == &new_filter_result) {
|
||||
struct tcindex_filter *nfp;
|
||||
struct tcindex_filter __rcu **fp;
|
||||
|
||||
|
|
|
@ -343,11 +343,9 @@ static int sctp_sock_filter(struct sctp_endpoint *ep, struct sctp_transport *tsp
|
|||
struct sctp_comm_param *commp = p;
|
||||
struct sock *sk = ep->base.sk;
|
||||
const struct inet_diag_req_v2 *r = commp->r;
|
||||
struct sctp_association *assoc =
|
||||
list_entry(ep->asocs.next, struct sctp_association, asocs);
|
||||
|
||||
/* find the ep only once through the transports by this condition */
|
||||
if (tsp->asoc != assoc)
|
||||
if (!list_is_first(&tsp->asoc->asocs, &ep->asocs))
|
||||
return 0;
|
||||
|
||||
if (r->sdiag_family != AF_UNSPEC && sk->sk_family != r->sdiag_family)
|
||||
|
|
|
@ -971,9 +971,12 @@ static inline void sock_recv_drops(struct msghdr *msg, struct sock *sk,
|
|||
static void sock_recv_mark(struct msghdr *msg, struct sock *sk,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
if (sock_flag(sk, SOCK_RCVMARK) && skb)
|
||||
put_cmsg(msg, SOL_SOCKET, SO_MARK, sizeof(__u32),
|
||||
&skb->mark);
|
||||
if (sock_flag(sk, SOCK_RCVMARK) && skb) {
|
||||
/* We must use a bounce buffer for CONFIG_HARDENED_USERCOPY=y */
|
||||
__u32 mark = skb->mark;
|
||||
|
||||
put_cmsg(msg, SOL_SOCKET, SO_MARK, sizeof(__u32), &mark);
|
||||
}
|
||||
}
|
||||
|
||||
void __sock_recv_cmsgs(struct msghdr *msg, struct sock *sk,
|
||||
|
|
|
@ -2614,6 +2614,7 @@ static int tipc_connect(struct socket *sock, struct sockaddr *dest,
|
|||
/* Send a 'SYN-' to destination */
|
||||
m.msg_name = dest;
|
||||
m.msg_namelen = destlen;
|
||||
iov_iter_kvec(&m.msg_iter, ITER_SOURCE, NULL, 0, 0);
|
||||
|
||||
/* If connect is in non-blocking case, set MSG_DONTWAIT to
|
||||
* indicate send_msg() is never blocked.
|
||||
|
@ -2776,6 +2777,7 @@ static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags,
|
|||
__skb_queue_head(&new_sk->sk_receive_queue, buf);
|
||||
skb_set_owner_r(buf, new_sk);
|
||||
}
|
||||
iov_iter_kvec(&m.msg_iter, ITER_SOURCE, NULL, 0, 0);
|
||||
__tipc_sendstream(new_sock, &m, 0);
|
||||
release_sock(new_sk);
|
||||
exit:
|
||||
|
|
|
@ -10,8 +10,10 @@ ret=0
|
|||
|
||||
PAUSE_ON_FAIL=${PAUSE_ON_FAIL:=no}
|
||||
IP="ip -netns testns"
|
||||
IP_PEER="ip -netns peerns"
|
||||
|
||||
RTABLE=100
|
||||
RTABLE_PEER=101
|
||||
GW_IP4=192.51.100.2
|
||||
SRC_IP=192.51.100.3
|
||||
GW_IP6=2001:db8:1::2
|
||||
|
@ -20,7 +22,9 @@ SRC_IP6=2001:db8:1::3
|
|||
DEV_ADDR=192.51.100.1
|
||||
DEV_ADDR6=2001:db8:1::1
|
||||
DEV=dummy0
|
||||
TESTS="fib_rule6 fib_rule4"
|
||||
TESTS="fib_rule6 fib_rule4 fib_rule6_connect fib_rule4_connect"
|
||||
|
||||
SELFTEST_PATH=""
|
||||
|
||||
log_test()
|
||||
{
|
||||
|
@ -52,6 +56,31 @@ log_section()
|
|||
echo "######################################################################"
|
||||
}
|
||||
|
||||
check_nettest()
|
||||
{
|
||||
if which nettest > /dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Add the selftest directory to PATH if not already done
|
||||
if [ "${SELFTEST_PATH}" = "" ]; then
|
||||
SELFTEST_PATH="$(dirname $0)"
|
||||
PATH="${PATH}:${SELFTEST_PATH}"
|
||||
|
||||
# Now retry with the new path
|
||||
if which nettest > /dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "${ret}" -eq 0 ]; then
|
||||
ret="${ksft_skip}"
|
||||
fi
|
||||
echo "nettest not found (try 'make -C ${SELFTEST_PATH} nettest')"
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
setup()
|
||||
{
|
||||
set -e
|
||||
|
@ -72,6 +101,39 @@ cleanup()
|
|||
ip netns del testns
|
||||
}
|
||||
|
||||
setup_peer()
|
||||
{
|
||||
set -e
|
||||
|
||||
ip netns add peerns
|
||||
$IP_PEER link set dev lo up
|
||||
|
||||
ip link add name veth0 netns testns type veth \
|
||||
peer name veth1 netns peerns
|
||||
$IP link set dev veth0 up
|
||||
$IP_PEER link set dev veth1 up
|
||||
|
||||
$IP address add 192.0.2.10 peer 192.0.2.11/32 dev veth0
|
||||
$IP_PEER address add 192.0.2.11 peer 192.0.2.10/32 dev veth1
|
||||
|
||||
$IP address add 2001:db8::10 peer 2001:db8::11/128 dev veth0 nodad
|
||||
$IP_PEER address add 2001:db8::11 peer 2001:db8::10/128 dev veth1 nodad
|
||||
|
||||
$IP_PEER address add 198.51.100.11/32 dev lo
|
||||
$IP route add table $RTABLE_PEER 198.51.100.11/32 via 192.0.2.11
|
||||
|
||||
$IP_PEER address add 2001:db8::1:11/128 dev lo
|
||||
$IP route add table $RTABLE_PEER 2001:db8::1:11/128 via 2001:db8::11
|
||||
|
||||
set +e
|
||||
}
|
||||
|
||||
cleanup_peer()
|
||||
{
|
||||
$IP link del dev veth0
|
||||
ip netns del peerns
|
||||
}
|
||||
|
||||
fib_check_iproute_support()
|
||||
{
|
||||
ip rule help 2>&1 | grep -q $1
|
||||
|
@ -190,6 +252,37 @@ fib_rule6_test()
|
|||
fi
|
||||
}
|
||||
|
||||
# Verify that the IPV6_TCLASS option of UDPv6 and TCPv6 sockets is properly
|
||||
# taken into account when connecting the socket and when sending packets.
|
||||
fib_rule6_connect_test()
|
||||
{
|
||||
local dsfield
|
||||
|
||||
if ! check_nettest; then
|
||||
echo "SKIP: Could not run test without nettest tool"
|
||||
return
|
||||
fi
|
||||
|
||||
setup_peer
|
||||
$IP -6 rule add dsfield 0x04 table $RTABLE_PEER
|
||||
|
||||
# Combine the base DS Field value (0x04) with all possible ECN values
|
||||
# (Not-ECT: 0, ECT(1): 1, ECT(0): 2, CE: 3).
|
||||
# The ECN bits shouldn't influence the result of the test.
|
||||
for dsfield in 0x04 0x05 0x06 0x07; do
|
||||
nettest -q -6 -B -t 5 -N testns -O peerns -U -D \
|
||||
-Q "${dsfield}" -l 2001:db8::1:11 -r 2001:db8::1:11
|
||||
log_test $? 0 "rule6 dsfield udp connect (dsfield ${dsfield})"
|
||||
|
||||
nettest -q -6 -B -t 5 -N testns -O peerns -Q "${dsfield}" \
|
||||
-l 2001:db8::1:11 -r 2001:db8::1:11
|
||||
log_test $? 0 "rule6 dsfield tcp connect (dsfield ${dsfield})"
|
||||
done
|
||||
|
||||
$IP -6 rule del dsfield 0x04 table $RTABLE_PEER
|
||||
cleanup_peer
|
||||
}
|
||||
|
||||
fib_rule4_del()
|
||||
{
|
||||
$IP rule del $1
|
||||
|
@ -296,6 +389,37 @@ fib_rule4_test()
|
|||
fi
|
||||
}
|
||||
|
||||
# Verify that the IP_TOS option of UDPv4 and TCPv4 sockets is properly taken
|
||||
# into account when connecting the socket and when sending packets.
|
||||
fib_rule4_connect_test()
|
||||
{
|
||||
local dsfield
|
||||
|
||||
if ! check_nettest; then
|
||||
echo "SKIP: Could not run test without nettest tool"
|
||||
return
|
||||
fi
|
||||
|
||||
setup_peer
|
||||
$IP -4 rule add dsfield 0x04 table $RTABLE_PEER
|
||||
|
||||
# Combine the base DS Field value (0x04) with all possible ECN values
|
||||
# (Not-ECT: 0, ECT(1): 1, ECT(0): 2, CE: 3).
|
||||
# The ECN bits shouldn't influence the result of the test.
|
||||
for dsfield in 0x04 0x05 0x06 0x07; do
|
||||
nettest -q -B -t 5 -N testns -O peerns -D -U -Q "${dsfield}" \
|
||||
-l 198.51.100.11 -r 198.51.100.11
|
||||
log_test $? 0 "rule4 dsfield udp connect (dsfield ${dsfield})"
|
||||
|
||||
nettest -q -B -t 5 -N testns -O peerns -Q "${dsfield}" \
|
||||
-l 198.51.100.11 -r 198.51.100.11
|
||||
log_test $? 0 "rule4 dsfield tcp connect (dsfield ${dsfield})"
|
||||
done
|
||||
|
||||
$IP -4 rule del dsfield 0x04 table $RTABLE_PEER
|
||||
cleanup_peer
|
||||
}
|
||||
|
||||
run_fibrule_tests()
|
||||
{
|
||||
log_section "IPv4 fib rule"
|
||||
|
@ -345,6 +469,8 @@ do
|
|||
case $t in
|
||||
fib_rule6_test|fib_rule6) fib_rule6_test;;
|
||||
fib_rule4_test|fib_rule4) fib_rule4_test;;
|
||||
fib_rule6_connect_test|fib_rule6_connect) fib_rule6_connect_test;;
|
||||
fib_rule4_connect_test|fib_rule4_connect) fib_rule4_connect_test;;
|
||||
|
||||
help) echo "Test names: $TESTS"; exit 0;;
|
||||
|
||||
|
|
|
@ -87,6 +87,7 @@ struct sock_args {
|
|||
int use_setsockopt;
|
||||
int use_freebind;
|
||||
int use_cmsg;
|
||||
uint8_t dsfield;
|
||||
const char *dev;
|
||||
const char *server_dev;
|
||||
int ifindex;
|
||||
|
@ -580,6 +581,36 @@ static int set_reuseaddr(int sd)
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int set_dsfield(int sd, int version, int dsfield)
|
||||
{
|
||||
if (!dsfield)
|
||||
return 0;
|
||||
|
||||
switch (version) {
|
||||
case AF_INET:
|
||||
if (setsockopt(sd, SOL_IP, IP_TOS, &dsfield,
|
||||
sizeof(dsfield)) < 0) {
|
||||
log_err_errno("setsockopt(IP_TOS)");
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case AF_INET6:
|
||||
if (setsockopt(sd, SOL_IPV6, IPV6_TCLASS, &dsfield,
|
||||
sizeof(dsfield)) < 0) {
|
||||
log_err_errno("setsockopt(IPV6_TCLASS)");
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
log_error("Invalid address family\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int str_to_uint(const char *str, int min, int max, unsigned int *value)
|
||||
{
|
||||
int number;
|
||||
|
@ -1317,6 +1348,9 @@ static int msock_init(struct sock_args *args, int server)
|
|||
(char *)&one, sizeof(one)) < 0)
|
||||
log_err_errno("Setting SO_BROADCAST error");
|
||||
|
||||
if (set_dsfield(sd, AF_INET, args->dsfield) != 0)
|
||||
goto out_err;
|
||||
|
||||
if (args->dev && bind_to_device(sd, args->dev) != 0)
|
||||
goto out_err;
|
||||
else if (args->use_setsockopt &&
|
||||
|
@ -1445,6 +1479,9 @@ static int lsock_init(struct sock_args *args)
|
|||
if (set_reuseport(sd) != 0)
|
||||
goto err;
|
||||
|
||||
if (set_dsfield(sd, args->version, args->dsfield) != 0)
|
||||
goto err;
|
||||
|
||||
if (args->dev && bind_to_device(sd, args->dev) != 0)
|
||||
goto err;
|
||||
else if (args->use_setsockopt &&
|
||||
|
@ -1658,6 +1695,9 @@ static int connectsock(void *addr, socklen_t alen, struct sock_args *args)
|
|||
if (set_reuseport(sd) != 0)
|
||||
goto err;
|
||||
|
||||
if (set_dsfield(sd, args->version, args->dsfield) != 0)
|
||||
goto err;
|
||||
|
||||
if (args->dev && bind_to_device(sd, args->dev) != 0)
|
||||
goto err;
|
||||
else if (args->use_setsockopt &&
|
||||
|
@ -1862,7 +1902,7 @@ static int ipc_parent(int cpid, int fd, struct sock_args *args)
|
|||
return client_status;
|
||||
}
|
||||
|
||||
#define GETOPT_STR "sr:l:c:p:t:g:P:DRn:M:X:m:d:I:BN:O:SUCi6xL:0:1:2:3:Fbqf"
|
||||
#define GETOPT_STR "sr:l:c:Q:p:t:g:P:DRn:M:X:m:d:I:BN:O:SUCi6xL:0:1:2:3:Fbqf"
|
||||
#define OPT_FORCE_BIND_KEY_IFINDEX 1001
|
||||
#define OPT_NO_BIND_KEY_IFINDEX 1002
|
||||
|
||||
|
@ -1893,6 +1933,8 @@ static void print_usage(char *prog)
|
|||
" -D|R datagram (D) / raw (R) socket (default stream)\n"
|
||||
" -l addr local address to bind to in server mode\n"
|
||||
" -c addr local address to bind to in client mode\n"
|
||||
" -Q dsfield DS Field value of the socket (the IP_TOS or\n"
|
||||
" IPV6_TCLASS socket option)\n"
|
||||
" -x configure XFRM policy on socket\n"
|
||||
"\n"
|
||||
" -d dev bind socket to given device name\n"
|
||||
|
@ -1971,6 +2013,13 @@ int main(int argc, char *argv[])
|
|||
args.has_local_ip = 1;
|
||||
args.client_local_addr_str = optarg;
|
||||
break;
|
||||
case 'Q':
|
||||
if (str_to_uint(optarg, 0, 255, &tmp) != 0) {
|
||||
fprintf(stderr, "Invalid DS Field\n");
|
||||
return 1;
|
||||
}
|
||||
args.dsfield = tmp;
|
||||
break;
|
||||
case 'p':
|
||||
if (str_to_uint(optarg, 1, 65535, &tmp) != 0) {
|
||||
fprintf(stderr, "Invalid port\n");
|
||||
|
|
Loading…
Reference in New Issue