mirror of
https://github.com/openwrt/openwrt.git
synced 2025-02-20 17:32:57 +00:00
kernek: use struct_group to wipe ar8216 volatile priv data
Instead of reference vlan and do strange subtraction, use the handy struct_group() to create a virtual struct of the same size of the members. This permits to have a more secure memset and fix compilation warning in 6.1 where additional checks are done. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
This commit is contained in:
parent
fb6de77a82
commit
0605fa693e
@ -1419,8 +1419,7 @@ ar8xxx_sw_reset_switch(struct switch_dev *dev)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
mutex_lock(&priv->reg_mutex);
|
mutex_lock(&priv->reg_mutex);
|
||||||
memset(&priv->vlan, 0, sizeof(struct ar8xxx_priv) -
|
memset(&priv->ar8xxx_priv_volatile, 0, sizeof(priv->ar8xxx_priv_volatile));
|
||||||
offsetof(struct ar8xxx_priv, vlan));
|
|
||||||
|
|
||||||
for (i = 0; i < dev->vlans; i++)
|
for (i = 0; i < dev->vlans; i++)
|
||||||
priv->vlan_id[i] = i;
|
priv->vlan_id[i] = i;
|
||||||
@ -2461,7 +2460,7 @@ ar8xxx_phy_config_init(struct phy_device *phydev)
|
|||||||
dev->phy_ptr = priv;
|
dev->phy_ptr = priv;
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,1,0)
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,1,0)
|
||||||
dev->priv_flags |= IFF_NO_IP_ALIGN;
|
dev->priv_flags |= IFF_NO_IP_ALIGN;
|
||||||
#else LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0)
|
#else
|
||||||
dev->extra_priv_flags |= IFF_NO_IP_ALIGN;
|
dev->extra_priv_flags |= IFF_NO_IP_ALIGN;
|
||||||
#endif
|
#endif
|
||||||
dev->eth_mangle_rx = ar8216_mangle_rx;
|
dev->eth_mangle_rx = ar8216_mangle_rx;
|
||||||
@ -2700,7 +2699,7 @@ ar8xxx_phy_detach(struct phy_device *phydev)
|
|||||||
dev->phy_ptr = NULL;
|
dev->phy_ptr = NULL;
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,1,0)
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,1,0)
|
||||||
dev->priv_flags &= ~IFF_NO_IP_ALIGN;
|
dev->priv_flags &= ~IFF_NO_IP_ALIGN;
|
||||||
#else LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0)
|
#else
|
||||||
dev->extra_priv_flags &= ~IFF_NO_IP_ALIGN;
|
dev->extra_priv_flags &= ~IFF_NO_IP_ALIGN;
|
||||||
#endif
|
#endif
|
||||||
dev->eth_mangle_rx = NULL;
|
dev->eth_mangle_rx = NULL;
|
||||||
|
@ -506,20 +506,22 @@ struct ar8xxx_priv {
|
|||||||
unsigned int use_count;
|
unsigned int use_count;
|
||||||
|
|
||||||
/* all fields below are cleared on reset */
|
/* all fields below are cleared on reset */
|
||||||
bool vlan;
|
struct_group(ar8xxx_priv_volatile,
|
||||||
|
bool vlan;
|
||||||
|
|
||||||
u16 vlan_id[AR8XXX_MAX_VLANS];
|
u16 vlan_id[AR8XXX_MAX_VLANS];
|
||||||
u8 vlan_table[AR8XXX_MAX_VLANS];
|
u8 vlan_table[AR8XXX_MAX_VLANS];
|
||||||
u8 vlan_tagged;
|
u8 vlan_tagged;
|
||||||
u16 pvid[AR8X16_MAX_PORTS];
|
u16 pvid[AR8X16_MAX_PORTS];
|
||||||
int arl_age_time;
|
int arl_age_time;
|
||||||
|
|
||||||
/* mirroring */
|
/* mirroring */
|
||||||
bool mirror_rx;
|
bool mirror_rx;
|
||||||
bool mirror_tx;
|
bool mirror_tx;
|
||||||
int source_port;
|
int source_port;
|
||||||
int monitor_port;
|
int monitor_port;
|
||||||
u8 port_vlan_prio[AR8X16_MAX_PORTS];
|
u8 port_vlan_prio[AR8X16_MAX_PORTS];
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
u32
|
u32
|
||||||
|
Loading…
x
Reference in New Issue
Block a user