* [PATCH 3/7] net: usb: asix88179_178a: add usbnet -> priv function
From: Ben Dooks @ 2018-10-12 9:16 UTC (permalink / raw)
To: davem, netdev
Cc: linux-usb, linux-kernel, linux-kernel, gregkh, bjorn,
steve.glendinning, Ben Dooks
In-Reply-To: <20181012091642.21294-1-ben.dooks@codethink.co.uk>
There are a number of places in the asix88179_178a driver where it gets the
private-data from the usbnet passed in. It would be sensible to have
one inline function to convert it and change all points in the driver
to use that.
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
drivers/net/usb/ax88179_178a.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 9e8ad372f419..f4b64e7e7706 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -196,6 +196,11 @@ static const struct {
{7, 0xcc, 0x4c, 0x18, 8},
};
+static inline struct ax88179_data *usbnet_to_ax(struct usbnet *usb)
+{
+ return (struct ax88179_data *)usb->data;
+}
+
static int __ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
u16 size, void *data, int in_pm)
{
@@ -678,7 +683,7 @@ ax88179_ethtool_set_eee(struct usbnet *dev, struct ethtool_eee *data)
static int ax88179_chk_eee(struct usbnet *dev)
{
struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET };
- struct ax88179_data *priv = (struct ax88179_data *)dev->data;
+ struct ax88179_data *priv = usbnet_to_ax(dev);
mii_ethtool_gset(&dev->mii, &ecmd);
@@ -781,7 +786,7 @@ static void ax88179_enable_eee(struct usbnet *dev)
static int ax88179_get_eee(struct net_device *net, struct ethtool_eee *edata)
{
struct usbnet *dev = netdev_priv(net);
- struct ax88179_data *priv = (struct ax88179_data *)dev->data;
+ struct ax88179_data *priv = usbnet_to_ax(dev);
edata->eee_enabled = priv->eee_enabled;
edata->eee_active = priv->eee_active;
@@ -792,7 +797,7 @@ static int ax88179_get_eee(struct net_device *net, struct ethtool_eee *edata)
static int ax88179_set_eee(struct net_device *net, struct ethtool_eee *edata)
{
struct usbnet *dev = netdev_priv(net);
- struct ax88179_data *priv = (struct ax88179_data *)dev->data;
+ struct ax88179_data *priv = usbnet_to_ax(dev);
int ret = -EOPNOTSUPP;
priv->eee_enabled = edata->eee_enabled;
@@ -841,7 +846,7 @@ static const struct ethtool_ops ax88179_ethtool_ops = {
static void ax88179_set_multicast(struct net_device *net)
{
struct usbnet *dev = netdev_priv(net);
- struct ax88179_data *data = (struct ax88179_data *)dev->data;
+ struct ax88179_data *data = usbnet_to_ax(dev);
u8 *m_filter = ((u8 *)dev->data) + 12;
data->rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_IPE);
@@ -1228,7 +1233,7 @@ static int ax88179_bind(struct usbnet *dev, struct usb_interface *intf)
u8 buf[5];
u16 *tmp16;
u8 *tmp;
- struct ax88179_data *ax179_data = (struct ax88179_data *)dev->data;
+ struct ax88179_data *ax179_data = usbnet_to_ax(dev);
struct ethtool_eee eee_data;
usbnet_get_endpoints(dev, intf);
@@ -1458,7 +1463,7 @@ ax88179_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
static int ax88179_link_reset(struct usbnet *dev)
{
- struct ax88179_data *ax179_data = (struct ax88179_data *)dev->data;
+ struct ax88179_data *ax179_data = usbnet_to_ax(dev);
u8 tmp[5], link_sts;
u16 mode, tmp16, delay = HZ / 10;
u32 tmp32 = 0x40000000;
@@ -1533,7 +1538,7 @@ static int ax88179_reset(struct usbnet *dev)
u8 buf[5];
u16 *tmp16;
u8 *tmp;
- struct ax88179_data *ax179_data = (struct ax88179_data *)dev->data;
+ struct ax88179_data *ax179_data = usbnet_to_ax(dev);
struct ethtool_eee eee_data;
tmp16 = (u16 *)buf;
--
2.19.1
^ permalink raw reply related
* [PATCH 4/7] net: qmi_wwan: add usbnet -> priv function
From: Ben Dooks @ 2018-10-12 9:16 UTC (permalink / raw)
To: davem, netdev
Cc: linux-usb, linux-kernel, linux-kernel, gregkh, bjorn,
steve.glendinning, Ben Dooks
In-Reply-To: <20181012091642.21294-1-ben.dooks@codethink.co.uk>
There are a number of places in the qmi_wwan driver where it gets the
private-data from the usbnet passed in. It would be sensible to have
one inline function to convert it and change all points in the driver
to use that.
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
drivers/net/usb/qmi_wwan.c | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 533b6fb8d923..45930758a945 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -76,6 +76,11 @@ struct qmimux_priv {
u8 mux_id;
};
+static inline struct qmi_wwan_state *usbnet_to_qmi(struct usbnet *usb)
+{
+ return (void *) &usb->data;
+}
+
static int qmimux_open(struct net_device *dev)
{
struct qmimux_priv *priv = netdev_priv(dev);
@@ -253,7 +258,7 @@ static void qmimux_unregister_device(struct net_device *dev)
static void qmi_wwan_netdev_setup(struct net_device *net)
{
struct usbnet *dev = netdev_priv(net);
- struct qmi_wwan_state *info = (void *)&dev->data;
+ struct qmi_wwan_state *info = usbnet_to_qmi(dev);
if (info->flags & QMI_WWAN_FLAG_RAWIP) {
net->header_ops = NULL; /* No header */
@@ -276,7 +281,7 @@ static void qmi_wwan_netdev_setup(struct net_device *net)
static ssize_t raw_ip_show(struct device *d, struct device_attribute *attr, char *buf)
{
struct usbnet *dev = netdev_priv(to_net_dev(d));
- struct qmi_wwan_state *info = (void *)&dev->data;
+ struct qmi_wwan_state *info = usbnet_to_qmi(dev);
return sprintf(buf, "%c\n", info->flags & QMI_WWAN_FLAG_RAWIP ? 'Y' : 'N');
}
@@ -284,7 +289,7 @@ static ssize_t raw_ip_show(struct device *d, struct device_attribute *attr, char
static ssize_t raw_ip_store(struct device *d, struct device_attribute *attr, const char *buf, size_t len)
{
struct usbnet *dev = netdev_priv(to_net_dev(d));
- struct qmi_wwan_state *info = (void *)&dev->data;
+ struct qmi_wwan_state *info = usbnet_to_qmi(dev);
bool enable;
int ret;
@@ -346,7 +351,7 @@ static ssize_t add_mux_show(struct device *d, struct device_attribute *attr, cha
static ssize_t add_mux_store(struct device *d, struct device_attribute *attr, const char *buf, size_t len)
{
struct usbnet *dev = netdev_priv(to_net_dev(d));
- struct qmi_wwan_state *info = (void *)&dev->data;
+ struct qmi_wwan_state *info = usbnet_to_qmi(dev);
u8 mux_id;
int ret;
@@ -391,7 +396,7 @@ static ssize_t del_mux_show(struct device *d, struct device_attribute *attr, cha
static ssize_t del_mux_store(struct device *d, struct device_attribute *attr, const char *buf, size_t len)
{
struct usbnet *dev = netdev_priv(to_net_dev(d));
- struct qmi_wwan_state *info = (void *)&dev->data;
+ struct qmi_wwan_state *info = usbnet_to_qmi(dev);
struct net_device *del_dev;
u8 mux_id;
int ret = 0;
@@ -468,7 +473,7 @@ static const u8 buggy_fw_addr[ETH_ALEN] = {0x00, 0xa0, 0xc6, 0x00, 0x00, 0x00};
*/
static int qmi_wwan_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
{
- struct qmi_wwan_state *info = (void *)&dev->data;
+ struct qmi_wwan_state *info = usbnet_to_qmi(dev);
bool rawip = info->flags & QMI_WWAN_FLAG_RAWIP;
__be16 proto;
@@ -555,7 +560,7 @@ static const struct net_device_ops qmi_wwan_netdev_ops = {
*/
static int qmi_wwan_manage_power(struct usbnet *dev, int on)
{
- struct qmi_wwan_state *info = (void *)&dev->data;
+ struct qmi_wwan_state *info = usbnet_to_qmi(dev);
int rv;
dev_dbg(&dev->intf->dev, "%s() pmcount=%d, on=%d\n", __func__,
@@ -589,7 +594,7 @@ static int qmi_wwan_register_subdriver(struct usbnet *dev)
{
int rv;
struct usb_driver *subdriver = NULL;
- struct qmi_wwan_state *info = (void *)&dev->data;
+ struct qmi_wwan_state *info = usbnet_to_qmi(dev);
/* collect bulk endpoints */
rv = usbnet_get_endpoints(dev, info->data);
@@ -651,7 +656,7 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
struct usb_cdc_union_desc *cdc_union;
struct usb_cdc_ether_desc *cdc_ether;
struct usb_driver *driver = driver_of(intf);
- struct qmi_wwan_state *info = (void *)&dev->data;
+ struct qmi_wwan_state *info = usbnet_to_qmi(dev);
struct usb_cdc_parsed_header hdr;
BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data) <
@@ -746,7 +751,7 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
static void qmi_wwan_unbind(struct usbnet *dev, struct usb_interface *intf)
{
- struct qmi_wwan_state *info = (void *)&dev->data;
+ struct qmi_wwan_state *info = usbnet_to_qmi(dev);
struct usb_driver *driver = driver_of(intf);
struct usb_interface *other;
@@ -785,7 +790,7 @@ static void qmi_wwan_unbind(struct usbnet *dev, struct usb_interface *intf)
static int qmi_wwan_suspend(struct usb_interface *intf, pm_message_t message)
{
struct usbnet *dev = usb_get_intfdata(intf);
- struct qmi_wwan_state *info = (void *)&dev->data;
+ struct qmi_wwan_state *info = usbnet_to_qmi(dev);
int ret;
/* Both usbnet_suspend() and subdriver->suspend() MUST return 0
@@ -808,7 +813,7 @@ static int qmi_wwan_suspend(struct usb_interface *intf, pm_message_t message)
static int qmi_wwan_resume(struct usb_interface *intf)
{
struct usbnet *dev = usb_get_intfdata(intf);
- struct qmi_wwan_state *info = (void *)&dev->data;
+ struct qmi_wwan_state *info = usbnet_to_qmi(dev);
int ret = 0;
bool callsub = (intf == info->control && info->subdriver &&
info->subdriver->resume);
@@ -1406,7 +1411,7 @@ static void qmi_wwan_disconnect(struct usb_interface *intf)
/* called twice if separate control and data intf */
if (!dev)
return;
- info = (void *)&dev->data;
+ info = usbnet_to_qmi(dev);
if (info->flags & QMI_WWAN_FLAG_MUX) {
if (!rtnl_trylock()) {
restart_syscall();
--
2.19.1
^ permalink raw reply related
* [PATCH 5/7] net: cdc_ether: add usbnet -> priv function
From: Ben Dooks @ 2018-10-12 9:16 UTC (permalink / raw)
To: davem, netdev
Cc: linux-usb, linux-kernel, linux-kernel, gregkh, bjorn,
steve.glendinning, Ben Dooks
In-Reply-To: <20181012091642.21294-1-ben.dooks@codethink.co.uk>
There are a number of places in the cdc drivers where it gets the
private-data from the usbnet passed in. It would be sensible to have
one inline function to convert it and change all points in the driver
to use that.
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
drivers/net/usb/cdc_ether.c | 8 ++---
drivers/net/usb/cdc_mbim.c | 23 ++++++++------
drivers/net/usb/cdc_ncm.c | 61 +++++++++++++++++++-----------------
drivers/net/usb/rndis_host.c | 6 ++--
include/linux/usb/usbnet.h | 5 +++
5 files changed, 59 insertions(+), 44 deletions(-)
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index 5c42cf81a08b..7fee0ebc1943 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -77,7 +77,7 @@ static const u8 mbm_guid[16] = {
static void usbnet_cdc_update_filter(struct usbnet *dev)
{
- struct cdc_state *info = (void *) &dev->data;
+ struct cdc_state *info = usbnet_to_cdc(dev);
struct usb_interface *intf = info->control;
struct net_device *net = dev->net;
@@ -115,7 +115,7 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
u8 *buf = intf->cur_altsetting->extra;
int len = intf->cur_altsetting->extralen;
struct usb_interface_descriptor *d;
- struct cdc_state *info = (void *) &dev->data;
+ struct cdc_state *info = usbnet_to_cdc(dev);
int status;
int rndis;
bool android_rndis_quirk = false;
@@ -353,7 +353,7 @@ EXPORT_SYMBOL_GPL(usbnet_ether_cdc_bind);
void usbnet_cdc_unbind(struct usbnet *dev, struct usb_interface *intf)
{
- struct cdc_state *info = (void *) &dev->data;
+ struct cdc_state *info = usbnet_to_cdc(dev);
struct usb_driver *driver = driver_of(intf);
/* combined interface - nothing to do */
@@ -438,7 +438,7 @@ EXPORT_SYMBOL_GPL(usbnet_cdc_status);
int usbnet_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
{
int status;
- struct cdc_state *info = (void *) &dev->data;
+ struct cdc_state *info = usbnet_to_cdc(dev);
BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data)
< sizeof(struct cdc_state)));
diff --git a/drivers/net/usb/cdc_mbim.c b/drivers/net/usb/cdc_mbim.c
index 0362acd5cdca..aec8f8eb21a7 100644
--- a/drivers/net/usb/cdc_mbim.c
+++ b/drivers/net/usb/cdc_mbim.c
@@ -36,6 +36,11 @@ struct cdc_mbim_state {
unsigned long flags;
};
+static inline struct cdc_mbim_state *usbnet_to_mbim(struct usbnet *usb)
+{
+ return (void *)&usb->data;
+}
+
/* flags for the cdc_mbim_state.flags field */
enum cdc_mbim_flags {
FLAG_IPS0_VLAN = 1 << 0, /* IP session 0 is tagged */
@@ -44,7 +49,7 @@ enum cdc_mbim_flags {
/* using a counter to merge subdriver requests with our own into a combined state */
static int cdc_mbim_manage_power(struct usbnet *dev, int on)
{
- struct cdc_mbim_state *info = (void *)&dev->data;
+ struct cdc_mbim_state *info = usbnet_to_mbim(dev);
int rv = 0;
dev_dbg(&dev->intf->dev, "%s() pmcount=%d, on=%d\n", __func__, atomic_read(&info->pmcount), on);
@@ -73,7 +78,7 @@ static int cdc_mbim_wdm_manage_power(struct usb_interface *intf, int status)
static int cdc_mbim_rx_add_vid(struct net_device *netdev, __be16 proto, u16 vid)
{
struct usbnet *dev = netdev_priv(netdev);
- struct cdc_mbim_state *info = (void *)&dev->data;
+ struct cdc_mbim_state *info = usbnet_to_mbim(dev);
/* creation of this VLAN is a request to tag IP session 0 */
if (vid == MBIM_IPS0_VID)
@@ -87,7 +92,7 @@ static int cdc_mbim_rx_add_vid(struct net_device *netdev, __be16 proto, u16 vid)
static int cdc_mbim_rx_kill_vid(struct net_device *netdev, __be16 proto, u16 vid)
{
struct usbnet *dev = netdev_priv(netdev);
- struct cdc_mbim_state *info = (void *)&dev->data;
+ struct cdc_mbim_state *info = usbnet_to_mbim(dev);
/* this is a request for an untagged IP session 0 */
if (vid == MBIM_IPS0_VID)
@@ -144,7 +149,7 @@ static int cdc_mbim_bind(struct usbnet *dev, struct usb_interface *intf)
struct usb_driver *subdriver = ERR_PTR(-ENODEV);
int ret = -ENODEV;
u8 data_altsetting = 1;
- struct cdc_mbim_state *info = (void *)&dev->data;
+ struct cdc_mbim_state *info = usbnet_to_mbim(dev);
/* should we change control altsetting on a NCM/MBIM function? */
if (cdc_ncm_select_altsetting(intf) == CDC_NCM_COMM_ALTSETTING_MBIM) {
@@ -195,7 +200,7 @@ static int cdc_mbim_bind(struct usbnet *dev, struct usb_interface *intf)
static void cdc_mbim_unbind(struct usbnet *dev, struct usb_interface *intf)
{
- struct cdc_mbim_state *info = (void *)&dev->data;
+ struct cdc_mbim_state *info = usbnet_to_mbim(dev);
struct cdc_ncm_ctx *ctx = info->ctx;
/* disconnect subdriver from control interface */
@@ -221,7 +226,7 @@ static bool is_ip_proto(__be16 proto)
static struct sk_buff *cdc_mbim_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
{
struct sk_buff *skb_out;
- struct cdc_mbim_state *info = (void *)&dev->data;
+ struct cdc_mbim_state *info = usbnet_to_mbim(dev);
struct cdc_ncm_ctx *ctx = info->ctx;
__le32 sign = cpu_to_le32(USB_CDC_MBIM_NDP16_IPS_SIGN);
u16 tci = 0;
@@ -411,7 +416,7 @@ static struct sk_buff *cdc_mbim_process_dgram(struct usbnet *dev, u8 *buf, size_
static int cdc_mbim_rx_fixup(struct usbnet *dev, struct sk_buff *skb_in)
{
struct sk_buff *skb;
- struct cdc_mbim_state *info = (void *)&dev->data;
+ struct cdc_mbim_state *info = usbnet_to_mbim(dev);
struct cdc_ncm_ctx *ctx = info->ctx;
int len;
int nframes;
@@ -506,7 +511,7 @@ static int cdc_mbim_suspend(struct usb_interface *intf, pm_message_t message)
{
int ret = -ENODEV;
struct usbnet *dev = usb_get_intfdata(intf);
- struct cdc_mbim_state *info = (void *)&dev->data;
+ struct cdc_mbim_state *info = usbnet_to_mbim(dev);
struct cdc_ncm_ctx *ctx = info->ctx;
if (!ctx)
@@ -534,7 +539,7 @@ static int cdc_mbim_resume(struct usb_interface *intf)
{
int ret = 0;
struct usbnet *dev = usb_get_intfdata(intf);
- struct cdc_mbim_state *info = (void *)&dev->data;
+ struct cdc_mbim_state *info = usbnet_to_mbim(dev);
struct cdc_ncm_ctx *ctx = info->ctx;
bool callsub = (intf == ctx->control && info->subdriver && info->subdriver->resume);
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 1eaec648bd1f..0d722b326e1b 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -91,6 +91,11 @@ static const struct cdc_ncm_stats cdc_ncm_gstrings_stats[] = {
#define CDC_NCM_LOW_MEM_MAX_CNT 10
+static inline struct cdc_ncm_ctx *usbnet_to_ncm(struct usbnet *net)
+{
+ return (struct cdc_ncm_ctx *)net->data[0];
+}
+
static int cdc_ncm_get_sset_count(struct net_device __always_unused *netdev, int sset)
{
switch (sset) {
@@ -106,7 +111,7 @@ static void cdc_ncm_get_ethtool_stats(struct net_device *netdev,
u64 *data)
{
struct usbnet *dev = netdev_priv(netdev);
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ struct cdc_ncm_ctx *ctx = usbnet_to_ncm(dev);
int i;
char *p = NULL;
@@ -148,7 +153,7 @@ static const struct ethtool_ops cdc_ncm_ethtool_ops = {
static u32 cdc_ncm_check_rx_max(struct usbnet *dev, u32 new_rx)
{
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ struct cdc_ncm_ctx *ctx = usbnet_to_ncm(dev);
u32 val, max, min;
/* clamp new_rx to sane values */
@@ -171,7 +176,7 @@ static u32 cdc_ncm_check_rx_max(struct usbnet *dev, u32 new_rx)
static u32 cdc_ncm_check_tx_max(struct usbnet *dev, u32 new_tx)
{
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ struct cdc_ncm_ctx *ctx = usbnet_to_ncm(dev);
u32 val, max, min;
/* clamp new_tx to sane values */
@@ -191,7 +196,7 @@ static u32 cdc_ncm_check_tx_max(struct usbnet *dev, u32 new_tx)
static ssize_t cdc_ncm_show_min_tx_pkt(struct device *d, struct device_attribute *attr, char *buf)
{
struct usbnet *dev = netdev_priv(to_net_dev(d));
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ struct cdc_ncm_ctx *ctx = usbnet_to_ncm(dev);
return sprintf(buf, "%u\n", ctx->min_tx_pkt);
}
@@ -199,7 +204,7 @@ static ssize_t cdc_ncm_show_min_tx_pkt(struct device *d, struct device_attribute
static ssize_t cdc_ncm_show_rx_max(struct device *d, struct device_attribute *attr, char *buf)
{
struct usbnet *dev = netdev_priv(to_net_dev(d));
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ struct cdc_ncm_ctx *ctx = usbnet_to_ncm(dev);
return sprintf(buf, "%u\n", ctx->rx_max);
}
@@ -207,7 +212,7 @@ static ssize_t cdc_ncm_show_rx_max(struct device *d, struct device_attribute *at
static ssize_t cdc_ncm_show_tx_max(struct device *d, struct device_attribute *attr, char *buf)
{
struct usbnet *dev = netdev_priv(to_net_dev(d));
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ struct cdc_ncm_ctx *ctx = usbnet_to_ncm(dev);
return sprintf(buf, "%u\n", ctx->tx_max);
}
@@ -215,7 +220,7 @@ static ssize_t cdc_ncm_show_tx_max(struct device *d, struct device_attribute *at
static ssize_t cdc_ncm_show_tx_timer_usecs(struct device *d, struct device_attribute *attr, char *buf)
{
struct usbnet *dev = netdev_priv(to_net_dev(d));
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ struct cdc_ncm_ctx *ctx = usbnet_to_ncm(dev);
return sprintf(buf, "%u\n", ctx->timer_interval / (u32)NSEC_PER_USEC);
}
@@ -223,7 +228,7 @@ static ssize_t cdc_ncm_show_tx_timer_usecs(struct device *d, struct device_attri
static ssize_t cdc_ncm_store_min_tx_pkt(struct device *d, struct device_attribute *attr, const char *buf, size_t len)
{
struct usbnet *dev = netdev_priv(to_net_dev(d));
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ struct cdc_ncm_ctx *ctx = usbnet_to_ncm(dev);
unsigned long val;
/* no need to restrict values - anything from 0 to infinity is OK */
@@ -237,7 +242,7 @@ static ssize_t cdc_ncm_store_min_tx_pkt(struct device *d, struct device_attribu
static ssize_t cdc_ncm_store_rx_max(struct device *d, struct device_attribute *attr, const char *buf, size_t len)
{
struct usbnet *dev = netdev_priv(to_net_dev(d));
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ struct cdc_ncm_ctx *ctx = usbnet_to_ncm(dev);
unsigned long val;
if (kstrtoul(buf, 0, &val) || cdc_ncm_check_rx_max(dev, val) != val)
@@ -250,7 +255,7 @@ static ssize_t cdc_ncm_store_rx_max(struct device *d, struct device_attribute *
static ssize_t cdc_ncm_store_tx_max(struct device *d, struct device_attribute *attr, const char *buf, size_t len)
{
struct usbnet *dev = netdev_priv(to_net_dev(d));
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ struct cdc_ncm_ctx *ctx = usbnet_to_ncm(dev);
unsigned long val;
if (kstrtoul(buf, 0, &val) || cdc_ncm_check_tx_max(dev, val) != val)
@@ -263,7 +268,7 @@ static ssize_t cdc_ncm_store_tx_max(struct device *d, struct device_attribute *
static ssize_t cdc_ncm_store_tx_timer_usecs(struct device *d, struct device_attribute *attr, const char *buf, size_t len)
{
struct usbnet *dev = netdev_priv(to_net_dev(d));
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ struct cdc_ncm_ctx *ctx = usbnet_to_ncm(dev);
ssize_t ret;
unsigned long val;
@@ -289,7 +294,7 @@ static DEVICE_ATTR(tx_timer_usecs, 0644, cdc_ncm_show_tx_timer_usecs, cdc_ncm_st
static ssize_t ndp_to_end_show(struct device *d, struct device_attribute *attr, char *buf)
{
struct usbnet *dev = netdev_priv(to_net_dev(d));
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ struct cdc_ncm_ctx *ctx = usbnet_to_ncm(dev);
return sprintf(buf, "%c\n", ctx->drvflags & CDC_NCM_FLAG_NDP_TO_END ? 'Y' : 'N');
}
@@ -297,7 +302,7 @@ static ssize_t ndp_to_end_show(struct device *d, struct device_attribute *attr,
static ssize_t ndp_to_end_store(struct device *d, struct device_attribute *attr, const char *buf, size_t len)
{
struct usbnet *dev = netdev_priv(to_net_dev(d));
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ struct cdc_ncm_ctx *ctx = usbnet_to_ncm(dev);
bool enable;
if (strtobool(buf, &enable))
@@ -332,7 +337,7 @@ static DEVICE_ATTR_RW(ndp_to_end);
static ssize_t cdc_ncm_show_##name(struct device *d, struct device_attribute *attr, char *buf) \
{ \
struct usbnet *dev = netdev_priv(to_net_dev(d)); \
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0]; \
+ struct cdc_ncm_ctx *ctx = usbnet_to_ncm(dev); \
return sprintf(buf, format "\n", tocpu(ctx->ncm_parm.name)); \
} \
static DEVICE_ATTR(name, 0444, cdc_ncm_show_##name, NULL)
@@ -375,7 +380,7 @@ static const struct attribute_group cdc_ncm_sysfs_attr_group = {
/* handle rx_max and tx_max changes */
static void cdc_ncm_update_rxtx_max(struct usbnet *dev, u32 new_rx, u32 new_tx)
{
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ struct cdc_ncm_ctx *ctx = usbnet_to_ncm(dev);
u8 iface_no = ctx->control->cur_altsetting->desc.bInterfaceNumber;
u32 val;
@@ -447,7 +452,7 @@ static void cdc_ncm_update_rxtx_max(struct usbnet *dev, u32 new_rx, u32 new_tx)
/* helpers for NCM and MBIM differences */
static u8 cdc_ncm_flags(struct usbnet *dev)
{
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ struct cdc_ncm_ctx *ctx = usbnet_to_ncm(dev);
if (cdc_ncm_comm_intf_is_mbim(dev->intf->cur_altsetting) && ctx->mbim_desc)
return ctx->mbim_desc->bmNetworkCapabilities;
@@ -472,7 +477,7 @@ static u32 cdc_ncm_min_dgram_size(struct usbnet *dev)
static u32 cdc_ncm_max_dgram_size(struct usbnet *dev)
{
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ struct cdc_ncm_ctx *ctx = usbnet_to_ncm(dev);
if (cdc_ncm_comm_intf_is_mbim(dev->intf->cur_altsetting) && ctx->mbim_desc)
return le16_to_cpu(ctx->mbim_desc->wMaxSegmentSize);
@@ -486,7 +491,7 @@ static u32 cdc_ncm_max_dgram_size(struct usbnet *dev)
*/
static int cdc_ncm_init(struct usbnet *dev)
{
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ struct cdc_ncm_ctx *ctx = usbnet_to_ncm(dev);
u8 iface_no = ctx->control->cur_altsetting->desc.bInterfaceNumber;
int err;
@@ -560,7 +565,7 @@ static int cdc_ncm_init(struct usbnet *dev)
/* set a new max datagram size */
static void cdc_ncm_set_dgram_size(struct usbnet *dev, int new_size)
{
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ struct cdc_ncm_ctx *ctx = usbnet_to_ncm(dev);
u8 iface_no = ctx->control->cur_altsetting->desc.bInterfaceNumber;
__le16 max_datagram_size;
u16 mbim_mtu;
@@ -608,7 +613,7 @@ static void cdc_ncm_set_dgram_size(struct usbnet *dev, int new_size)
static void cdc_ncm_fix_modulus(struct usbnet *dev)
{
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ struct cdc_ncm_ctx *ctx = usbnet_to_ncm(dev);
u32 val;
/*
@@ -652,7 +657,7 @@ static void cdc_ncm_fix_modulus(struct usbnet *dev)
static int cdc_ncm_setup(struct usbnet *dev)
{
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ struct cdc_ncm_ctx *ctx = usbnet_to_ncm(dev);
u32 def_rx, def_tx;
/* be conservative when selecting intial buffer size to
@@ -950,7 +955,7 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
if (ctx->data != ctx->control)
usb_driver_release_interface(driver, ctx->data);
error:
- cdc_ncm_free((struct cdc_ncm_ctx *)dev->data[0]);
+ cdc_ncm_free(usbnet_to_ncm(dev));
dev->data[0] = 0;
dev_info(&intf->dev, "bind() failure\n");
return -ENODEV;
@@ -959,7 +964,7 @@ EXPORT_SYMBOL_GPL(cdc_ncm_bind_common);
void cdc_ncm_unbind(struct usbnet *dev, struct usb_interface *intf)
{
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ struct cdc_ncm_ctx *ctx = usbnet_to_ncm(dev);
struct usb_driver *driver = driver_of(intf);
if (ctx == NULL)
@@ -1110,7 +1115,7 @@ static struct usb_cdc_ncm_ndp16 *cdc_ncm_ndp(struct cdc_ncm_ctx *ctx, struct sk_
struct sk_buff *
cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign)
{
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ struct cdc_ncm_ctx *ctx = usbnet_to_ncm(dev);
struct usb_cdc_ncm_nth16 *nth16;
struct usb_cdc_ncm_ndp16 *ndp16;
struct sk_buff *skb_out;
@@ -1360,7 +1365,7 @@ static enum hrtimer_restart cdc_ncm_tx_timer_cb(struct hrtimer *timer)
static void cdc_ncm_txpath_bh(unsigned long param)
{
struct usbnet *dev = (struct usbnet *)param;
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ struct cdc_ncm_ctx *ctx = usbnet_to_ncm(dev);
spin_lock_bh(&ctx->mtx);
if (ctx->tx_timer_pending != 0) {
@@ -1382,7 +1387,7 @@ struct sk_buff *
cdc_ncm_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
{
struct sk_buff *skb_out;
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ struct cdc_ncm_ctx *ctx = usbnet_to_ncm(dev);
/*
* The Ethernet API we are using does not support transmitting
@@ -1495,7 +1500,7 @@ EXPORT_SYMBOL_GPL(cdc_ncm_rx_verify_ndp16);
int cdc_ncm_rx_fixup(struct usbnet *dev, struct sk_buff *skb_in)
{
struct sk_buff *skb;
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ struct cdc_ncm_ctx *ctx = usbnet_to_ncm(dev);
int len;
int nframes;
int x;
@@ -1604,7 +1609,7 @@ static void cdc_ncm_status(struct usbnet *dev, struct urb *urb)
struct cdc_ncm_ctx *ctx;
struct usb_cdc_notification *event;
- ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ ctx = usbnet_to_ncm(dev);
if (urb->actual_length < sizeof(*event))
return;
diff --git a/drivers/net/usb/rndis_host.c b/drivers/net/usb/rndis_host.c
index b807c91abe1d..a24af05a74fb 100644
--- a/drivers/net/usb/rndis_host.c
+++ b/drivers/net/usb/rndis_host.c
@@ -69,7 +69,7 @@ EXPORT_SYMBOL_GPL(rndis_status);
static void rndis_msg_indicate(struct usbnet *dev, struct rndis_indicate *msg,
int buflen)
{
- struct cdc_state *info = (void *)&dev->data;
+ struct cdc_state *info = usbnet_to_cdc(dev);
struct device *udev = &info->control->dev;
if (dev->driver_info->indication) {
@@ -102,7 +102,7 @@ static void rndis_msg_indicate(struct usbnet *dev, struct rndis_indicate *msg,
*/
int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen)
{
- struct cdc_state *info = (void *) &dev->data;
+ struct cdc_state *info = usbnet_to_cdc(dev);
struct usb_cdc_notification notification;
int master_ifnum;
int retval;
@@ -301,7 +301,7 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags)
{
int retval;
struct net_device *net = dev->net;
- struct cdc_state *info = (void *) &dev->data;
+ struct cdc_state *info = usbnet_to_cdc(dev);
union {
void *buf;
struct rndis_msg_hdr *header;
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index e2ec3582e549..cdb54dd3a4b4 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -207,6 +207,11 @@ struct cdc_state {
struct usb_interface *data;
};
+static inline struct cdc_state *usbnet_to_cdc(struct usbnet *net)
+{
+ return (void *) &net->data;
+}
+
extern int usbnet_generic_cdc_bind(struct usbnet *, struct usb_interface *);
extern int usbnet_ether_cdc_bind(struct usbnet *dev, struct usb_interface *intf);
extern int usbnet_cdc_bind(struct usbnet *, struct usb_interface *);
--
2.19.1
^ permalink raw reply related
* [PATCH 6/7] net: huawei_cdc_ncm: add usbnet -> priv function
From: Ben Dooks @ 2018-10-12 9:16 UTC (permalink / raw)
To: davem, netdev
Cc: linux-usb, linux-kernel, linux-kernel, gregkh, bjorn,
steve.glendinning, Ben Dooks
In-Reply-To: <20181012091642.21294-1-ben.dooks@codethink.co.uk>
There are a number of places in the huawei driver where it gets the
private-data from the usbnet passed in. It would be sensible to have
one inline function to convert it and change all points in the driver
to use that.
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
---
drivers/net/usb/huawei_cdc_ncm.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/net/usb/huawei_cdc_ncm.c b/drivers/net/usb/huawei_cdc_ncm.c
index 63f28908afda..d290b8c318be 100644
--- a/drivers/net/usb/huawei_cdc_ncm.c
+++ b/drivers/net/usb/huawei_cdc_ncm.c
@@ -38,9 +38,14 @@ struct huawei_cdc_ncm_state {
struct usb_interface *data;
};
+static inline struct huawei_cdc_ncm_state *usbnet_to_state(struct usbnet *usb)
+{
+ return (struct huawei_cdc_ncm_state *)&usb->data;
+}
+
static int huawei_cdc_ncm_manage_power(struct usbnet *usbnet_dev, int on)
{
- struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;
+ struct huawei_cdc_ncm_state *drvstate = usbnet_to_state(usbnet_dev);
int rv;
if ((on && atomic_add_return(1, &drvstate->pmcount) == 1) ||
@@ -72,7 +77,7 @@ static int huawei_cdc_ncm_bind(struct usbnet *usbnet_dev,
struct cdc_ncm_ctx *ctx;
struct usb_driver *subdriver = ERR_PTR(-ENODEV);
int ret = -ENODEV;
- struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;
+ struct huawei_cdc_ncm_state *drvstate = usbnet_to_state(usbnet_dev);
int drvflags = 0;
/* altsetting should always be 1 for NCM devices - so we hard-coded
@@ -119,7 +124,7 @@ static int huawei_cdc_ncm_bind(struct usbnet *usbnet_dev,
static void huawei_cdc_ncm_unbind(struct usbnet *usbnet_dev,
struct usb_interface *intf)
{
- struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;
+ struct huawei_cdc_ncm_state *drvstate = usbnet_to_state(usbnet_dev);
struct cdc_ncm_ctx *ctx = drvstate->ctx;
if (drvstate->subdriver && drvstate->subdriver->disconnect)
@@ -134,7 +139,7 @@ static int huawei_cdc_ncm_suspend(struct usb_interface *intf,
{
int ret = 0;
struct usbnet *usbnet_dev = usb_get_intfdata(intf);
- struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;
+ struct huawei_cdc_ncm_state *drvstate = usbnet_to_state(usbnet_dev);
struct cdc_ncm_ctx *ctx = drvstate->ctx;
if (ctx == NULL) {
@@ -161,7 +166,7 @@ static int huawei_cdc_ncm_resume(struct usb_interface *intf)
{
int ret = 0;
struct usbnet *usbnet_dev = usb_get_intfdata(intf);
- struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;
+ struct huawei_cdc_ncm_state *drvstate = usbnet_to_state(usbnet_dev);
bool callsub;
struct cdc_ncm_ctx *ctx = drvstate->ctx;
--
2.19.1
^ permalink raw reply related
* [PATCH 7/7] net: usb: sr9800: add usbnet -> priv function
From: Ben Dooks @ 2018-10-12 9:16 UTC (permalink / raw)
To: davem, netdev
Cc: linux-usb, linux-kernel, linux-kernel, gregkh, bjorn,
steve.glendinning, Ben Dooks
In-Reply-To: <20181012091642.21294-1-ben.dooks@codethink.co.uk>
There are a number of places in the sr8900 driver where it gets the
private-data from the usbnet passed in. It would be sensible to have
one inline function to convert it and change all points in the driver
to use that.
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
drivers/net/usb/sr9800.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/net/usb/sr9800.c b/drivers/net/usb/sr9800.c
index 9277a0f228df..2093ecfff5a5 100644
--- a/drivers/net/usb/sr9800.c
+++ b/drivers/net/usb/sr9800.c
@@ -25,6 +25,11 @@
#include "sr9800.h"
+static inline struct sr_data *usbnet_to_sr(struct usbnet *usb)
+{
+ return (struct sr_data *)&usb->data;
+}
+
static int sr_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
u16 size, void *data)
{
@@ -296,7 +301,7 @@ static int sr_write_gpio(struct usbnet *dev, u16 value, int sleep)
static void sr_set_multicast(struct net_device *net)
{
struct usbnet *dev = netdev_priv(net);
- struct sr_data *data = (struct sr_data *)&dev->data;
+ struct sr_data *data = usbnet_to_sr(dev);
u16 rx_ctl = SR_DEFAULT_RX_CTL;
if (net->flags & IFF_PROMISC) {
@@ -436,7 +441,7 @@ sr_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
static int sr_get_eeprom_len(struct net_device *net)
{
struct usbnet *dev = netdev_priv(net);
- struct sr_data *data = (struct sr_data *)&dev->data;
+ struct sr_data *data = usbnet_to_sr(dev);
return data->eeprom_len;
}
@@ -493,7 +498,7 @@ static int sr_ioctl(struct net_device *net, struct ifreq *rq, int cmd)
static int sr_set_mac_address(struct net_device *net, void *p)
{
struct usbnet *dev = netdev_priv(net);
- struct sr_data *data = (struct sr_data *)&dev->data;
+ struct sr_data *data = usbnet_to_sr(dev);
struct sockaddr *addr = p;
if (netif_running(net))
@@ -595,7 +600,7 @@ static int sr9800_set_default_mode(struct usbnet *dev)
static int sr9800_reset(struct usbnet *dev)
{
- struct sr_data *data = (struct sr_data *)&dev->data;
+ struct sr_data *data = usbnet_to_sr(dev);
int ret, embd_phy;
u16 rx_ctl;
@@ -726,7 +731,7 @@ static int sr9800_phy_powerup(struct usbnet *dev)
static int sr9800_bind(struct usbnet *dev, struct usb_interface *intf)
{
- struct sr_data *data = (struct sr_data *)&dev->data;
+ struct sr_data *data = usbnet_to_sr(dev);
u16 led01_mux, led23_mux;
int ret, embd_phy;
u32 phyid;
--
2.19.1
^ permalink raw reply related
* Re: [PATCH net-next v7] net/ncsi: Extend NC-SI Netlink interface to allow user space to send NC-SI command
From: Samuel Mendoza-Jonas @ 2018-10-12 2:39 UTC (permalink / raw)
To: Justin.Lee1, davem
Cc: linux-aspeed, netdev, openbmc, amithash, christian, vijaykhemka
In-Reply-To: <cd371b0265b74889a10241a6af7e4843@AUSX13MPS302.AMER.DELL.COM>
On Thu, 2018-10-11 at 18:07 +0000, Justin.Lee1@Dell.com wrote:
> The new command (NCSI_CMD_SEND_CMD) is added to allow user space application
> to send NC-SI command to the network card.
> Also, add a new attribute (NCSI_ATTR_DATA) for transferring request and response.
>
> The work flow is as below.
>
> Request:
> User space application
> -> Netlink interface (msg)
> -> new Netlink handler - ncsi_send_cmd_nl()
> -> ncsi_xmit_cmd()
>
> Response:
> Response received - ncsi_rcv_rsp()
> -> internal response handler - ncsi_rsp_handler_xxx()
> -> ncsi_rsp_handler_netlink()
> -> ncsi_send_netlink_rsp ()
> -> Netlink interface (msg)
> -> user space application
>
> Command timeout - ncsi_request_timeout()
> -> ncsi_send_netlink_timeout ()
> -> Netlink interface (msg with zero data length)
> -> user space application
>
> Error:
> Error detected
> -> ncsi_send_netlink_err ()
> -> Netlink interface (err msg)
> -> user space application
>
>
> Signed-off-by: Justin Lee <justin.lee1@dell.com>
>
Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
^ permalink raw reply
* Re: [PATCH 1/7] net: smsc75xx: add usbnet -> priv function
From: Greg KH @ 2018-10-12 10:19 UTC (permalink / raw)
To: Ben Dooks
Cc: davem, netdev, linux-usb, linux-kernel, linux-kernel, bjorn,
steve.glendinning
In-Reply-To: <20181012091642.21294-2-ben.dooks@codethink.co.uk>
On Fri, Oct 12, 2018 at 10:16:36AM +0100, Ben Dooks wrote:
> There are a number of places in the smsc75xx driver where it gets the
> private-data from the usbnet passed in. It would be sensible to have
> one inline function to convert it and change all points in the driver
> to use that.
>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply
* Re: [PATCH 4/7] net: qmi_wwan: add usbnet -> priv function
From: Greg KH @ 2018-10-12 10:20 UTC (permalink / raw)
To: Ben Dooks
Cc: davem, netdev, linux-usb, linux-kernel, linux-kernel, bjorn,
steve.glendinning
In-Reply-To: <20181012091642.21294-5-ben.dooks@codethink.co.uk>
On Fri, Oct 12, 2018 at 10:16:39AM +0100, Ben Dooks wrote:
> There are a number of places in the qmi_wwan driver where it gets the
> private-data from the usbnet passed in. It would be sensible to have
> one inline function to convert it and change all points in the driver
> to use that.
>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply
* Re: [PATCH 3/7] net: usb: asix88179_178a: add usbnet -> priv function
From: Greg KH @ 2018-10-12 10:20 UTC (permalink / raw)
To: Ben Dooks
Cc: davem, netdev, linux-usb, linux-kernel, linux-kernel, bjorn,
steve.glendinning
In-Reply-To: <20181012091642.21294-4-ben.dooks@codethink.co.uk>
On Fri, Oct 12, 2018 at 10:16:38AM +0100, Ben Dooks wrote:
> There are a number of places in the asix88179_178a driver where it gets the
> private-data from the usbnet passed in. It would be sensible to have
> one inline function to convert it and change all points in the driver
> to use that.
>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply
* Re: [PATCH 5/7] net: cdc_ether: add usbnet -> priv function
From: Greg KH @ 2018-10-12 10:20 UTC (permalink / raw)
To: Ben Dooks
Cc: davem, netdev, linux-usb, linux-kernel, linux-kernel, bjorn,
steve.glendinning
In-Reply-To: <20181012091642.21294-6-ben.dooks@codethink.co.uk>
On Fri, Oct 12, 2018 at 10:16:40AM +0100, Ben Dooks wrote:
> There are a number of places in the cdc drivers where it gets the
> private-data from the usbnet passed in. It would be sensible to have
> one inline function to convert it and change all points in the driver
> to use that.
>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply
* Re: [PATCH 6/7] net: huawei_cdc_ncm: add usbnet -> priv function
From: Greg KH @ 2018-10-12 10:20 UTC (permalink / raw)
To: Ben Dooks
Cc: davem, netdev, linux-usb, linux-kernel, linux-kernel, bjorn,
steve.glendinning
In-Reply-To: <20181012091642.21294-7-ben.dooks@codethink.co.uk>
On Fri, Oct 12, 2018 at 10:16:41AM +0100, Ben Dooks wrote:
> There are a number of places in the huawei driver where it gets the
> private-data from the usbnet passed in. It would be sensible to have
> one inline function to convert it and change all points in the driver
> to use that.
>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply
* Re: [PATCH 7/7] net: usb: sr9800: add usbnet -> priv function
From: Greg KH @ 2018-10-12 10:20 UTC (permalink / raw)
To: Ben Dooks
Cc: davem, netdev, linux-usb, linux-kernel, linux-kernel, bjorn,
steve.glendinning
In-Reply-To: <20181012091642.21294-8-ben.dooks@codethink.co.uk>
On Fri, Oct 12, 2018 at 10:16:42AM +0100, Ben Dooks wrote:
> There are a number of places in the sr8900 driver where it gets the
> private-data from the usbnet passed in. It would be sensible to have
> one inline function to convert it and change all points in the driver
> to use that.
>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply
* [iproute2-next v2] tipc: support interface name when activating UDP bearer
From: Hoang Le @ 2018-10-12 2:56 UTC (permalink / raw)
To: jon.maloy, maloy, ying.xue, netdev, tipc-discussion
Support for indicating interface name has an ip address in parallel
with specifying ip address when activating UDP bearer.
This liberates the user from keeping track of the current ip address
for each device.
Old command syntax:
$tipc bearer enable media udp name NAME localip IP
New command syntax:
$tipc bearer enable media udp name NAME [localip IP|dev DEVICE]
v2:
- Removed initial value for fd
- Fixed the returning value for cmd_bearer_validate_and_get_addr
to make its consistent with using: zero or non-zero
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Hoang Le <hoang.h.le@dektech.com.au>
---
tipc/bearer.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 60 insertions(+), 5 deletions(-)
diff --git a/tipc/bearer.c b/tipc/bearer.c
index 05dc84aa8ded..aa41af58eac8 100644
--- a/tipc/bearer.c
+++ b/tipc/bearer.c
@@ -19,6 +19,8 @@
#include <linux/tipc_netlink.h>
#include <linux/tipc.h>
#include <linux/genetlink.h>
+#include <linux/if.h>
+#include <sys/ioctl.h>
#include <libmnl/libmnl.h>
#include <sys/socket.h>
@@ -68,7 +70,7 @@ static void cmd_bearer_enable_l2_help(struct cmdl *cmdl, char *media)
static void cmd_bearer_enable_udp_help(struct cmdl *cmdl, char *media)
{
fprintf(stderr,
- "Usage: %s bearer enable [OPTIONS] media %s name NAME localip IP [UDP OPTIONS]\n\n",
+ "Usage: %s bearer enable [OPTIONS] media %s name NAME [localip IP|device DEVICE] [UDP OPTIONS]\n\n",
cmdl->argv[0], media);
fprintf(stderr,
"OPTIONS\n"
@@ -121,6 +123,47 @@ static int generate_multicast(short af, char *buf, int bufsize)
return 0;
}
+static int cmd_bearer_validate_and_get_addr(const char *name, char *straddr)
+{
+ struct ifreq ifc;
+ struct sockaddr_in *ip4addr;
+ struct sockaddr_in6 *ip6addr;
+ int fd;
+
+ if (!name || !straddr)
+ return 0;
+
+ fd = socket(PF_INET, SOCK_DGRAM, 0);
+ if (fd <= 0) {
+ fprintf(stderr, "Failed to create socket\n");
+ return 0;
+ }
+
+ ifc.ifr_name[0] = 0;
+ memcpy(ifc.ifr_name, name, strlen(name));
+ ifc.ifr_name[strlen(name)] = 0;
+
+ if (ioctl(fd, SIOCGIFADDR, &ifc) < 0) {
+ fprintf(stderr, "ioctl failed: %s\n", strerror(errno));
+ close(fd);
+ return 0;
+ }
+
+ ip4addr = (struct sockaddr_in *)&ifc.ifr_addr;
+ if (inet_ntop(AF_INET, &ip4addr->sin_addr, straddr,
+ INET_ADDRSTRLEN) == NULL) {
+ ip6addr = (struct sockaddr_in6 *)&ifc.ifr_addr;
+ if (inet_ntop(AF_INET6, &ip6addr->sin6_addr, straddr,
+ INET6_ADDRSTRLEN) == NULL) {
+ fprintf(stderr, "UDP local address error\n");
+ close(fd);
+ return 0;
+ }
+ }
+ close(fd);
+ return 1;
+}
+
static int nl_add_udp_enable_opts(struct nlmsghdr *nlh, struct opt *opts,
struct cmdl *cmdl)
{
@@ -138,13 +181,25 @@ static int nl_add_udp_enable_opts(struct nlmsghdr *nlh, struct opt *opts,
.ai_family = AF_UNSPEC,
.ai_socktype = SOCK_DGRAM
};
+ char addr[INET6_ADDRSTRLEN] = {0};
- if (!(opt = get_opt(opts, "localip"))) {
- fprintf(stderr, "error, udp bearer localip missing\n");
- cmd_bearer_enable_udp_help(cmdl, "udp");
+ opt = get_opt(opts, "device");
+ if (opt && !cmd_bearer_validate_and_get_addr(opt->val, addr)) {
+ fprintf(stderr, "error, no device name available\n");
return -EINVAL;
}
- locip = opt->val;
+
+ if (strlen(addr) > 0) {
+ locip = addr;
+ } else {
+ opt = get_opt(opts, "localip");
+ if (!opt) {
+ fprintf(stderr, "error, udp bearer localip/device missing\n");
+ cmd_bearer_enable_udp_help(cmdl, "udp");
+ return -EINVAL;
+ }
+ locip = opt->val;
+ }
if ((opt = get_opt(opts, "remoteip")))
remip = opt->val;
--
2.17.1
^ permalink raw reply related
* [PATCH] net: fix waring in af_unix
From: Kyeongdon Kim @ 2018-10-12 10:34 UTC (permalink / raw)
To: davem, ktkhai, viro, garsilva, jbaron, dvlasenk, xiyou.wangcong
Cc: netdev, linux-kernel, kyeongdon.kim
This fixes the "'hash' may be used uninitialized in this function"
net/unix/af_unix.c:1041:20: warning: 'hash' may be used uninitialized in this function [-Wmaybe-uninitialized]
addr->hash = hash ^ sk->sk_type;
^
Signed-off-by: Kyeongdon Kim <kyeongdon.kim@lge.com>
---
net/unix/af_unix.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index d1edfa3..e6cecc8 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -989,7 +989,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
struct sockaddr_un *sunaddr = (struct sockaddr_un *)uaddr;
char *sun_path = sunaddr->sun_path;
int err;
- unsigned int hash;
+ unsigned int hash = 0;
struct unix_address *addr;
struct hlist_head *list;
struct path path = { };
--
2.6.2
^ permalink raw reply related
* Re: [PATCH bpf-next 2/2] bpf, libbpf: simplify perf RB walk and do incremental updates
From: Jakub Kicinski @ 2018-10-12 3:04 UTC (permalink / raw)
To: Daniel Borkmann; +Cc: alexei.starovoitov, netdev
In-Reply-To: <20181011140207.27602-3-daniel@iogearbox.net>
On Thu, 11 Oct 2018 16:02:07 +0200, Daniel Borkmann wrote:
> Clean up and improve bpf_perf_event_read_simple() ring walk a bit
> to use similar tail update scheme as in perf and bcc allowing the
> kernel to make forward progress not only after full timely walk.
The extra memory barriers won't impact performance? If I read the code
correctly we now have:
while (bla) {
head = HEAD
rmb()
...
mb()
TAIL = tail
}
Would it make sense to try to piggy back on the mb() for head re-read
at least? Perhaps that's a non-issue, just wondering.
> Also few other improvements to use realloc() instead of free() and
> malloc() combination and for the callback use proper perf_event_header
> instead of void pointer, so that real applications can use container_of()
> macro with proper type checking.
FWIW the free() + malloc() was to avoid the the needless copy of the
previous event realloc() may do. It makes sense to use realloc()
especially if you want to put extra info in front of the buffer, just
sayin' it wasn't a complete braino ;)
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
^ permalink raw reply
* Re: [PATCH 4/7] net: qmi_wwan: add usbnet -> priv function
From: Bjørn Mork @ 2018-10-12 10:44 UTC (permalink / raw)
To: Ben Dooks
Cc: davem, netdev, linux-usb, linux-kernel, linux-kernel, gregkh,
steve.glendinning
In-Reply-To: <20181012091642.21294-5-ben.dooks@codethink.co.uk>
Ben Dooks <ben.dooks@codethink.co.uk> writes:
> +static inline struct qmi_wwan_state *usbnet_to_qmi(struct usbnet *usb)
> +{
> + return (void *) &usb->data;
> +}
checkpatch doesn't like this, and it is also inconsistent with the
coding style elsewhere in the driver.
CHECK: No space is necessary after a cast
#30: FILE: drivers/net/usb/qmi_wwan.c:81:
+ return (void *) &usb->data;
total: 0 errors, 0 warnings, 1 checks, 115 lines checked
And as for consistency: I realize that "dev" is a very generic name,
but it's used consistendly for all struct usbnet pointers in the driver:
bjorn@miraculix:/usr/local/src/git/linux$ git grep 'struct usbnet' drivers/net/usb/qmi_wwan.c
drivers/net/usb/qmi_wwan.c:static struct net_device *qmimux_find_dev(struct usbnet *dev, u8 mux_id)
drivers/net/usb/qmi_wwan.c:static bool qmimux_has_slaves(struct usbnet *dev)
drivers/net/usb/qmi_wwan.c:static int qmimux_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
drivers/net/usb/qmi_wwan.c: struct usbnet *dev = netdev_priv(net);
drivers/net/usb/qmi_wwan.c: struct usbnet *dev = netdev_priv(to_net_dev(d));
drivers/net/usb/qmi_wwan.c: struct usbnet *dev = netdev_priv(to_net_dev(d));
drivers/net/usb/qmi_wwan.c: struct usbnet *dev = netdev_priv(to_net_dev(d));
drivers/net/usb/qmi_wwan.c: struct usbnet *dev = netdev_priv(to_net_dev(d));
drivers/net/usb/qmi_wwan.c:static int qmi_wwan_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
drivers/net/usb/qmi_wwan.c:static int qmi_wwan_manage_power(struct usbnet *dev, int on)
drivers/net/usb/qmi_wwan.c: struct usbnet *dev = usb_get_intfdata(intf);
drivers/net/usb/qmi_wwan.c:static int qmi_wwan_register_subdriver(struct usbnet *dev)
drivers/net/usb/qmi_wwan.c:static int qmi_wwan_change_dtr(struct usbnet *dev, bool on)
drivers/net/usb/qmi_wwan.c:static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
drivers/net/usb/qmi_wwan.c: BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data) <
drivers/net/usb/qmi_wwan.c:static void qmi_wwan_unbind(struct usbnet *dev, struct usb_interface *intf)
drivers/net/usb/qmi_wwan.c: struct usbnet *dev = usb_get_intfdata(intf);
drivers/net/usb/qmi_wwan.c: struct usbnet *dev = usb_get_intfdata(intf);
drivers/net/usb/qmi_wwan.c: struct usbnet *dev = usb_get_intfdata(intf);
The name was chosen to be consistent with the cdc_ether usage. I'd
prefer it if this function could use the "dev" name, to avoid confusing
things unnecessarly with yet another generic name like "usb". Which
isn't used anywhere else in the driver, and could just as easily refer
to a struct usb_device or struct usb_interface.
(yes, I know there are a couple of "struct usb_device *dev" cases. But
I'd rather see those renamed TBH)
I also don't see why this function should be qmi_wwan specific. No need
to duplicate the same function in every minidriver, when you can do with
two generic helpers (maybe with more meaningful names):
static inline void *usbnet_priv(const struct usbnet *dev)
{
return (void *)&dev->data;
}
static inline void *usbnet_priv0(const struct usbnet * *dev)
{
return (void *)dev->data[0];
}
Please fix the checkpatch warning and consider the other comments.
Personally I don't really think it makes the code any easier to read.
But if you want it, then I'm fine this. I guess I've grown too used to
seeing those casts ;-)
Bjørn
^ permalink raw reply
* [PATCH v2 net-next] net/ipv6: Add knob to skip DELROUTE message on device down
From: David Ahern @ 2018-10-12 3:17 UTC (permalink / raw)
To: netdev, davem; +Cc: roopa, David Ahern
From: David Ahern <dsahern@gmail.com>
Another difference between IPv4 and IPv6 is the generation of RTM_DELROUTE
notifications when a device is taken down (admin down) or deleted. IPv4
does not generate a message for routes evicted by the down or delete;
IPv6 does. A NOS at scale really needs to avoid these messages and have
IPv4 and IPv6 behave similarly, relying on userspace to handle link
notifications and evict the routes.
At this point existing user behavior needs to be preserved. Since
notifications are a global action (not per app) the only way to preserve
existing behavior and allow the messages to be skipped is to add a new
sysctl (net/ipv6/route/skip_notify_on_dev_down) which can be set to
disable the notificatioons.
IPv6 route code already supports the option to skip the message (it is
used for multipath routes for example). Besides the new sysctl we need
to pass the skip_notify setting through the generic fib6_clean and
fib6_walk functions to fib6_clean_node and to set skip_notify on calls
to __ip_del_rt for the addrconf_ifdown path.
Signed-off-by: David Ahern <dsahern@gmail.com>
---
v2
- removed the changes to addrconf and anycast. addrconf_ifdown calls
rt6_disable_ip which calls rt6_sync_down_dev. The last one evicts all
routes for the device, so the delete route calls done later in addrconf
and anycast are superfluous
Documentation/networking/ip-sysctl.txt | 8 ++++++++
include/net/ip6_fib.h | 3 +++
include/net/netns/ipv6.h | 1 +
net/ipv6/ip6_fib.c | 20 +++++++++++++++-----
net/ipv6/route.c | 20 +++++++++++++++++++-
5 files changed, 46 insertions(+), 6 deletions(-)
diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
index 960de8fe3f40..163b5ff1073c 100644
--- a/Documentation/networking/ip-sysctl.txt
+++ b/Documentation/networking/ip-sysctl.txt
@@ -1442,6 +1442,14 @@ max_hbh_length - INTEGER
header.
Default: INT_MAX (unlimited)
+skip_notify_on_dev_down - BOOLEAN
+ Controls whether an RTM_DELROUTE message is generated for routes
+ removed when a device is taken down or deleted. IPv4 does not
+ generate this message; IPv6 does by default. Setting this sysctl
+ to true skips the message, making IPv4 and IPv6 on par in relying
+ on userspace caches to track link events and evict routes.
+ Default: false (generate message)
+
IPv6 Fragmentation:
ip6frag_high_thresh - INTEGER
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index f06e968f1992..caabfd84a098 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -407,6 +407,9 @@ struct fib6_node *fib6_locate(struct fib6_node *root,
void fib6_clean_all(struct net *net, int (*func)(struct fib6_info *, void *arg),
void *arg);
+void fib6_clean_all_skip_notify(struct net *net,
+ int (*func)(struct fib6_info *, void *arg),
+ void *arg);
int fib6_add(struct fib6_node *root, struct fib6_info *rt,
struct nl_info *info, struct netlink_ext_ack *extack);
diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
index f0e396ab9bec..ef1ed529f33c 100644
--- a/include/net/netns/ipv6.h
+++ b/include/net/netns/ipv6.h
@@ -45,6 +45,7 @@ struct netns_sysctl_ipv6 {
int max_dst_opts_len;
int max_hbh_opts_len;
int seg6_flowlabel;
+ bool skip_notify_on_dev_down;
};
struct netns_ipv6 {
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index e14d244c551f..9ba72d94d60f 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -47,6 +47,7 @@ struct fib6_cleaner {
int (*func)(struct fib6_info *, void *arg);
int sernum;
void *arg;
+ bool skip_notify;
};
#ifdef CONFIG_IPV6_SUBTREES
@@ -1956,6 +1957,7 @@ static int fib6_clean_node(struct fib6_walker *w)
struct fib6_cleaner *c = container_of(w, struct fib6_cleaner, w);
struct nl_info info = {
.nl_net = c->net,
+ .skip_notify = c->skip_notify,
};
if (c->sernum != FIB6_NO_SERNUM_CHANGE &&
@@ -2007,7 +2009,7 @@ static int fib6_clean_node(struct fib6_walker *w)
static void fib6_clean_tree(struct net *net, struct fib6_node *root,
int (*func)(struct fib6_info *, void *arg),
- int sernum, void *arg)
+ int sernum, void *arg, bool skip_notify)
{
struct fib6_cleaner c;
@@ -2019,13 +2021,14 @@ static void fib6_clean_tree(struct net *net, struct fib6_node *root,
c.sernum = sernum;
c.arg = arg;
c.net = net;
+ c.skip_notify = skip_notify;
fib6_walk(net, &c.w);
}
static void __fib6_clean_all(struct net *net,
int (*func)(struct fib6_info *, void *),
- int sernum, void *arg)
+ int sernum, void *arg, bool skip_notify)
{
struct fib6_table *table;
struct hlist_head *head;
@@ -2037,7 +2040,7 @@ static void __fib6_clean_all(struct net *net,
hlist_for_each_entry_rcu(table, head, tb6_hlist) {
spin_lock_bh(&table->tb6_lock);
fib6_clean_tree(net, &table->tb6_root,
- func, sernum, arg);
+ func, sernum, arg, skip_notify);
spin_unlock_bh(&table->tb6_lock);
}
}
@@ -2047,14 +2050,21 @@ static void __fib6_clean_all(struct net *net,
void fib6_clean_all(struct net *net, int (*func)(struct fib6_info *, void *),
void *arg)
{
- __fib6_clean_all(net, func, FIB6_NO_SERNUM_CHANGE, arg);
+ __fib6_clean_all(net, func, FIB6_NO_SERNUM_CHANGE, arg, false);
+}
+
+void fib6_clean_all_skip_notify(struct net *net,
+ int (*func)(struct fib6_info *, void *),
+ void *arg)
+{
+ __fib6_clean_all(net, func, FIB6_NO_SERNUM_CHANGE, arg, true);
}
static void fib6_flush_trees(struct net *net)
{
int new_sernum = fib6_new_sernum(net);
- __fib6_clean_all(net, NULL, new_sernum, NULL);
+ __fib6_clean_all(net, NULL, new_sernum, NULL, false);
}
/*
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index bf4cd647d8b8..f4e08b0689a8 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -4026,8 +4026,12 @@ void rt6_sync_down_dev(struct net_device *dev, unsigned long event)
.event = event,
},
};
+ struct net *net = dev_net(dev);
- fib6_clean_all(dev_net(dev), fib6_ifdown, &arg);
+ if (net->ipv6.sysctl.skip_notify_on_dev_down)
+ fib6_clean_all_skip_notify(net, fib6_ifdown, &arg);
+ else
+ fib6_clean_all(net, fib6_ifdown, &arg);
}
void rt6_disable_ip(struct net_device *dev, unsigned long event)
@@ -5031,6 +5035,9 @@ int ipv6_sysctl_rtcache_flush(struct ctl_table *ctl, int write,
return 0;
}
+static int zero;
+static int one = 1;
+
static struct ctl_table ipv6_route_table_template[] = {
{
.procname = "flush",
@@ -5102,6 +5109,15 @@ static struct ctl_table ipv6_route_table_template[] = {
.mode = 0644,
.proc_handler = proc_dointvec_ms_jiffies,
},
+ {
+ .procname = "skip_notify_on_dev_down",
+ .data = &init_net.ipv6.sysctl.skip_notify_on_dev_down,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = proc_dointvec,
+ .extra1 = &zero,
+ .extra2 = &one,
+ },
{ }
};
@@ -5125,6 +5141,7 @@ struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
table[7].data = &net->ipv6.sysctl.ip6_rt_mtu_expires;
table[8].data = &net->ipv6.sysctl.ip6_rt_min_advmss;
table[9].data = &net->ipv6.sysctl.ip6_rt_gc_min_interval;
+ table[10].data = &net->ipv6.sysctl.skip_notify_on_dev_down;
/* Don't export sysctls to unprivileged users */
if (net->user_ns != &init_user_ns)
@@ -5189,6 +5206,7 @@ static int __net_init ip6_route_net_init(struct net *net)
net->ipv6.sysctl.ip6_rt_gc_elasticity = 9;
net->ipv6.sysctl.ip6_rt_mtu_expires = 10*60*HZ;
net->ipv6.sysctl.ip6_rt_min_advmss = IPV6_MIN_MTU - 20 - 40;
+ net->ipv6.sysctl.skip_notify_on_dev_down = 0;
net->ipv6.ip6_rt_gc_expire = 30*HZ;
--
2.11.0
^ permalink raw reply related
* [PATCH v4] Wait for running BPF programs when updating map-in-map
From: Daniel Colascione @ 2018-10-12 10:54 UTC (permalink / raw)
To: joelaf
Cc: linux-kernel, timmurray, netdev, Alexei Starovoitov,
Lorenzo Colitti, Chenbo Feng, Mathieu Desnoyers,
Alexei Starovoitov, Daniel Borkmann, Daniel Colascione
In-Reply-To: <20180816040145.gqzqicab4s6kcbye@ast-mbp.dhcp.thefacebook.com>
The map-in-map frequently serves as a mechanism for atomic
snapshotting of state that a BPF program might record. The current
implementation is dangerous to use in this way, however, since
userspace has no way of knowing when all programs that might have
retrieved the "old" value of the map may have completed.
This change ensures that map update operations on map-in-map map types
always wait for all references to the old map to drop before returning
to userspace.
Signed-off-by: Daniel Colascione <dancol@google.com>
---
kernel/bpf/syscall.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 8339d81cba1d..d7c16ae1e85a 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -741,6 +741,18 @@ static int map_lookup_elem(union bpf_attr *attr)
return err;
}
+static void maybe_wait_bpf_programs(struct bpf_map *map)
+{
+ /* Wait for any running BPF programs to complete so that
+ * userspace, when we return to it, knows that all programs
+ * that could be running use the new map value.
+ */
+ if (map->map_type == BPF_MAP_TYPE_HASH_OF_MAPS ||
+ map->map_type == BPF_MAP_TYPE_ARRAY_OF_MAPS) {
+ synchronize_rcu();
+ }
+}
+
#define BPF_MAP_UPDATE_ELEM_LAST_FIELD flags
static int map_update_elem(union bpf_attr *attr)
@@ -831,6 +843,7 @@ static int map_update_elem(union bpf_attr *attr)
}
__this_cpu_dec(bpf_prog_active);
preempt_enable();
+ maybe_wait_bpf_programs(map);
out:
free_value:
kfree(value);
@@ -883,6 +896,7 @@ static int map_delete_elem(union bpf_attr *attr)
rcu_read_unlock();
__this_cpu_dec(bpf_prog_active);
preempt_enable();
+ maybe_wait_bpf_programs(map);
out:
kfree(key);
err_put:
--
2.19.0.605.g01d371f741-goog
^ permalink raw reply related
* [PATCH net-next] net: Evict neighbor entries on carrier down
From: David Ahern @ 2018-10-12 3:33 UTC (permalink / raw)
To: netdev, davem; +Cc: roopa, idosch, David Ahern
From: David Ahern <dsahern@gmail.com>
When a link's carrier goes down it could be a sign of the port changing
networks. If the new network has overlapping addresses with the old one,
then the kernel will continue trying to use neighbor entries established
based on the old network until the entries finally age out - meaning a
potentially long delay with communications not working.
This patch evicts neighbor entries on carrier down with the exception of
those marked permanent. Permanent entries are managed by userspace (either
an admin or a routing daemon such as FRR).
Signed-off-by: David Ahern <dsahern@gmail.com>
---
include/net/neighbour.h | 1 +
net/core/neighbour.c | 27 +++++++++++++++++++++++----
net/ipv4/arp.c | 2 ++
net/ipv6/ndisc.c | 2 ++
4 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index 0874f7fcd859..f58b384aa6c9 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -323,6 +323,7 @@ void __neigh_set_probe_once(struct neighbour *neigh);
bool neigh_remove_one(struct neighbour *ndel, struct neigh_table *tbl);
void neigh_changeaddr(struct neigh_table *tbl, struct net_device *dev);
int neigh_ifdown(struct neigh_table *tbl, struct net_device *dev);
+int neigh_carrier_down(struct neigh_table *tbl, struct net_device *dev);
int neigh_resolve_output(struct neighbour *neigh, struct sk_buff *skb);
int neigh_connected_output(struct neighbour *neigh, struct sk_buff *skb);
int neigh_direct_output(struct neighbour *neigh, struct sk_buff *skb);
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index dc1389b8beb1..69c41cb3966d 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -232,7 +232,8 @@ static void pneigh_queue_purge(struct sk_buff_head *list)
}
}
-static void neigh_flush_dev(struct neigh_table *tbl, struct net_device *dev)
+static void neigh_flush_dev(struct neigh_table *tbl, struct net_device *dev,
+ bool skip_perm)
{
int i;
struct neigh_hash_table *nht;
@@ -250,6 +251,10 @@ static void neigh_flush_dev(struct neigh_table *tbl, struct net_device *dev)
np = &n->next;
continue;
}
+ if (skip_perm && n->nud_state & NUD_PERMANENT) {
+ np = &n->next;
+ continue;
+ }
rcu_assign_pointer(*np,
rcu_dereference_protected(n->next,
lockdep_is_held(&tbl->lock)));
@@ -285,21 +290,35 @@ static void neigh_flush_dev(struct neigh_table *tbl, struct net_device *dev)
void neigh_changeaddr(struct neigh_table *tbl, struct net_device *dev)
{
write_lock_bh(&tbl->lock);
- neigh_flush_dev(tbl, dev);
+ neigh_flush_dev(tbl, dev, false);
write_unlock_bh(&tbl->lock);
}
EXPORT_SYMBOL(neigh_changeaddr);
-int neigh_ifdown(struct neigh_table *tbl, struct net_device *dev)
+static int __neigh_ifdown(struct neigh_table *tbl, struct net_device *dev,
+ bool skip_perm)
{
write_lock_bh(&tbl->lock);
- neigh_flush_dev(tbl, dev);
+ neigh_flush_dev(tbl, dev, skip_perm);
pneigh_ifdown_and_unlock(tbl, dev);
del_timer_sync(&tbl->proxy_timer);
pneigh_queue_purge(&tbl->proxy_queue);
return 0;
}
+
+int neigh_carrier_down(struct neigh_table *tbl, struct net_device *dev)
+{
+ __neigh_ifdown(tbl, dev, true);
+ return 0;
+}
+EXPORT_SYMBOL(neigh_carrier_down);
+
+int neigh_ifdown(struct neigh_table *tbl, struct net_device *dev)
+{
+ __neigh_ifdown(tbl, dev, false);
+ return 0;
+}
EXPORT_SYMBOL(neigh_ifdown);
static struct neighbour *neigh_alloc(struct neigh_table *tbl, struct net_device *dev)
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index e90c89ef8c08..850a6f13a082 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -1255,6 +1255,8 @@ static int arp_netdev_event(struct notifier_block *this, unsigned long event,
change_info = ptr;
if (change_info->flags_changed & IFF_NOARP)
neigh_changeaddr(&arp_tbl, dev);
+ if (!netif_carrier_ok(dev))
+ neigh_carrier_down(&arp_tbl, dev);
break;
default:
break;
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 51863ada15a4..a25cfdd47c89 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1784,6 +1784,8 @@ static int ndisc_netdev_event(struct notifier_block *this, unsigned long event,
change_info = ptr;
if (change_info->flags_changed & IFF_NOARP)
neigh_changeaddr(&nd_tbl, dev);
+ if (!netif_carrier_ok(dev))
+ neigh_carrier_down(&nd_tbl, dev);
break;
case NETDEV_DOWN:
neigh_ifdown(&nd_tbl, dev);
--
2.11.0
^ permalink raw reply related
* pull-request: mac80211-next 2018-10-12
From: Johannes Berg @ 2018-10-12 11:13 UTC (permalink / raw)
To: David Miller
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
linux-wireless-u79uwXL29TY76Z2rM5mHXA
Hi Dave,
Here's another set of updates. Note that there's a patch here
(lib80211 skcipher removal to simplify the code) that will
cause conflicts when merging with the crypto tree, the new
code from this should be used. Please advise Greg/Linus unless
the crypto tree will somehow end up in your tree first?
Please pull and let me know if there's any problem.
Thanks,
johannes
The following changes since commit abf1a08ff3237a27188ff8cc2904f2cea893af55:
net: vhost: remove bad code line (2018-10-07 21:31:32 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git tags/mac80211-next-for-davem-2018-10-12
for you to fetch changes up to f8252e7b5a83deee0e477fc1e31e3f06ceb35d28:
mac80211: implement ieee80211_tx_rate_update to update rate (2018-10-12 13:05:40 +0200)
----------------------------------------------------------------
Highlights:
* merge net-next, so I can finish the hwsim workqueue removal
* fix TXQ NULL pointer issue that was reported multiple times
* minstrel cleanups from Felix
* simplify lib80211 code by not using skcipher, note that this
will conflict with the crypto tree (and this new code here
should be used)
* use new netlink policy validation in nl80211
* fix up SAE (part of WPA3) in client-mode
* FTM responder support in the stack
----------------------------------------------------------------
Andrew Zaborowski (1):
nl80211: Fix a GET_KEY reply attribute
Anilkumar Kolli (1):
mac80211: implement ieee80211_tx_rate_update to update rate
Ankita Bajaj (1):
nl80211: Add per peer statistics to compute FCS error rate
Chaitanya T K (1):
mac80211: minstrel: Enable STBC and LDPC for VHT Rates
Colin Ian King (1):
cfg80211: remove redundant check of !scan_plan
Erik Stromdahl (1):
mac80211: fix issue with possible txq NULL pointer
Felix Fietkau (8):
mac80211: minstrel: remove unnecessary debugfs cleanup code
mac80211: minstrel: merge with minstrel_ht, always enable VHT support
mac80211: minstrel: reduce minstrel_mcs_groups size
mac80211: minstrel: fix using short preamble CCK rates on HT clients
mac80211: minstrel: fix CCK rate group streams value
mac80211: minstrel: fix sampling/reporting of CCK rates in HT mode
mac80211: minstrel: do not sample rates 3 times slower than max_prob_rate
mac80211: rc80211_minstrel: remove variance / stddev calculation
Johannes Berg (14):
cfg80211: combine duplicate wdev init code
cfg80211: tracing: reuse wiphy_wdev_evt for rdev_get_txq_stats
nl80211: remove nl80211_prepare_wdev_dump() skb argument
cfg80211: regulatory: make initialization more robust
cfg80211: move cookie_counter out of wiphy
nl80211: add error messages to nl80211_parse_chandef()
cfg80211: combine wdev/netdev unregister code
cfg80211: unify sending NL80211_CMD_NEW_INTERFACE
cfg80211: sort tracing properly
Merge remote-tracking branch 'net-next/master' into mac80211-next
lib80211: don't use skcipher
nl80211: use policy range validation where applicable
nl80211: use netlink policy validation function for elements
mac80211: avoid reflecting frames back to the client
Jouni Malinen (3):
mac80211: Helper function for marking STA authenticated
mac80211: Move ieee80211_mgd_auth() EBUSY check to be before allocation
mac80211: Extend SAE authentication in infra BSS STA mode
Martin Willi (1):
mac80211_hwsim: drop now unused work-queue from hwsim
Masashi Honma (1):
mac80211: Remove unused initialization
Pradeep Kumar Chitrapu (2):
cfg80211: support FTM responder configuration/statistics
mac80211: support FTM responder configuration/statistics
Wei Yongjun (1):
mac80211: fix error handling in ieee80211_register_hw()
zhong jiang (1):
cfg80211: remove unnecessary null pointer check in cfg80211_netdev_notifier_call
drivers/net/wireless/mac80211_hwsim.c | 11 +-
include/linux/ieee80211.h | 1 +
include/net/cfg80211.h | 62 ++-
include/net/mac80211.h | 43 ++
include/uapi/linux/nl80211.h | 98 ++++
net/mac80211/Kconfig | 17 +-
net/mac80211/Makefile | 11 +-
net/mac80211/cfg.c | 85 +++
net/mac80211/driver-ops.h | 16 +
net/mac80211/ieee80211_i.h | 1 +
net/mac80211/main.c | 11 +-
net/mac80211/mlme.c | 107 ++--
net/mac80211/rate.h | 13 -
net/mac80211/rc80211_minstrel.c | 162 ------
net/mac80211/rc80211_minstrel.h | 35 +-
net/mac80211/rc80211_minstrel_debugfs.c | 68 +--
net/mac80211/rc80211_minstrel_ht.c | 298 +++++++----
net/mac80211/rc80211_minstrel_ht.h | 20 +-
net/mac80211/rc80211_minstrel_ht_debugfs.c | 58 +-
net/mac80211/rx.c | 12 +-
net/mac80211/status.c | 19 +
net/mac80211/trace.h | 23 +
net/mac80211/util.c | 8 +
net/wireless/core.c | 83 +--
net/wireless/core.h | 14 +
net/wireless/lib80211_crypt_tkip.c | 59 +-
net/wireless/lib80211_crypt_wep.c | 52 +-
net/wireless/nl80211.c | 830 ++++++++++++++---------------
net/wireless/rdev-ops.h | 15 +
net/wireless/reg.c | 9 +
net/wireless/trace.h | 233 ++++----
31 files changed, 1338 insertions(+), 1136 deletions(-)
^ permalink raw reply
* [PATCHv2 2/2] dt-bindings: can: xilinx_can: add Xilinx CAN FD 2.0 bindings
From: shubhrajyoti.datta @ 2018-10-12 4:25 UTC (permalink / raw)
To: linux-can, netdev, devicetree
Cc: robh+dt, michal.simek, davem, mkl, wg, Shubhrajyoti Datta
In-Reply-To: <1539318309-13715-1-git-send-email-shubhrajyoti.datta@gmail.com>
From: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
Add compatible string and new attributes to support the Xilinx CAN
FD 2.0.
Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
---
Documentation/devicetree/bindings/net/can/xilinx_can.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/net/can/xilinx_can.txt b/Documentation/devicetree/bindings/net/can/xilinx_can.txt
index 060e2d4..100cc40b 100644
--- a/Documentation/devicetree/bindings/net/can/xilinx_can.txt
+++ b/Documentation/devicetree/bindings/net/can/xilinx_can.txt
@@ -6,6 +6,7 @@ Required properties:
- "xlnx,zynq-can-1.0" for Zynq CAN controllers
- "xlnx,axi-can-1.00.a" for Axi CAN controllers
- "xlnx,canfd-1.0" for CAN FD controllers
+ - "xlnx,canfd-2.0" for CAN FD 2.0 controllers
- reg : Physical base address and size of the controller
registers map.
- interrupts : Property with a value describing the interrupt
--
2.1.1
^ permalink raw reply related
* [PATCHv2 1/2] can: xilinx: add can 2.0 support
From: shubhrajyoti.datta @ 2018-10-12 4:25 UTC (permalink / raw)
To: linux-can, netdev, devicetree
Cc: robh+dt, michal.simek, davem, mkl, wg, Shubhrajyoti Datta
From: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
Add support for can 2.0.
Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
---
drivers/net/can/xilinx_can.c | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/drivers/net/can/xilinx_can.c b/drivers/net/can/xilinx_can.c
index 045f084..7c4f5ad 100644
--- a/drivers/net/can/xilinx_can.c
+++ b/drivers/net/can/xilinx_can.c
@@ -63,6 +63,7 @@ enum xcan_reg {
XCAN_FSR_OFFSET = 0x00E8, /* RX FIFO Status */
XCAN_TXMSG_BASE_OFFSET = 0x0100, /* TX Message Space */
XCAN_RXMSG_BASE_OFFSET = 0x1100, /* RX Message Space */
+ XCAN_RXMSG_2_BASE_OFFSET = 0x2100, /* RX Message Space */
};
#define XCAN_FRAME_ID_OFFSET(frame_base) ((frame_base) + 0x00)
@@ -75,6 +76,8 @@ enum xcan_reg {
XCAN_CANFD_FRAME_SIZE * (n))
#define XCAN_RXMSG_FRAME_OFFSET(n) (XCAN_RXMSG_BASE_OFFSET + \
XCAN_CANFD_FRAME_SIZE * (n))
+#define XCAN_RXMSG_2_FRAME_OFFSET(n) (XCAN_RXMSG_2_BASE_OFFSET + \
+ XCAN_CANFD_FRAME_SIZE * (n))
/* the single TX mailbox used by this driver on CAN FD HW */
#define XCAN_TX_MAILBOX_IDX 0
@@ -152,6 +155,7 @@ enum xcan_reg {
* instead of the regular FIFO at 0x50
*/
#define XCAN_FLAG_RX_FIFO_MULTI 0x0010
+#define XCAN_FLAG_CANFD_2 0x0020
struct xcan_devtype_data {
unsigned int flags;
@@ -221,6 +225,18 @@ static const struct can_bittiming_const xcan_bittiming_const_canfd = {
.brp_inc = 1,
};
+static const struct can_bittiming_const xcan_bittiming_const_canfd2 = {
+ .name = DRIVER_NAME,
+ .tseg1_min = 1,
+ .tseg1_max = 256,
+ .tseg2_min = 1,
+ .tseg2_max = 128,
+ .sjw_max = 128,
+ .brp_min = 1,
+ .brp_max = 256,
+ .brp_inc = 1,
+};
+
/**
* xcan_write_reg_le - Write a value to the device register little endian
* @priv: Driver private data structure
@@ -973,7 +989,10 @@ static int xcan_rx_fifo_get_next_frame(struct xcan_priv *priv)
if (!(fsr & XCAN_FSR_FL_MASK))
return -ENOENT;
- offset = XCAN_RXMSG_FRAME_OFFSET(fsr & XCAN_FSR_RI_MASK);
+ if (priv->devtype.flags & XCAN_FLAG_CANFD_2)
+ offset = XCAN_RXMSG_2_FRAME_OFFSET(fsr & XCAN_FSR_RI_MASK);
+ else
+ offset = XCAN_RXMSG_FRAME_OFFSET(fsr & XCAN_FSR_RI_MASK);
} else {
/* check if RX FIFO is empty */
@@ -1430,11 +1449,24 @@ static const struct xcan_devtype_data xcan_canfd_data = {
.bus_clk_name = "s_axi_aclk",
};
+static const struct xcan_devtype_data xcan_canfd2_data = {
+ .flags = XCAN_FLAG_EXT_FILTERS |
+ XCAN_FLAG_RXMNF |
+ XCAN_FLAG_TX_MAILBOXES |
+ XCAN_FLAG_CANFD_2 |
+ XCAN_FLAG_RX_FIFO_MULTI,
+ .bittiming_const = &xcan_bittiming_const_canfd2,
+ .btr_ts2_shift = XCAN_BTR_TS2_SHIFT_CANFD,
+ .btr_sjw_shift = XCAN_BTR_SJW_SHIFT_CANFD,
+ .bus_clk_name = "s_axi_aclk",
+};
+
/* Match table for OF platform binding */
static const struct of_device_id xcan_of_match[] = {
{ .compatible = "xlnx,zynq-can-1.0", .data = &xcan_zynq_data },
{ .compatible = "xlnx,axi-can-1.00.a", .data = &xcan_axi_data },
{ .compatible = "xlnx,canfd-1.0", .data = &xcan_canfd_data },
+ { .compatible = "xlnx,canfd-2.0", .data = &xcan_canfd2_data },
{ /* end of list */ },
};
MODULE_DEVICE_TABLE(of, xcan_of_match);
--
2.1.1
^ permalink raw reply related
* [PATCH ipsec-next] xfrm: use complete IPv6 addresses for hash
From: Michal Kubecek @ 2018-10-12 12:24 UTC (permalink / raw)
To: Steffen Klassert; +Cc: Herbert Xu, David S. Miller, netdev, linux-kernel
In some environments it is common that many hosts share the same lower half
of their IPv6 addresses (in particular ::1). As __xfrm6_addr_hash() and
__xfrm6_daddr_saddr_hash() calculate the hash only from the lower halves,
as much as 1/3 of the hosts ends up in one hashtable chain which harms the
performance.
Use complete IPv6 addresses when calculating the hashes. Rather than just
adding two more words to the xor, use jhash2() for consistency with
__xfrm6_pref_hash() and __xfrm6_dpref_spref_hash().
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
net/xfrm/xfrm_hash.h | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/net/xfrm/xfrm_hash.h b/net/xfrm/xfrm_hash.h
index 61be810389d8..ce66323102f9 100644
--- a/net/xfrm/xfrm_hash.h
+++ b/net/xfrm/xfrm_hash.h
@@ -13,7 +13,7 @@ static inline unsigned int __xfrm4_addr_hash(const xfrm_address_t *addr)
static inline unsigned int __xfrm6_addr_hash(const xfrm_address_t *addr)
{
- return ntohl(addr->a6[2] ^ addr->a6[3]);
+ return jhash2((__force u32 *)addr->a6, 4, 0);
}
static inline unsigned int __xfrm4_daddr_saddr_hash(const xfrm_address_t *daddr,
@@ -26,8 +26,7 @@ static inline unsigned int __xfrm4_daddr_saddr_hash(const xfrm_address_t *daddr,
static inline unsigned int __xfrm6_daddr_saddr_hash(const xfrm_address_t *daddr,
const xfrm_address_t *saddr)
{
- return ntohl(daddr->a6[2] ^ daddr->a6[3] ^
- saddr->a6[2] ^ saddr->a6[3]);
+ return __xfrm6_addr_hash(daddr) ^ __xfrm6_addr_hash(saddr);
}
static inline u32 __bits2mask32(__u8 bits)
--
2.19.1
^ permalink raw reply related
* Re: [PATCH bpf-next 3/8] bpf, sockmap: convert to generic sk_msg interface
From: John Fastabend @ 2018-10-12 4:56 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann; +Cc: davejwatson, netdev
In-Reply-To: <20181011225739.3pjhdy5jsegvr3ub@ast-mbp.dhcp.thefacebook.com>
On 10/11/2018 03:57 PM, Alexei Starovoitov wrote:
> On Thu, Oct 11, 2018 at 02:45:42AM +0200, Daniel Borkmann wrote:
>> Add a generic sk_msg layer, and convert current sockmap and later
>> kTLS over to make use of it. While sk_buff handles network packet
>> representation from netdevice up to socket, sk_msg handles data
>> representation from application to socket layer.
>>
>> This means that sk_msg framework spans across ULP users in the
>> kernel, and enables features such as introspection or filtering
>> of data with the help of BPF programs that operate on this data
>> structure.
>>
>> Latter becomes in particular useful for kTLS where data encryption
>> is deferred into the kernel, and as such enabling the kernel to
>> perform L7 introspection and policy based on BPF for TLS connections
>> where the record is being encrypted after BPF has run and came to
>> a verdict. In order to get there, first step is to transform open
>> coding of scatter-gather list handling into a common core framework
>> that subsystems use.
>>
>> Joint work with John.
>>
>> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
>> Signed-off-by: John Fastabend <john.fastabend@gmail.com>
>> ---
>> include/linux/bpf.h | 33 +-
>> include/linux/bpf_types.h | 2 +-
>> include/linux/filter.h | 21 -
>> include/linux/skmsg.h | 371 +++++++
>> include/net/tcp.h | 27 +
>> kernel/bpf/Makefile | 5 -
>> kernel/bpf/core.c | 2 -
>> kernel/bpf/sockmap.c | 2610 ---------------------------------------------
>> kernel/bpf/syscall.c | 6 +-
>> net/Kconfig | 11 +
>> net/core/Makefile | 2 +
>> net/core/filter.c | 270 ++---
>> net/core/skmsg.c | 763 +++++++++++++
>> net/core/sock_map.c | 1002 +++++++++++++++++
>> net/ipv4/Makefile | 1 +
>> net/ipv4/tcp_bpf.c | 655 ++++++++++++
>> net/strparser/Kconfig | 4 +-
>> 17 files changed, 2925 insertions(+), 2860 deletions(-)
>
>> +void sk_msg_trim(struct sock *sk, struct sk_msg *msg, int len)
>> +{
>> + int trim = msg->sg.size - len;
>> + u32 i = msg->sg.end;
>> +
>> + if (trim <= 0) {
>> + WARN_ON(trim < 0);
>> + return;
>> + }
>> +
>> + sk_msg_iter_var_prev(i);
>> + msg->sg.size = len;
>> + while (msg->sg.data[i].length &&
>> + trim >= msg->sg.data[i].length) {
>> + trim -= msg->sg.data[i].length;
>> + sk_msg_free_elem(sk, msg, i, true);
>> + sk_msg_iter_var_prev(i);
>> + if (!trim)
>> + goto out;
>> + }
>> +
>> + msg->sg.data[i].length -= trim;
>> + sk_mem_uncharge(sk, trim);
>> +out:
>> + /* If we trim data before curr pointer update copybreak and current
>> + * so that any future copy operations start at new copy location.
>> + * However trimed data that has not yet been used in a copy op
>> + * does not require an update.
>> + */
>> + if (msg->sg.curr >= i) {
>> + msg->sg.curr = i;//msg->sg.end;
>
> is this a leftover of some debugging ?
Correct the comment needs to be removed.
>
> I think such giant patchset is impossible to review in reasonable
> amount of time. I guess you've considered splitting it, but
> couldn't find a way to do so ?
Right, so I looked at splitting this up but it was hard to make
any sense out of how to split this up well. This patch is moving existing
code in ./kernel/bpf/sockmap.c into skmsg.c, sock_map.c, and tcp_bpf.c
Along the way some of the naming/structures are changed a bit to
fit into the new file layout. Splitting it up to just move bits and
pieces at a time didn't seem to help much, made it more difficult
to review IMO, and I also had trouble breaking it into isolated changes.
>
> May be expand the commit log a bit more to explain not only _why_
> (which is typical requiremnt), but _how_ the patchset is doing it?
>
Sounds like a good idea Daniel and I can work something up tomorrow.
The gist is to isolate the sock_map changes a bit so they can be
used by multiple ULPs (as noted in the commit log). But the how here
is to create a sock_map.c file to manage BPF map APIs, a skmsg.c
file full of all the generic code used with sk_msg structs (the
core structure throughout) and finally tcp_bpf to handle the TCP
specific parts. The nice fallout of all this is we then can add
_just_ the TLS bits in the subsequent patches. Also note the overall
+/- diff for the entire series is actually fairly small. I also
believe this is going to be very useful adding more socket types to
sock map, UDP for instance.
Along the way the naming is cleaned up to reflect the above changes.
> Overall sk_msg generalization looks great to me. Especially
> considering how it's used in the next patches,
> but details are scary. sockmap was plagued with bugs that
> syzbot found. Are we changing it a lot again or it's mainly
> copy-paste/split into different files plus rename?
>
There should not be any functional changes here just copy-paste,
split into above noted files and renames. Besides all the self
tests I've been running this in Cilium as well now for some time.
> I'm willing to take a leap of faith and merge it, but would
> love if commit log could make it easier to see what is going on.
>
Great. Lets get some extra details in the commit log!
^ permalink raw reply
* [PATCH] rxrpc: add IPV6 dependency
From: Arnd Bergmann @ 2018-10-12 12:36 UTC (permalink / raw)
To: David Howells, David S. Miller
Cc: Arnd Bergmann, linux-afs, linux-kernel, netdev
The udpv6_encap_enable() function is part of the ipv6 code, and if that
is configured as a loadable module, rxcpc cannot be built-in any more:
net/rxrpc/local_object.o: In function `rxrpc_lookup_local':
local_object.c:(.text+0x2688): undefined reference to `udpv6_encap_enable'
Add a dependency that allows building rxrpc with or without IPv6, but
that disallows the broken configuration. Since AFS selects RXRPC,
this needs the same dependency.
Fixes: 5271953cad31 ("rxrpc: Use the UDP encap_rcv hook")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
fs/afs/Kconfig | 1 +
net/rxrpc/Kconfig | 1 +
2 files changed, 2 insertions(+)
diff --git a/fs/afs/Kconfig b/fs/afs/Kconfig
index ebba3b18e5da..e2cad2c9d9d8 100644
--- a/fs/afs/Kconfig
+++ b/fs/afs/Kconfig
@@ -1,6 +1,7 @@
config AFS_FS
tristate "Andrew File System support (AFS)"
depends on INET
+ depends on IPV6 || !IPV6
select AF_RXRPC
select DNS_RESOLVER
help
diff --git a/net/rxrpc/Kconfig b/net/rxrpc/Kconfig
index 86f8853a038c..d925be00fc74 100644
--- a/net/rxrpc/Kconfig
+++ b/net/rxrpc/Kconfig
@@ -5,6 +5,7 @@
config AF_RXRPC
tristate "RxRPC session sockets"
depends on INET
+ depends on IPV6 || !IPV6
select CRYPTO
select KEYS
help
--
2.18.0
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox