* [PATCH net-next] net: netlink: minor: remove unused pointer in alloc_pg_vec
From: Daniel Borkmann @ 2013-08-02 15:32 UTC (permalink / raw)
To: davem; +Cc: netdev
Variable ptr is being assigned, but never used, so just remove it.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
---
net/netlink/af_netlink.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 0c61b59..6273772 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -294,14 +294,14 @@ static void **alloc_pg_vec(struct netlink_sock *nlk,
{
unsigned int block_nr = req->nm_block_nr;
unsigned int i;
- void **pg_vec, *ptr;
+ void **pg_vec;
pg_vec = kcalloc(block_nr, sizeof(void *), GFP_KERNEL);
if (pg_vec == NULL)
return NULL;
for (i = 0; i < block_nr; i++) {
- pg_vec[i] = ptr = alloc_one_pg_vec_page(order);
+ pg_vec[i] = alloc_one_pg_vec_page(order);
if (pg_vec[i] == NULL)
goto err1;
}
--
1.7.11.7
^ permalink raw reply related
* Re: bonding + arp monitoring fails if interface is a vlan
From: Jay Vosburgh @ 2013-08-02 15:49 UTC (permalink / raw)
To: Nikolay Aleksandrov; +Cc: Santiago Garcia Mantinan, netdev
In-Reply-To: <51FB9EE5.3040907@redhat.com>
Nikolay Aleksandrov <nikolay@redhat.com> wrote:
>On 08/01/2013 02:11 PM, Santiago Garcia Mantinan wrote:
>> Hi!
>>
>> I'm trying to setup a bond of a couple of vlans, these vlans are different
>> paths to an upstream switch from a local switch. I want to do arp
>> monitoring of the link in order for the bonding interface to know which path
>> is ok and wich one is broken. If I set it up using arp monitoring and
>> without using vlans it works ok, it also works if I set it up using vlans
>> but without arp monitoring, so the broken setup seems to be with bonding +
>> arp monitoring + vlans. Here is a schema:
>>
>> -------------
>> |Remote Switch|
>> -------------
>> | |
>> P P
>> A A
>> T T
>> H H
>> 1 2
>> | |
>> ------------
>> |Local switch|
>> ------------
>> |
>> | VLAN for PATH1
>> | VLAN for PATH2
>> |
>> Linux machine
>>
>> The broken setup seems to work but arp monitoring makes it loose the logical
>> link from time to time, thus changing to other slave if available. What I
>> saw when monitoring this with tcpdump is that all the arp requests were
>> going out and that all the replies where coming in, so acording to the
>> traffic seen on tcpdump the link should have been stable, but
>> /proc/net/bonding/bond0 showed the link failures increasing and when testing
>> with just a vlan interface I was loosing ping when the link was going down.
>>
>> I've tried this on Debian wheezy with its 3.2.46 kernel and also the 3.10.3
>> version in unstable, the tests where done on a couple of machines using a 32
>> bits kernel with different nics (r8169 and skge).
>>
>> I created a small lab to replicate the problem, on this setup I avoided all
>> the switching and I directly connected the machine with bonding to another
>> Linux on which I just had eth0.1002 configured with ip 192.168.1.1, the
>> results where the same as in the full scenario, link on the bonding slave
>> was going down from time to time.
>>
>> This is the setup on the bonding interface.
>>
>> auto bond0
>> iface bond0 inet static
>> address 192.168.1.2
>> netmask 255.255.255.0
>> bond-slaves eth0.1002
>> bond-mode active-backup
>> bond-arp_validate 0
>> bond-arp_interval 5000
>> bond-arp_ip_target 192.168.1.1
>> pre-up ip link set eth0 up || true
>> pre-up ip link add link eth0 name eth0.1002 type vlan id 1002 || true
>> down ip link delete eth0.1002 || true
>>
>I believe that it is because dev_trans_start() returns 0 for 8021q devices and
>so the calculations if the slave has transmitted are wrong, and the flip-flop
>happens.
>Please try the attached patch, it should resolve your issue (basically it gets
>the dev_trans_start of the vlan's underlying device if a vlan is found).
>
>The patch is against Linus' tree.
>
>Cheers,
> Nik
>
>
>diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>index 07f257d4..6aac0ae 100644
>--- a/drivers/net/bonding/bond_main.c
>+++ b/drivers/net/bonding/bond_main.c
>@@ -665,6 +665,16 @@ static int bond_check_dev_link(struct bonding *bond,
> return reporting ? -1 : BMSR_LSTATUS;
> }
>
>+static unsigned long bond_dev_trans_start(struct net_device *dev)
>+{
>+ struct net_device *real_dev = dev;
>+
>+ if (dev->priv_flags & IFF_802_1Q_VLAN)
>+ real_dev = vlan_dev_real_dev(dev);
>+
>+ return dev_trans_start(real_dev);
>+}
Should this handle nested VLANs? E.g.,
static unsigned long bond_dev_trans_start(struct net_device *dev)
{
while (dev->priv_flags & IFF_802_1Q_VLAN)
dev = vlan_dev_real_dev(dev);
return dev_trans_start(dev);
}
Also, this (ARP monitoring of a VLAN slave) has likely never
worked, and therefore this change should be considered for -stable.
-J
>+
> /*----------------------------- Multicast list ------------------------------*/
>
> /*
>@@ -2750,7 +2760,7 @@ void bond_loadbalance_arp_mon(struct work_struct *work)
> * so it can wait
> */
> bond_for_each_slave(bond, slave, i) {
>- unsigned long trans_start = dev_trans_start(slave->dev);
>+ unsigned long trans_start = bond_dev_trans_start(slave->dev);
>
> if (slave->link != BOND_LINK_UP) {
> if (time_in_range(jiffies,
>@@ -2912,7 +2922,7 @@ static int bond_ab_arp_inspect(struct bonding *bond, int delta_in_ticks)
> * - (more than 2*delta since receive AND
> * the bond has an IP address)
> */
>- trans_start = dev_trans_start(slave->dev);
>+ trans_start = bond_dev_trans_start(slave->dev);
> if (bond_is_active_slave(slave) &&
> (!time_in_range(jiffies,
> trans_start - delta_in_ticks,
>@@ -2947,7 +2957,7 @@ static void bond_ab_arp_commit(struct bonding *bond, int delta_in_ticks)
> continue;
>
> case BOND_LINK_UP:
>- trans_start = dev_trans_start(slave->dev);
>+ trans_start = bond_dev_trans_start(slave->dev);
> if ((!bond->curr_active_slave &&
> time_in_range(jiffies,
> trans_start - delta_in_ticks,
---
-Jay Vosburgh, IBM Linux Technology Center, fubar@us.ibm.com
^ permalink raw reply
* Re: [PATCH net-next] sctp: Don't lookup dst if transport dst is still valid
From: Neil Horman @ 2013-08-02 15:58 UTC (permalink / raw)
To: Fan Du; +Cc: vyasevich, davem, netdev
In-Reply-To: <1375411513-12551-1-git-send-email-fan.du@windriver.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
^ permalink raw reply
* Re: bonding + arp monitoring fails if interface is a vlan
From: Nikolay Aleksandrov @ 2013-08-02 16:13 UTC (permalink / raw)
To: Jay Vosburgh; +Cc: Santiago Garcia Mantinan, netdev
In-Reply-To: <10459.1375458558@death.nxdomain>
On 08/02/2013 05:49 PM, Jay Vosburgh wrote:
> Nikolay Aleksandrov <nikolay@redhat.com> wrote:
>
>> On 08/01/2013 02:11 PM, Santiago Garcia Mantinan wrote:
>>> Hi!
>>>
>>> I'm trying to setup a bond of a couple of vlans, these vlans are different
>>> paths to an upstream switch from a local switch. I want to do arp
>>> monitoring of the link in order for the bonding interface to know which path
>>> is ok and wich one is broken. If I set it up using arp monitoring and
>>> without using vlans it works ok, it also works if I set it up using vlans
>>> but without arp monitoring, so the broken setup seems to be with bonding +
>>> arp monitoring + vlans. Here is a schema:
>>>
>>> -------------
>>> |Remote Switch|
>>> -------------
>>> | |
>>> P P
>>> A A
>>> T T
>>> H H
>>> 1 2
>>> | |
>>> ------------
>>> |Local switch|
>>> ------------
>>> |
>>> | VLAN for PATH1
>>> | VLAN for PATH2
>>> |
>>> Linux machine
>>>
>>> The broken setup seems to work but arp monitoring makes it loose the logical
>>> link from time to time, thus changing to other slave if available. What I
>>> saw when monitoring this with tcpdump is that all the arp requests were
>>> going out and that all the replies where coming in, so acording to the
>>> traffic seen on tcpdump the link should have been stable, but
>>> /proc/net/bonding/bond0 showed the link failures increasing and when testing
>>> with just a vlan interface I was loosing ping when the link was going down.
>>>
>>> I've tried this on Debian wheezy with its 3.2.46 kernel and also the 3.10.3
>>> version in unstable, the tests where done on a couple of machines using a 32
>>> bits kernel with different nics (r8169 and skge).
>>>
>>> I created a small lab to replicate the problem, on this setup I avoided all
>>> the switching and I directly connected the machine with bonding to another
>>> Linux on which I just had eth0.1002 configured with ip 192.168.1.1, the
>>> results where the same as in the full scenario, link on the bonding slave
>>> was going down from time to time.
>>>
>>> This is the setup on the bonding interface.
>>>
>>> auto bond0
>>> iface bond0 inet static
>>> address 192.168.1.2
>>> netmask 255.255.255.0
>>> bond-slaves eth0.1002
>>> bond-mode active-backup
>>> bond-arp_validate 0
>>> bond-arp_interval 5000
>>> bond-arp_ip_target 192.168.1.1
>>> pre-up ip link set eth0 up || true
>>> pre-up ip link add link eth0 name eth0.1002 type vlan id 1002 || true
>>> down ip link delete eth0.1002 || true
>>>
>> I believe that it is because dev_trans_start() returns 0 for 8021q devices and
>> so the calculations if the slave has transmitted are wrong, and the flip-flop
>> happens.
>> Please try the attached patch, it should resolve your issue (basically it gets
>> the dev_trans_start of the vlan's underlying device if a vlan is found).
>>
>> The patch is against Linus' tree.
>>
>> Cheers,
>> Nik
>>
>>
>> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>> index 07f257d4..6aac0ae 100644
>> --- a/drivers/net/bonding/bond_main.c
>> +++ b/drivers/net/bonding/bond_main.c
>> @@ -665,6 +665,16 @@ static int bond_check_dev_link(struct bonding *bond,
>> return reporting ? -1 : BMSR_LSTATUS;
>> }
>>
>> +static unsigned long bond_dev_trans_start(struct net_device *dev)
>> +{
>> + struct net_device *real_dev = dev;
>> +
>> + if (dev->priv_flags & IFF_802_1Q_VLAN)
>> + real_dev = vlan_dev_real_dev(dev);
>> +
>> + return dev_trans_start(real_dev);
>> +}
>
> Should this handle nested VLANs? E.g.,
>
> static unsigned long bond_dev_trans_start(struct net_device *dev)
> {
> while (dev->priv_flags & IFF_802_1Q_VLAN)
> dev = vlan_dev_real_dev(dev);
>
> return dev_trans_start(dev);
> }
>
> Also, this (ARP monitoring of a VLAN slave) has likely never
> worked, and therefore this change should be considered for -stable.
>
> -J
>
Yes, it should :-)
Thanks Jay, I'll re-submit it as a proper patch for -net in a bit.
Nik
^ permalink raw reply
* [PATCH net] bonding: fix arp monitoring with vlan slaves
From: Nikolay Aleksandrov @ 2013-08-02 16:41 UTC (permalink / raw)
To: netdev; +Cc: andy, davem, fubar
From: Nikolay Aleksandrov <Nikolay Aleksandrov nikolay@redhat.com>
When arp monitoring is enabled the bonding relies on slaves'
dev_trans_start() value to check if the slave link is up or not, but for
8021q devices that value is either stale or 0, and can't be used. So use
the 8021q's underlying device value.
Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
---
drivers/net/bonding/bond_main.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 07f257d4..5f2bad3 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -665,6 +665,17 @@ static int bond_check_dev_link(struct bonding *bond,
return reporting ? -1 : BMSR_LSTATUS;
}
+/* For 8021q devices dev_trans_start() returns 0 or a stale value, so use the
+ * 8021q's underlying device value
+ */
+static unsigned long bond_dev_trans_start(struct net_device *dev)
+{
+ while (dev->priv_flags & IFF_802_1Q_VLAN)
+ dev = vlan_dev_real_dev(dev);
+
+ return dev_trans_start(dev);
+}
+
/*----------------------------- Multicast list ------------------------------*/
/*
@@ -2750,7 +2761,7 @@ void bond_loadbalance_arp_mon(struct work_struct *work)
* so it can wait
*/
bond_for_each_slave(bond, slave, i) {
- unsigned long trans_start = dev_trans_start(slave->dev);
+ unsigned long trans_start = bond_dev_trans_start(slave->dev);
if (slave->link != BOND_LINK_UP) {
if (time_in_range(jiffies,
@@ -2912,7 +2923,7 @@ static int bond_ab_arp_inspect(struct bonding *bond, int delta_in_ticks)
* - (more than 2*delta since receive AND
* the bond has an IP address)
*/
- trans_start = dev_trans_start(slave->dev);
+ trans_start = bond_dev_trans_start(slave->dev);
if (bond_is_active_slave(slave) &&
(!time_in_range(jiffies,
trans_start - delta_in_ticks,
@@ -2947,7 +2958,7 @@ static void bond_ab_arp_commit(struct bonding *bond, int delta_in_ticks)
continue;
case BOND_LINK_UP:
- trans_start = dev_trans_start(slave->dev);
+ trans_start = bond_dev_trans_start(slave->dev);
if ((!bond->curr_active_slave &&
time_in_range(jiffies,
trans_start - delta_in_ticks,
--
1.8.1.4
^ permalink raw reply related
* [PATCH net-next 0/2] fix bonding neighbour setup handling
From: Veaceslav Falico @ 2013-08-02 17:07 UTC (permalink / raw)
To: netdev; +Cc: vfalico, fubar, andy, ebiederm, joe
Recent patches revealed an old bug, which was there for quite awhile. It's
related to vlan on top of bonding and ndo_neigh_setup(). When vlan device
is initiated, it calls its real_dev->ndo_neigh_setup(), and in case of
bonding - it will modify neigh_parms->neigh_setup to point to
bond_neigh_init, while neigh_parms are of vlan's dev.
This way, when neigh_parms->neigh_setup() of vlan's dev is called, the
bonding function will be called, which expects the dev to be struct
bonding, but will receive a vlan dev.
It was hidden before because of bond->first_slave usage. Now, with
Nikolay's conversion to list/RCU, first_slave is gone and we hit a null
pointer dereference when working with lists/slave.
First patch moves ndo_neigh_setup() in neigh_parms_alloc() to the bottom,
so that the ->dev will be available to the caller. It doesn't really change
anything, however is needed for the second patch.
Second patch makes bond_neigh_setup() (bond->ndo_neigh_setup()) check if
the neigh_parms are really from a bonding dev, and only modify the
neigh_setup in this case.
drivers/net/bonding/bond_main.c | 8 +++++++-
net/core/neighbour.c | 10 ++++++----
2 files changed, 13 insertions(+), 5 deletions(-)
^ permalink raw reply
* [PATCH net-next 2/2] bonding: modify only neigh_parms owned by us
From: Veaceslav Falico @ 2013-08-02 17:07 UTC (permalink / raw)
To: netdev; +Cc: vfalico, fubar, andy, ebiederm, joe
In-Reply-To: <1375463259-12033-1-git-send-email-vfalico@redhat.com>
Otherwise, on neighbour creation, bond_neigh_init() will be called with a
foreign netdev.
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
drivers/net/bonding/bond_main.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 1d37a96..476df7d 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3630,11 +3630,17 @@ static int bond_neigh_init(struct neighbour *n)
* The bonding ndo_neigh_setup is called at init time beofre any
* slave exists. So we must declare proxy setup function which will
* be used at run time to resolve the actual slave neigh param setup.
+ *
+ * It's also called by master devices (such as vlans) to setup their
+ * underlying devices. In that case - do nothing, we're already set up from
+ * our init.
*/
static int bond_neigh_setup(struct net_device *dev,
struct neigh_parms *parms)
{
- parms->neigh_setup = bond_neigh_init;
+ /* modify only our neigh_parms */
+ if (parms->dev == dev)
+ parms->neigh_setup = bond_neigh_init;
return 0;
}
--
1.7.1
^ permalink raw reply related
* [PATCH net-next 1/2] neighbour: populate neigh_parms on alloc before calling ndo_neigh_setup
From: Veaceslav Falico @ 2013-08-02 17:07 UTC (permalink / raw)
To: netdev; +Cc: vfalico, fubar, andy, ebiederm, joe
In-Reply-To: <1375463259-12033-1-git-send-email-vfalico@redhat.com>
dev->ndo_neigh_setup() might need some of the values of neigh_parms, so
populate them before calling it.
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
net/core/neighbour.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index b7de821..576d46f 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -1441,16 +1441,18 @@ struct neigh_parms *neigh_parms_alloc(struct net_device *dev,
atomic_set(&p->refcnt, 1);
p->reachable_time =
neigh_rand_reach_time(p->base_reachable_time);
+ dev_hold(dev);
+ p->dev = dev;
+ write_pnet(&p->net, hold_net(net));
+ p->sysctl_table = NULL;
if (ops->ndo_neigh_setup && ops->ndo_neigh_setup(dev, p)) {
+ release_net(net);
+ dev_put(dev);
kfree(p);
return NULL;
}
- dev_hold(dev);
- p->dev = dev;
- write_pnet(&p->net, hold_net(net));
- p->sysctl_table = NULL;
write_lock_bh(&tbl->lock);
p->next = tbl->parms.next;
tbl->parms.next = p;
--
1.7.1
^ permalink raw reply related
* Re: [PATCH v3] r8169: remove "PHY reset until link up" log spam
From: Francois Romieu @ 2013-08-02 17:47 UTC (permalink / raw)
To: Peter Wu; +Cc: Sergei Shtylyov, David Miller, netdev, nic_swsd
In-Reply-To: <1375432615-7901-1-git-send-email-lekensteyn@gmail.com>
Peter Wu <lekensteyn@gmail.com> :
> This message was added in commit a7154cb8 (June 2004, [PATCH] r8169:
> link handling and phy reset rework) and is printed every ten seconds
> when no cable is connected and runtime power management is disabled.
> (Before that commit, "Reset RTL8169s PHY" would be printed instead.)
>
> Signed-off-by: Peter Wu <lekensteyn@gmail.com>
Acked-by: Francois Romieu <romieu@fr.zoreil.com>
--
Ueimor
^ permalink raw reply
* [PATCH net-next] cnic, bnx2i: Fix bug on some bnx2x devices that don't support iSCSI
From: Michael Chan @ 2013-08-02 18:28 UTC (permalink / raw)
To: davem; +Cc: netdev, Michael Chan, Eddie Wai
On some bnx2x devices, iSCSI is determined to be unsupported only after
firmware is downloaded. We need to check max_iscsi_conn again after
NETDEV_UP and block iSCSI init operations. Without this fix, iscsiadm
can hang as the firmware will not respond to the iSCSI init message.
Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
---
drivers/net/ethernet/broadcom/cnic.c | 7 +++++++
drivers/scsi/bnx2i/bnx2i_init.c | 12 +++++-------
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/broadcom/cnic.c
index 6bd6d14..4f8a535 100644
--- a/drivers/net/ethernet/broadcom/cnic.c
+++ b/drivers/net/ethernet/broadcom/cnic.c
@@ -5276,6 +5276,13 @@ static int cnic_register_netdev(struct cnic_dev *dev)
if (err)
netdev_err(dev->netdev, "register_cnic failed\n");
+ /* Read iSCSI config again. On some bnx2x device, iSCSI config
+ * can change after firmware is downloaded.
+ */
+ dev->max_iscsi_conn = ethdev->max_iscsi_conn;
+ if (ethdev->drv_state & CNIC_DRV_STATE_NO_ISCSI)
+ dev->max_iscsi_conn = 0;
+
return err;
}
diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 50fef69..3104202 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -172,16 +172,14 @@ void bnx2i_start(void *handle)
struct bnx2i_hba *hba = handle;
int i = HZ;
- /*
- * We should never register devices that don't support iSCSI
- * (see bnx2i_init_one), so something is wrong if we try to
- * start a iSCSI adapter on hardware with 0 supported iSCSI
- * connections
+ /* On some bnx2x devices, it is possible that iSCSI is no
+ * longer supported after firmware is downloaded. In that
+ * case, the iscsi_init_msg will return failure.
*/
- BUG_ON(!hba->cnic->max_iscsi_conn);
bnx2i_send_fw_iscsi_init_msg(hba);
- while (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state) && i--)
+ while (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state) &&
+ !test_bit(ADAPTER_STATE_INIT_FAILED, &hba->adapter_state) && i--)
msleep(BNX2I_INIT_POLL_TIME);
}
--
1.7.1
^ permalink raw reply related
* [PATCH] netlabel: use domain based selectors when address based selectors are not available
From: Paul Moore @ 2013-08-02 18:45 UTC (permalink / raw)
To: netdev; +Cc: linux-security-module, selinux
NetLabel has the ability to selectively assign network security labels
to outbound traffic based on either the LSM's "domain" (different for
each LSM), the network destination, or a combination of both. Depending
on the type of traffic, local or forwarded, and the type of traffic
selector, domain or address based, different hooks are used to label the
traffic; the goal being minimal overhead.
Unfortunately, there is a bug such that a system using NetLabel domain
based traffic selectors does not correctly label outbound local traffic
that is not assigned to a socket. The issue is that in these cases
the associated NetLabel hook only looks at the address based selectors
and not the domain based selectors. This patch corrects this by
checking both the domain and address based selectors so that the correct
labeling is applied, regardless of the configuration type.
In order to acomplish this fix, this patch also simplifies some of the
NetLabel domainhash structures to use a more common outbound traffic
mapping type: struct netlbl_dommap_def. This simplifies some of the code
in this patch and paves the way for further simplifications in the
future.
Signed-off-by: Paul Moore <pmoore@redhat.com>
---
net/netlabel/netlabel_cipso_v4.c | 4 +
net/netlabel/netlabel_domainhash.c | 104 +++++++++++++++++-------------------
net/netlabel/netlabel_domainhash.h | 46 ++++++++--------
net/netlabel/netlabel_kapi.c | 88 ++++++++++++------------------
net/netlabel/netlabel_mgmt.c | 44 +++++++--------
net/netlabel/netlabel_unlabeled.c | 2 -
6 files changed, 130 insertions(+), 158 deletions(-)
diff --git a/net/netlabel/netlabel_cipso_v4.c b/net/netlabel/netlabel_cipso_v4.c
index c15042f..a110064 100644
--- a/net/netlabel/netlabel_cipso_v4.c
+++ b/net/netlabel/netlabel_cipso_v4.c
@@ -691,8 +691,8 @@ static int netlbl_cipsov4_remove_cb(struct netlbl_dom_map *entry, void *arg)
{
struct netlbl_domhsh_walk_arg *cb_arg = arg;
- if (entry->type == NETLBL_NLTYPE_CIPSOV4 &&
- entry->type_def.cipsov4->doi == cb_arg->doi)
+ if (entry->def.type == NETLBL_NLTYPE_CIPSOV4 &&
+ entry->def.cipso->doi == cb_arg->doi)
return netlbl_domhsh_remove_entry(entry, cb_arg->audit_info);
return 0;
diff --git a/net/netlabel/netlabel_domainhash.c b/net/netlabel/netlabel_domainhash.c
index 6bb1d42..85d842e 100644
--- a/net/netlabel/netlabel_domainhash.c
+++ b/net/netlabel/netlabel_domainhash.c
@@ -84,15 +84,15 @@ static void netlbl_domhsh_free_entry(struct rcu_head *entry)
#endif /* IPv6 */
ptr = container_of(entry, struct netlbl_dom_map, rcu);
- if (ptr->type == NETLBL_NLTYPE_ADDRSELECT) {
+ if (ptr->def.type == NETLBL_NLTYPE_ADDRSELECT) {
netlbl_af4list_foreach_safe(iter4, tmp4,
- &ptr->type_def.addrsel->list4) {
+ &ptr->def.addrsel->list4) {
netlbl_af4list_remove_entry(iter4);
kfree(netlbl_domhsh_addr4_entry(iter4));
}
#if IS_ENABLED(CONFIG_IPV6)
netlbl_af6list_foreach_safe(iter6, tmp6,
- &ptr->type_def.addrsel->list6) {
+ &ptr->def.addrsel->list6) {
netlbl_af6list_remove_entry(iter6);
kfree(netlbl_domhsh_addr6_entry(iter6));
}
@@ -213,21 +213,21 @@ static void netlbl_domhsh_audit_add(struct netlbl_dom_map *entry,
if (addr4 != NULL) {
struct netlbl_domaddr4_map *map4;
map4 = netlbl_domhsh_addr4_entry(addr4);
- type = map4->type;
- cipsov4 = map4->type_def.cipsov4;
+ type = map4->def.type;
+ cipsov4 = map4->def.cipso;
netlbl_af4list_audit_addr(audit_buf, 0, NULL,
addr4->addr, addr4->mask);
#if IS_ENABLED(CONFIG_IPV6)
} else if (addr6 != NULL) {
struct netlbl_domaddr6_map *map6;
map6 = netlbl_domhsh_addr6_entry(addr6);
- type = map6->type;
+ type = map6->def.type;
netlbl_af6list_audit_addr(audit_buf, 0, NULL,
&addr6->addr, &addr6->mask);
#endif /* IPv6 */
} else {
- type = entry->type;
- cipsov4 = entry->type_def.cipsov4;
+ type = entry->def.type;
+ cipsov4 = entry->def.cipso;
}
switch (type) {
case NETLBL_NLTYPE_UNLABELED:
@@ -265,26 +265,25 @@ static int netlbl_domhsh_validate(const struct netlbl_dom_map *entry)
if (entry == NULL)
return -EINVAL;
- switch (entry->type) {
+ switch (entry->def.type) {
case NETLBL_NLTYPE_UNLABELED:
- if (entry->type_def.cipsov4 != NULL ||
- entry->type_def.addrsel != NULL)
+ if (entry->def.cipso != NULL || entry->def.addrsel != NULL)
return -EINVAL;
break;
case NETLBL_NLTYPE_CIPSOV4:
- if (entry->type_def.cipsov4 == NULL)
+ if (entry->def.cipso == NULL)
return -EINVAL;
break;
case NETLBL_NLTYPE_ADDRSELECT:
- netlbl_af4list_foreach(iter4, &entry->type_def.addrsel->list4) {
+ netlbl_af4list_foreach(iter4, &entry->def.addrsel->list4) {
map4 = netlbl_domhsh_addr4_entry(iter4);
- switch (map4->type) {
+ switch (map4->def.type) {
case NETLBL_NLTYPE_UNLABELED:
- if (map4->type_def.cipsov4 != NULL)
+ if (map4->def.cipso != NULL)
return -EINVAL;
break;
case NETLBL_NLTYPE_CIPSOV4:
- if (map4->type_def.cipsov4 == NULL)
+ if (map4->def.cipso == NULL)
return -EINVAL;
break;
default:
@@ -292,9 +291,9 @@ static int netlbl_domhsh_validate(const struct netlbl_dom_map *entry)
}
}
#if IS_ENABLED(CONFIG_IPV6)
- netlbl_af6list_foreach(iter6, &entry->type_def.addrsel->list6) {
+ netlbl_af6list_foreach(iter6, &entry->def.addrsel->list6) {
map6 = netlbl_domhsh_addr6_entry(iter6);
- switch (map6->type) {
+ switch (map6->def.type) {
case NETLBL_NLTYPE_UNLABELED:
break;
default:
@@ -402,32 +401,31 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry,
rcu_assign_pointer(netlbl_domhsh_def, entry);
}
- if (entry->type == NETLBL_NLTYPE_ADDRSELECT) {
+ if (entry->def.type == NETLBL_NLTYPE_ADDRSELECT) {
netlbl_af4list_foreach_rcu(iter4,
- &entry->type_def.addrsel->list4)
+ &entry->def.addrsel->list4)
netlbl_domhsh_audit_add(entry, iter4, NULL,
ret_val, audit_info);
#if IS_ENABLED(CONFIG_IPV6)
netlbl_af6list_foreach_rcu(iter6,
- &entry->type_def.addrsel->list6)
+ &entry->def.addrsel->list6)
netlbl_domhsh_audit_add(entry, NULL, iter6,
ret_val, audit_info);
#endif /* IPv6 */
} else
netlbl_domhsh_audit_add(entry, NULL, NULL,
ret_val, audit_info);
- } else if (entry_old->type == NETLBL_NLTYPE_ADDRSELECT &&
- entry->type == NETLBL_NLTYPE_ADDRSELECT) {
+ } else if (entry_old->def.type == NETLBL_NLTYPE_ADDRSELECT &&
+ entry->def.type == NETLBL_NLTYPE_ADDRSELECT) {
struct list_head *old_list4;
struct list_head *old_list6;
- old_list4 = &entry_old->type_def.addrsel->list4;
- old_list6 = &entry_old->type_def.addrsel->list6;
+ old_list4 = &entry_old->def.addrsel->list4;
+ old_list6 = &entry_old->def.addrsel->list6;
/* we only allow the addition of address selectors if all of
* the selectors do not exist in the existing domain map */
- netlbl_af4list_foreach_rcu(iter4,
- &entry->type_def.addrsel->list4)
+ netlbl_af4list_foreach_rcu(iter4, &entry->def.addrsel->list4)
if (netlbl_af4list_search_exact(iter4->addr,
iter4->mask,
old_list4)) {
@@ -435,8 +433,7 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry,
goto add_return;
}
#if IS_ENABLED(CONFIG_IPV6)
- netlbl_af6list_foreach_rcu(iter6,
- &entry->type_def.addrsel->list6)
+ netlbl_af6list_foreach_rcu(iter6, &entry->def.addrsel->list6)
if (netlbl_af6list_search_exact(&iter6->addr,
&iter6->mask,
old_list6)) {
@@ -446,7 +443,7 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry,
#endif /* IPv6 */
netlbl_af4list_foreach_safe(iter4, tmp4,
- &entry->type_def.addrsel->list4) {
+ &entry->def.addrsel->list4) {
netlbl_af4list_remove_entry(iter4);
iter4->valid = 1;
ret_val = netlbl_af4list_add(iter4, old_list4);
@@ -457,7 +454,7 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry,
}
#if IS_ENABLED(CONFIG_IPV6)
netlbl_af6list_foreach_safe(iter6, tmp6,
- &entry->type_def.addrsel->list6) {
+ &entry->def.addrsel->list6) {
netlbl_af6list_remove_entry(iter6);
iter6->valid = 1;
ret_val = netlbl_af6list_add(iter6, old_list6);
@@ -538,18 +535,18 @@ int netlbl_domhsh_remove_entry(struct netlbl_dom_map *entry,
struct netlbl_af4list *iter4;
struct netlbl_domaddr4_map *map4;
- switch (entry->type) {
+ switch (entry->def.type) {
case NETLBL_NLTYPE_ADDRSELECT:
netlbl_af4list_foreach_rcu(iter4,
- &entry->type_def.addrsel->list4) {
+ &entry->def.addrsel->list4) {
map4 = netlbl_domhsh_addr4_entry(iter4);
- cipso_v4_doi_putdef(map4->type_def.cipsov4);
+ cipso_v4_doi_putdef(map4->def.cipso);
}
/* no need to check the IPv6 list since we currently
* support only unlabeled protocols for IPv6 */
break;
case NETLBL_NLTYPE_CIPSOV4:
- cipso_v4_doi_putdef(entry->type_def.cipsov4);
+ cipso_v4_doi_putdef(entry->def.cipso);
break;
}
call_rcu(&entry->rcu, netlbl_domhsh_free_entry);
@@ -590,20 +587,21 @@ int netlbl_domhsh_remove_af4(const char *domain,
entry_map = netlbl_domhsh_search(domain);
else
entry_map = netlbl_domhsh_search_def(domain);
- if (entry_map == NULL || entry_map->type != NETLBL_NLTYPE_ADDRSELECT)
+ if (entry_map == NULL ||
+ entry_map->def.type != NETLBL_NLTYPE_ADDRSELECT)
goto remove_af4_failure;
spin_lock(&netlbl_domhsh_lock);
entry_addr = netlbl_af4list_remove(addr->s_addr, mask->s_addr,
- &entry_map->type_def.addrsel->list4);
+ &entry_map->def.addrsel->list4);
spin_unlock(&netlbl_domhsh_lock);
if (entry_addr == NULL)
goto remove_af4_failure;
- netlbl_af4list_foreach_rcu(iter4, &entry_map->type_def.addrsel->list4)
+ netlbl_af4list_foreach_rcu(iter4, &entry_map->def.addrsel->list4)
goto remove_af4_single_addr;
#if IS_ENABLED(CONFIG_IPV6)
- netlbl_af6list_foreach_rcu(iter6, &entry_map->type_def.addrsel->list6)
+ netlbl_af6list_foreach_rcu(iter6, &entry_map->def.addrsel->list6)
goto remove_af4_single_addr;
#endif /* IPv6 */
/* the domain mapping is empty so remove it from the mapping table */
@@ -616,7 +614,7 @@ remove_af4_single_addr:
* shouldn't be a problem */
synchronize_rcu();
entry = netlbl_domhsh_addr4_entry(entry_addr);
- cipso_v4_doi_putdef(entry->type_def.cipsov4);
+ cipso_v4_doi_putdef(entry->def.cipso);
kfree(entry);
return 0;
@@ -693,8 +691,8 @@ struct netlbl_dom_map *netlbl_domhsh_getentry(const char *domain)
* responsible for ensuring that rcu_read_[un]lock() is called.
*
*/
-struct netlbl_domaddr4_map *netlbl_domhsh_getentry_af4(const char *domain,
- __be32 addr)
+struct netlbl_dommap_def *netlbl_domhsh_getentry_af4(const char *domain,
+ __be32 addr)
{
struct netlbl_dom_map *dom_iter;
struct netlbl_af4list *addr_iter;
@@ -702,15 +700,13 @@ struct netlbl_domaddr4_map *netlbl_domhsh_getentry_af4(const char *domain,
dom_iter = netlbl_domhsh_search_def(domain);
if (dom_iter == NULL)
return NULL;
- if (dom_iter->type != NETLBL_NLTYPE_ADDRSELECT)
- return NULL;
- addr_iter = netlbl_af4list_search(addr,
- &dom_iter->type_def.addrsel->list4);
+ if (dom_iter->def.type != NETLBL_NLTYPE_ADDRSELECT)
+ return &dom_iter->def;
+ addr_iter = netlbl_af4list_search(addr, &dom_iter->def.addrsel->list4);
if (addr_iter == NULL)
return NULL;
-
- return netlbl_domhsh_addr4_entry(addr_iter);
+ return &(netlbl_domhsh_addr4_entry(addr_iter)->def);
}
#if IS_ENABLED(CONFIG_IPV6)
@@ -725,7 +721,7 @@ struct netlbl_domaddr4_map *netlbl_domhsh_getentry_af4(const char *domain,
* responsible for ensuring that rcu_read_[un]lock() is called.
*
*/
-struct netlbl_domaddr6_map *netlbl_domhsh_getentry_af6(const char *domain,
+struct netlbl_dommap_def *netlbl_domhsh_getentry_af6(const char *domain,
const struct in6_addr *addr)
{
struct netlbl_dom_map *dom_iter;
@@ -734,15 +730,13 @@ struct netlbl_domaddr6_map *netlbl_domhsh_getentry_af6(const char *domain,
dom_iter = netlbl_domhsh_search_def(domain);
if (dom_iter == NULL)
return NULL;
- if (dom_iter->type != NETLBL_NLTYPE_ADDRSELECT)
- return NULL;
- addr_iter = netlbl_af6list_search(addr,
- &dom_iter->type_def.addrsel->list6);
+ if (dom_iter->def.type != NETLBL_NLTYPE_ADDRSELECT)
+ return &dom_iter->def;
+ addr_iter = netlbl_af6list_search(addr, &dom_iter->def.addrsel->list6);
if (addr_iter == NULL)
return NULL;
-
- return netlbl_domhsh_addr6_entry(addr_iter);
+ return &(netlbl_domhsh_addr6_entry(addr_iter)->def);
}
#endif /* IPv6 */
diff --git a/net/netlabel/netlabel_domainhash.h b/net/netlabel/netlabel_domainhash.h
index 90872c4..b9be0ee 100644
--- a/net/netlabel/netlabel_domainhash.h
+++ b/net/netlabel/netlabel_domainhash.h
@@ -43,37 +43,35 @@
#define NETLBL_DOMHSH_BITSIZE 7
/* Domain mapping definition structures */
+struct netlbl_domaddr_map {
+ struct list_head list4;
+ struct list_head list6;
+};
+struct netlbl_dommap_def {
+ u32 type;
+ union {
+ struct netlbl_domaddr_map *addrsel;
+ struct cipso_v4_doi *cipso;
+ };
+};
#define netlbl_domhsh_addr4_entry(iter) \
container_of(iter, struct netlbl_domaddr4_map, list)
struct netlbl_domaddr4_map {
- u32 type;
- union {
- struct cipso_v4_doi *cipsov4;
- } type_def;
+ struct netlbl_dommap_def def;
struct netlbl_af4list list;
};
#define netlbl_domhsh_addr6_entry(iter) \
container_of(iter, struct netlbl_domaddr6_map, list)
struct netlbl_domaddr6_map {
- u32 type;
-
- /* NOTE: no 'type_def' union needed at present since we don't currently
- * support any IPv6 labeling protocols */
+ struct netlbl_dommap_def def;
struct netlbl_af6list list;
};
-struct netlbl_domaddr_map {
- struct list_head list4;
- struct list_head list6;
-};
+
struct netlbl_dom_map {
char *domain;
- u32 type;
- union {
- struct cipso_v4_doi *cipsov4;
- struct netlbl_domaddr_map *addrsel;
- } type_def;
+ struct netlbl_dommap_def def;
u32 valid;
struct list_head list;
@@ -97,16 +95,16 @@ int netlbl_domhsh_remove_af4(const char *domain,
int netlbl_domhsh_remove(const char *domain, struct netlbl_audit *audit_info);
int netlbl_domhsh_remove_default(struct netlbl_audit *audit_info);
struct netlbl_dom_map *netlbl_domhsh_getentry(const char *domain);
-struct netlbl_domaddr4_map *netlbl_domhsh_getentry_af4(const char *domain,
- __be32 addr);
+struct netlbl_dommap_def *netlbl_domhsh_getentry_af4(const char *domain,
+ __be32 addr);
+#if IS_ENABLED(CONFIG_IPV6)
+struct netlbl_dommap_def *netlbl_domhsh_getentry_af6(const char *domain,
+ const struct in6_addr *addr);
+#endif /* IPv6 */
+
int netlbl_domhsh_walk(u32 *skip_bkt,
u32 *skip_chain,
int (*callback) (struct netlbl_dom_map *entry, void *arg),
void *cb_arg);
-#if IS_ENABLED(CONFIG_IPV6)
-struct netlbl_domaddr6_map *netlbl_domhsh_getentry_af6(const char *domain,
- const struct in6_addr *addr);
-#endif /* IPv6 */
-
#endif
diff --git a/net/netlabel/netlabel_kapi.c b/net/netlabel/netlabel_kapi.c
index 7c94aed..96a458e 100644
--- a/net/netlabel/netlabel_kapi.c
+++ b/net/netlabel/netlabel_kapi.c
@@ -122,7 +122,7 @@ int netlbl_cfg_unlbl_map_add(const char *domain,
}
if (addr == NULL && mask == NULL)
- entry->type = NETLBL_NLTYPE_UNLABELED;
+ entry->def.type = NETLBL_NLTYPE_UNLABELED;
else if (addr != NULL && mask != NULL) {
addrmap = kzalloc(sizeof(*addrmap), GFP_ATOMIC);
if (addrmap == NULL)
@@ -137,7 +137,7 @@ int netlbl_cfg_unlbl_map_add(const char *domain,
map4 = kzalloc(sizeof(*map4), GFP_ATOMIC);
if (map4 == NULL)
goto cfg_unlbl_map_add_failure;
- map4->type = NETLBL_NLTYPE_UNLABELED;
+ map4->def.type = NETLBL_NLTYPE_UNLABELED;
map4->list.addr = addr4->s_addr & mask4->s_addr;
map4->list.mask = mask4->s_addr;
map4->list.valid = 1;
@@ -154,7 +154,7 @@ int netlbl_cfg_unlbl_map_add(const char *domain,
map6 = kzalloc(sizeof(*map6), GFP_ATOMIC);
if (map6 == NULL)
goto cfg_unlbl_map_add_failure;
- map6->type = NETLBL_NLTYPE_UNLABELED;
+ map6->def.type = NETLBL_NLTYPE_UNLABELED;
map6->list.addr = *addr6;
map6->list.addr.s6_addr32[0] &= mask6->s6_addr32[0];
map6->list.addr.s6_addr32[1] &= mask6->s6_addr32[1];
@@ -174,8 +174,8 @@ int netlbl_cfg_unlbl_map_add(const char *domain,
break;
}
- entry->type_def.addrsel = addrmap;
- entry->type = NETLBL_NLTYPE_ADDRSELECT;
+ entry->def.addrsel = addrmap;
+ entry->def.type = NETLBL_NLTYPE_ADDRSELECT;
} else {
ret_val = -EINVAL;
goto cfg_unlbl_map_add_failure;
@@ -355,8 +355,8 @@ int netlbl_cfg_cipsov4_map_add(u32 doi,
}
if (addr == NULL && mask == NULL) {
- entry->type_def.cipsov4 = doi_def;
- entry->type = NETLBL_NLTYPE_CIPSOV4;
+ entry->def.cipso = doi_def;
+ entry->def.type = NETLBL_NLTYPE_CIPSOV4;
} else if (addr != NULL && mask != NULL) {
addrmap = kzalloc(sizeof(*addrmap), GFP_ATOMIC);
if (addrmap == NULL)
@@ -367,8 +367,8 @@ int netlbl_cfg_cipsov4_map_add(u32 doi,
addrinfo = kzalloc(sizeof(*addrinfo), GFP_ATOMIC);
if (addrinfo == NULL)
goto out_addrinfo;
- addrinfo->type_def.cipsov4 = doi_def;
- addrinfo->type = NETLBL_NLTYPE_CIPSOV4;
+ addrinfo->def.cipso = doi_def;
+ addrinfo->def.type = NETLBL_NLTYPE_CIPSOV4;
addrinfo->list.addr = addr->s_addr & mask->s_addr;
addrinfo->list.mask = mask->s_addr;
addrinfo->list.valid = 1;
@@ -376,8 +376,8 @@ int netlbl_cfg_cipsov4_map_add(u32 doi,
if (ret_val != 0)
goto cfg_cipsov4_map_add_failure;
- entry->type_def.addrsel = addrmap;
- entry->type = NETLBL_NLTYPE_ADDRSELECT;
+ entry->def.addrsel = addrmap;
+ entry->def.type = NETLBL_NLTYPE_ADDRSELECT;
} else {
ret_val = -EINVAL;
goto out_addrmap;
@@ -657,14 +657,14 @@ int netlbl_sock_setattr(struct sock *sk,
}
switch (family) {
case AF_INET:
- switch (dom_entry->type) {
+ switch (dom_entry->def.type) {
case NETLBL_NLTYPE_ADDRSELECT:
ret_val = -EDESTADDRREQ;
break;
case NETLBL_NLTYPE_CIPSOV4:
ret_val = cipso_v4_sock_setattr(sk,
- dom_entry->type_def.cipsov4,
- secattr);
+ dom_entry->def.cipso,
+ secattr);
break;
case NETLBL_NLTYPE_UNLABELED:
ret_val = 0;
@@ -754,23 +754,22 @@ int netlbl_conn_setattr(struct sock *sk,
{
int ret_val;
struct sockaddr_in *addr4;
- struct netlbl_domaddr4_map *af4_entry;
+ struct netlbl_dommap_def *entry;
rcu_read_lock();
switch (addr->sa_family) {
case AF_INET:
addr4 = (struct sockaddr_in *)addr;
- af4_entry = netlbl_domhsh_getentry_af4(secattr->domain,
- addr4->sin_addr.s_addr);
- if (af4_entry == NULL) {
+ entry = netlbl_domhsh_getentry_af4(secattr->domain,
+ addr4->sin_addr.s_addr);
+ if (entry == NULL) {
ret_val = -ENOENT;
goto conn_setattr_return;
}
- switch (af4_entry->type) {
+ switch (entry->type) {
case NETLBL_NLTYPE_CIPSOV4:
ret_val = cipso_v4_sock_setattr(sk,
- af4_entry->type_def.cipsov4,
- secattr);
+ entry->cipso, secattr);
break;
case NETLBL_NLTYPE_UNLABELED:
/* just delete the protocols we support for right now
@@ -812,36 +811,21 @@ int netlbl_req_setattr(struct request_sock *req,
const struct netlbl_lsm_secattr *secattr)
{
int ret_val;
- struct netlbl_dom_map *dom_entry;
- struct netlbl_domaddr4_map *af4_entry;
- u32 proto_type;
- struct cipso_v4_doi *proto_cv4;
+ struct netlbl_dommap_def *entry;
rcu_read_lock();
- dom_entry = netlbl_domhsh_getentry(secattr->domain);
- if (dom_entry == NULL) {
- ret_val = -ENOENT;
- goto req_setattr_return;
- }
switch (req->rsk_ops->family) {
case AF_INET:
- if (dom_entry->type == NETLBL_NLTYPE_ADDRSELECT) {
- struct inet_request_sock *req_inet = inet_rsk(req);
- af4_entry = netlbl_domhsh_getentry_af4(secattr->domain,
- req_inet->rmt_addr);
- if (af4_entry == NULL) {
- ret_val = -ENOENT;
- goto req_setattr_return;
- }
- proto_type = af4_entry->type;
- proto_cv4 = af4_entry->type_def.cipsov4;
- } else {
- proto_type = dom_entry->type;
- proto_cv4 = dom_entry->type_def.cipsov4;
+ entry = netlbl_domhsh_getentry_af4(secattr->domain,
+ inet_rsk(req)->rmt_addr);
+ if (entry == NULL) {
+ ret_val = -ENOENT;
+ goto req_setattr_return;
}
- switch (proto_type) {
+ switch (entry->type) {
case NETLBL_NLTYPE_CIPSOV4:
- ret_val = cipso_v4_req_setattr(req, proto_cv4, secattr);
+ ret_val = cipso_v4_req_setattr(req,
+ entry->cipso, secattr);
break;
case NETLBL_NLTYPE_UNLABELED:
/* just delete the protocols we support for right now
@@ -899,23 +883,21 @@ int netlbl_skbuff_setattr(struct sk_buff *skb,
{
int ret_val;
struct iphdr *hdr4;
- struct netlbl_domaddr4_map *af4_entry;
+ struct netlbl_dommap_def *entry;
rcu_read_lock();
switch (family) {
case AF_INET:
hdr4 = ip_hdr(skb);
- af4_entry = netlbl_domhsh_getentry_af4(secattr->domain,
- hdr4->daddr);
- if (af4_entry == NULL) {
+ entry = netlbl_domhsh_getentry_af4(secattr->domain,hdr4->daddr);
+ if (entry == NULL) {
ret_val = -ENOENT;
goto skbuff_setattr_return;
}
- switch (af4_entry->type) {
+ switch (entry->type) {
case NETLBL_NLTYPE_CIPSOV4:
- ret_val = cipso_v4_skbuff_setattr(skb,
- af4_entry->type_def.cipsov4,
- secattr);
+ ret_val = cipso_v4_skbuff_setattr(skb, entry->cipso,
+ secattr);
break;
case NETLBL_NLTYPE_UNLABELED:
/* just delete the protocols we support for right now
diff --git a/net/netlabel/netlabel_mgmt.c b/net/netlabel/netlabel_mgmt.c
index c5384ff..dd1c37d 100644
--- a/net/netlabel/netlabel_mgmt.c
+++ b/net/netlabel/netlabel_mgmt.c
@@ -104,7 +104,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
ret_val = -ENOMEM;
goto add_failure;
}
- entry->type = nla_get_u32(info->attrs[NLBL_MGMT_A_PROTOCOL]);
+ entry->def.type = nla_get_u32(info->attrs[NLBL_MGMT_A_PROTOCOL]);
if (info->attrs[NLBL_MGMT_A_DOMAIN]) {
size_t tmp_size = nla_len(info->attrs[NLBL_MGMT_A_DOMAIN]);
entry->domain = kmalloc(tmp_size, GFP_KERNEL);
@@ -116,12 +116,12 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
info->attrs[NLBL_MGMT_A_DOMAIN], tmp_size);
}
- /* NOTE: internally we allow/use a entry->type value of
+ /* NOTE: internally we allow/use a entry->def.type value of
* NETLBL_NLTYPE_ADDRSELECT but we don't currently allow users
* to pass that as a protocol value because we need to know the
* "real" protocol */
- switch (entry->type) {
+ switch (entry->def.type) {
case NETLBL_NLTYPE_UNLABELED:
break;
case NETLBL_NLTYPE_CIPSOV4:
@@ -132,7 +132,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
cipsov4 = cipso_v4_doi_getdef(tmp_val);
if (cipsov4 == NULL)
goto add_failure;
- entry->type_def.cipsov4 = cipsov4;
+ entry->def.cipso = cipsov4;
break;
default:
goto add_failure;
@@ -172,9 +172,9 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
map->list.addr = addr->s_addr & mask->s_addr;
map->list.mask = mask->s_addr;
map->list.valid = 1;
- map->type = entry->type;
+ map->def.type = entry->def.type;
if (cipsov4)
- map->type_def.cipsov4 = cipsov4;
+ map->def.cipso = cipsov4;
ret_val = netlbl_af4list_add(&map->list, &addrmap->list4);
if (ret_val != 0) {
@@ -182,8 +182,8 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
goto add_failure;
}
- entry->type = NETLBL_NLTYPE_ADDRSELECT;
- entry->type_def.addrsel = addrmap;
+ entry->def.type = NETLBL_NLTYPE_ADDRSELECT;
+ entry->def.addrsel = addrmap;
#if IS_ENABLED(CONFIG_IPV6)
} else if (info->attrs[NLBL_MGMT_A_IPV6ADDR]) {
struct in6_addr *addr;
@@ -223,7 +223,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
map->list.addr.s6_addr32[3] &= mask->s6_addr32[3];
map->list.mask = *mask;
map->list.valid = 1;
- map->type = entry->type;
+ map->def.type = entry->def.type;
ret_val = netlbl_af6list_add(&map->list, &addrmap->list6);
if (ret_val != 0) {
@@ -231,8 +231,8 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
goto add_failure;
}
- entry->type = NETLBL_NLTYPE_ADDRSELECT;
- entry->type_def.addrsel = addrmap;
+ entry->def.type = NETLBL_NLTYPE_ADDRSELECT;
+ entry->def.addrsel = addrmap;
#endif /* IPv6 */
}
@@ -281,14 +281,13 @@ static int netlbl_mgmt_listentry(struct sk_buff *skb,
return ret_val;
}
- switch (entry->type) {
+ switch (entry->def.type) {
case NETLBL_NLTYPE_ADDRSELECT:
nla_a = nla_nest_start(skb, NLBL_MGMT_A_SELECTORLIST);
if (nla_a == NULL)
return -ENOMEM;
- netlbl_af4list_foreach_rcu(iter4,
- &entry->type_def.addrsel->list4) {
+ netlbl_af4list_foreach_rcu(iter4, &entry->def.addrsel->list4) {
struct netlbl_domaddr4_map *map4;
struct in_addr addr_struct;
@@ -310,13 +309,13 @@ static int netlbl_mgmt_listentry(struct sk_buff *skb,
return ret_val;
map4 = netlbl_domhsh_addr4_entry(iter4);
ret_val = nla_put_u32(skb, NLBL_MGMT_A_PROTOCOL,
- map4->type);
+ map4->def.type);
if (ret_val != 0)
return ret_val;
- switch (map4->type) {
+ switch (map4->def.type) {
case NETLBL_NLTYPE_CIPSOV4:
ret_val = nla_put_u32(skb, NLBL_MGMT_A_CV4DOI,
- map4->type_def.cipsov4->doi);
+ map4->def.cipso->doi);
if (ret_val != 0)
return ret_val;
break;
@@ -325,8 +324,7 @@ static int netlbl_mgmt_listentry(struct sk_buff *skb,
nla_nest_end(skb, nla_b);
}
#if IS_ENABLED(CONFIG_IPV6)
- netlbl_af6list_foreach_rcu(iter6,
- &entry->type_def.addrsel->list6) {
+ netlbl_af6list_foreach_rcu(iter6, &entry->def.addrsel->list6) {
struct netlbl_domaddr6_map *map6;
nla_b = nla_nest_start(skb, NLBL_MGMT_A_ADDRSELECTOR);
@@ -345,7 +343,7 @@ static int netlbl_mgmt_listentry(struct sk_buff *skb,
return ret_val;
map6 = netlbl_domhsh_addr6_entry(iter6);
ret_val = nla_put_u32(skb, NLBL_MGMT_A_PROTOCOL,
- map6->type);
+ map6->def.type);
if (ret_val != 0)
return ret_val;
@@ -356,14 +354,14 @@ static int netlbl_mgmt_listentry(struct sk_buff *skb,
nla_nest_end(skb, nla_a);
break;
case NETLBL_NLTYPE_UNLABELED:
- ret_val = nla_put_u32(skb, NLBL_MGMT_A_PROTOCOL, entry->type);
+ ret_val = nla_put_u32(skb,NLBL_MGMT_A_PROTOCOL,entry->def.type);
break;
case NETLBL_NLTYPE_CIPSOV4:
- ret_val = nla_put_u32(skb, NLBL_MGMT_A_PROTOCOL, entry->type);
+ ret_val = nla_put_u32(skb,NLBL_MGMT_A_PROTOCOL,entry->def.type);
if (ret_val != 0)
return ret_val;
ret_val = nla_put_u32(skb, NLBL_MGMT_A_CV4DOI,
- entry->type_def.cipsov4->doi);
+ entry->def.cipso->doi);
break;
}
diff --git a/net/netlabel/netlabel_unlabeled.c b/net/netlabel/netlabel_unlabeled.c
index af35319..8f08974 100644
--- a/net/netlabel/netlabel_unlabeled.c
+++ b/net/netlabel/netlabel_unlabeled.c
@@ -1541,7 +1541,7 @@ int __init netlbl_unlabel_defconf(void)
entry = kzalloc(sizeof(*entry), GFP_KERNEL);
if (entry == NULL)
return -ENOMEM;
- entry->type = NETLBL_NLTYPE_UNLABELED;
+ entry->def.type = NETLBL_NLTYPE_UNLABELED;
ret_val = netlbl_domhsh_add_default(entry, &audit_info);
if (ret_val != 0)
return ret_val;
^ permalink raw reply related
* Re: locating the 'tc actions' hook
From: John Fastabend @ 2013-08-02 18:46 UTC (permalink / raw)
To: Jamal Hadi Salim
Cc: John Fastabend, Stephen Hemminger, Eric Dumazet, Tom Herbert,
netdev
In-Reply-To: <51FAECBF.3030704@intel.com>
On 08/01/2013 04:18 PM, John Fastabend wrote:
> [...]
>
>>> Am I missing something obvious here? Is there a way to link them to
>>> filters? Sorry if it turns out to be a stupid question.
>>>
>>
>> I think the second use case is what you are bumping into. I know from
>> answering questions this is a very popular use case in some eastern
>> European countries (where one policer with a specific rate is shared
>> by many flows); i think they have a setup where you share your DSL
>> connection with your neighbors. Its quiet a clever setup.
>>
>
> Great thanks I was missing part (b) above. Now I see how the index
> works.
>
Perhaps another incorrect observation but what protects the tc_actions?
Create a series of actions via 'tc actions' which populates the hash
table protected by hinfo->lock and also rtnetlink is holding the rtnl
lock.
Add a filter with index hook to get this action graph attached to a
filters tcf_exts pointer.
Now for what I think is the race, the classifier will call tcf_exts_exec
which will call tcf_action_exec() and start walking the actions and
executing them with the qdisc_lock held.
At the same time tcf_action_destroy() may be called via 'tc actions
delete' which will only hold the rtnl lock via rtnetlink.
Again I think I might be missing a piece somewhere but I'm not seeing
how the locking adds up here. I'll look at it a bit more but thought
it might be worth asking.
>>
>>> My motivation here is to use the filters/actions outside the qdisc lock
>>> for mq, mqprio, and the ingress qdisc.
>>>
>>
>> Are you trying to offload these actions into hardware?
>> Is the classifier in hardware?
>> Please let me know if you need further help. Example, I could send you
>> a bunch of examples for either
>>
>
> I have two things in mind for this.
>
> The first being directly related to the previous per queue rate limiter
> patch. With rate limiters per queue on a multiqueue device using mq or
> mqprio I need some mechanism to steer packets to queues. One way to do
> this is to use mqprio and create a 'tc' with a single queue in it.
> And then use iptables or netprio_cgroup to steer packets. Another way
> to do this would be to use 'skbedit queue_mapping' to set the queue from
> 'tc' but unfortunately with the existing flows the queue has already
> been selected by the time the classifiers are called. Calling into the
> classifier chain before picking the qdisc would fix this. For flow based
> QOS with multiqueue devices this type of functionality would be useful.
>
> The second thought that I've been piecing together would be to populate
> the rxhash (or maybe some other field) using the hardware flow
> classifier in some meaningful way for the ingress qdisc. Some of the
> existing Intel NICs can do this and I believe other vendors have similar
> capabilities. Although currently with the qdisc lock running around the
> ingress qdisc the multiqueue devices take a perf hit just by
> instantiating the ingress qdisc which really is only using the lock to
> guard some stats and keep the classifier/action chains sane.
>
> If you have some good examples it would be great to see them and drop
> them in my testbed. Go ahead and send them to me offlist if you can.
>
> .John
>
>> cheers,
>> jamal
>>
>>
>>> .John
>>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe netdev" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
John Fastabend Intel Corporation
^ permalink raw reply
* Query: Regarding 8211E Phy module support in drivers/net/phy
From: Sharma Bhupesh-B45370 @ 2013-08-02 18:50 UTC (permalink / raw)
To: 'peppe.cavallaro@st.com'; +Cc: 'netdev@vger.kernel.org'
Hi Peppe,
This regarding the patch prepared by you for adding RTL8211E support in
drivers/net/phy/realtek.c
commit ef3d90491a15f0d5cf1ec39a38a45dac6968fb2a
Author: Giuseppe CAVALLARO <peppe.cavallaro@st.com>
Date: Wed Jan 23 00:30:03 2013 +0000
net: phy: realtek: add rtl8211e driver
This patch adds the minimal driver to manage the
Realtek RTL8211E 10/100/1000 Transceivers.
I see a macro specific to 8211E:
+#define RTL8211E_INER_LINK_STAT 0x10
I was having a look at the RTL8211E(G) datasheet and could see
the following bit positions for INER register (Address 0x12):
[7:1] as Reserved
[0] as Jabber Interrupt
If I am not wrong a value 0x10 written to the INER register tries to set bit [4] which seems
Reserved.
Or am I missing something here.
Please let me know your views on the same.
Thanks,
Bhupesh
^ permalink raw reply
* Re: [PATCH v3] sis900: Fix the tx queue timeout issue
From: Ben Hutchings @ 2013-08-02 19:18 UTC (permalink / raw)
To: Denis Kirjanov; +Cc: davem, venza, B38611, netdev
In-Reply-To: <1375437054-1995-1-git-send-email-kda@linux-powerpc.org>
On Fri, 2013-08-02 at 13:50 +0400, Denis Kirjanov wrote:
> [ 198.720048] ------------[ cut here ]------------
> [ 198.720108] WARNING: CPU: 0 PID: 0 at net/sched/sch_generic.c:255 dev_watchdog+0x229/0x240()
> [ 198.720118] NETDEV WATCHDOG: eth0 (sis900): transmit queue 0 timed out
> [ 198.720125] Modules linked in: bridge stp llc dmfe sundance 3c59x sis900 mii
> [ 198.720159] CPU: 0 PID: 0 Comm: swapper Not tainted 3.11.0-rc3+ #12
> [ 198.720167] Hardware name: System Manufacturer System Name/TUSI-M, BIOS ASUS TUSI-M ACPI BIOS
> Revision 1013 Beta 001 12/14/2001
> [ 198.720175] 000000ff c13fa6b9 c169ddcc c12208d6 c169ddf8 c1031e4d c1664a84 c169de24
> [ 198.720197] 00000000 c165f5ea 000000ff c13fa6b9 00000001 000000ff c1664a84 c169de10
> [ 198.720217] c1031f13 00000009 c169de08 c1664a84 c169de24 c169de50 c13fa6b9 c165f5ea
> [ 198.720240] Call Trace:
> [ 198.720257] [<c13fa6b9>] ? dev_watchdog+0x229/0x240
> [ 198.720274] [<c12208d6>] dump_stack+0x16/0x20
> [ 198.720306] [<c1031e4d>] warn_slowpath_common+0x7d/0xa0
> [ 198.720318] [<c13fa6b9>] ? dev_watchdog+0x229/0x240
> [ 198.720330] [<c1031f13>] warn_slowpath_fmt+0x33/0x40
> [ 198.720342] [<c13fa6b9>] dev_watchdog+0x229/0x240
> [ 198.720357] [<c103f158>] call_timer_fn+0x78/0x150
> [ 198.720369] [<c103f0e0>] ? internal_add_timer+0x40/0x40
> [ 198.720381] [<c13fa490>] ? dev_init_scheduler+0xa0/0xa0
> [ 198.720392] [<c103f33f>] run_timer_softirq+0x10f/0x200
> [ 198.720412] [<c103954f>] ? __do_softirq+0x6f/0x210
> [ 198.720424] [<c13fa490>] ? dev_init_scheduler+0xa0/0xa0
> [ 198.720435] [<c1039598>] __do_softirq+0xb8/0x210
> [ 198.720467] [<c14b54d2>] ? _raw_spin_unlock+0x22/0x30
> [ 198.720484] [<c1003245>] ? handle_irq+0x25/0xd0
> [ 198.720496] [<c1039c0c>] irq_exit+0x9c/0xb0
> [ 198.720508] [<c14bc9d7>] do_IRQ+0x47/0x94
> [ 198.720534] [<c1056078>] ? hrtimer_start+0x28/0x30
> [ 198.720564] [<c14bc8b1>] common_interrupt+0x31/0x38
> [ 198.720589] [<c1008692>] ? default_idle+0x22/0xa0
> [ 198.720600] [<c10083c7>] arch_cpu_idle+0x17/0x30
> [ 198.720631] [<c106d23d>] cpu_startup_entry+0xcd/0x180
> [ 198.720643] [<c14ae30a>] rest_init+0xaa/0xb0
> [ 198.720654] [<c14ae260>] ? reciprocal_value+0x50/0x50
> [ 198.720668] [<c17044e0>] ? repair_env_string+0x60/0x60
> [ 198.720679] [<c1704bda>] start_kernel+0x29a/0x350
> [ 198.720690] [<c17044e0>] ? repair_env_string+0x60/0x60
> [ 198.720721] [<c1704269>] i386_start_kernel+0x39/0xa0
> [ 198.720729] ---[ end trace 81e0a6266f5c73a8 ]---
> [ 198.720740] eth0: Transmit timeout, status 00000204 00000000
>
> timer routine checks the link status and if it's up calls
> netif_carrier_on() allowing upper layer to start the tx queue
> even if the auto-negotiation process is not finished.
>
> Also remove ugly auto-negotiation check from the sis900_start_xmit()
>
> CC: Duan Fugang <B38611@freescale.com>
> CC: Ben Hutchings <bhutchings@solarflare.com>
>
> Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
> ---
> v1->v2: use netdev_dbg() instead of printk()
> v2->v3:
> handle link change from timer,
> remove auto-negotiation check from xmit path
This looks reasonable. It looks like link changes now work like this:
1. When sis900_timer() detects link-down, it calls netif_carrier_off()
but does not clear autong_complete.
2. When sis900_timer() detects link-up, it calls sis900_check_mode()
which restarts autonegotiation and clears autong_complete.
3. sis900_timer() will now call sis900_read_mode(). When that detects
link-up, it sets autong_complete and calls netif_carrier_on().
This patch has moved the call to netif_carrier_on() from step 2 to step
3. However, I don't understand why autonegotiation is restarted in step
2. When autonegotiation is enabled, the PHY should not indicate link-up
until it has completed. Perhaps this is a necessary workaround for a
hardware bug. Otherwise it's a waste of time.
Ben.
> ---
> drivers/net/ethernet/sis/sis900.c | 12 ++----------
> 1 file changed, 2 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/net/ethernet/sis/sis900.c b/drivers/net/ethernet/sis/sis900.c
> index eb4aea3..f5d7ad7 100644
> --- a/drivers/net/ethernet/sis/sis900.c
> +++ b/drivers/net/ethernet/sis/sis900.c
> @@ -1318,7 +1318,7 @@ static void sis900_timer(unsigned long data)
> if (duplex){
> sis900_set_mode(sis_priv, speed, duplex);
> sis630_set_eq(net_dev, sis_priv->chipset_rev);
> - netif_start_queue(net_dev);
> + netif_carrier_on(net_dev);
> }
>
> sis_priv->timer.expires = jiffies + HZ;
> @@ -1336,10 +1336,8 @@ static void sis900_timer(unsigned long data)
> status = sis900_default_phy(net_dev);
> mii_phy = sis_priv->mii;
>
> - if (status & MII_STAT_LINK){
> + if (status & MII_STAT_LINK)
> sis900_check_mode(net_dev, mii_phy);
> - netif_carrier_on(net_dev);
> - }
> } else {
> /* Link ON -> OFF */
> if (!(status & MII_STAT_LINK)){
> @@ -1612,12 +1610,6 @@ sis900_start_xmit(struct sk_buff *skb, struct net_device *net_dev)
> unsigned int index_cur_tx, index_dirty_tx;
> unsigned int count_dirty_tx;
>
> - /* Don't transmit data before the complete of auto-negotiation */
> - if(!sis_priv->autong_complete){
> - netif_stop_queue(net_dev);
> - return NETDEV_TX_BUSY;
> - }
> -
> spin_lock_irqsave(&sis_priv->lock, flags);
>
> /* Calculate the next Tx descriptor entry. */
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply
* Re: [PATCH V3 0/3] networking: Use ETH_ALEN where appropriate
From: David Miller @ 2013-08-02 19:34 UTC (permalink / raw)
To: joe
Cc: wimax, netdev, linux-usb, linux-kernel, virtualization,
netfilter-devel, linuxppc-dev, linux-arm-kernel, linux-media
In-Reply-To: <cover.1375398692.git.joe@perches.com>
From: Joe Perches <joe@perches.com>
Date: Thu, 1 Aug 2013 16:17:46 -0700
> Convert the uses mac addresses to ETH_ALEN so
> it's easier to find and verify where mac addresses
> need to be __aligned(2)
Series applied to net-next, thanks.
^ permalink raw reply
* Re: [PATCH net-next] sctp: Don't lookup dst if transport dst is still valid
From: David Miller @ 2013-08-02 19:36 UTC (permalink / raw)
To: vyasevich; +Cc: fan.du, nhorman, netdev
In-Reply-To: <51FBC8CA.8030005@gmail.com>
From: Vlad Yasevich <vyasevich@gmail.com>
Date: Fri, 02 Aug 2013 10:57:14 -0400
> On 08/01/2013 10:45 PM, Fan Du wrote:
>> When sctp sits on IPv6, sctp_transport_dst_check pass cookie as ZERO,
>> as a result ip6_dst_check always fail out. This behaviour makes
>> transport->dst useless, because every sctp_packet_transmit must look
>> for valid dst.
>>
>> Add a dst_cookie into sctp_transport, and set the cookie whenever we
>> get new dst for sctp_transport. So dst validness could be checked
>> against it.
>>
>> Since I have split genid for IPv4 and IPv6, also delete/add IPv6
>> address
>> will also bump IPv6 genid. So issues we discussed in:
>> http://marc.info/?l=linux-netdev&m=137404469219410&w=4
>> have all been sloved for this patch.
>>
>> Signed-off-by: Fan Du <fan.du@windriver.com>
>
> Acked-by: Vlad Yasevich <vyasevich@gmail.com>
Applied.
^ permalink raw reply
* RE: Question regarding failure utilizing bonding mode 5 (balance-tlb)
From: Yuval Mintz @ 2013-08-02 20:16 UTC (permalink / raw)
To: Jay Vosburgh; +Cc: netdev@vger.kernel.org, Ariel Elior
In-Reply-To: <7717.1375412975@death.nxdomain>
> >We've had reports that load/unload tests using bonding driver in
> >balance-tlb mode over bnx2x interfaces results in loss of traffic.
>
> I've also been looking into what I suspect is the same thing,
> although using bnx2 and not bnx2x.
Makes sense, given that both follow the same paradigms.
> >When the active slave is unloaded, the ifconfig MAC (dev_addr) is
> >swapped between the slaves directly, i.e., without calling the ndo. Once
> >the interface of the previously active slave will be reloaded, it will
> >configure it's HW MAC according to that dev_addr value (i.e., the
> >bonding driver takes no additional measures to force it's own MAC on the
> >interface when re-loading), causing it to have a configured MAC which
> >differs from the one that is held by the bonding driver.
> The part I don't follow is that in bond_enslave, this sequence
> occurs:
>
> 1. bond_enslave calls dev_set_mac_address ("the ndo") to program
> the newly added slave with the master's MAC. The ndo_set_mac_address
> functions for bnx2x and bnx2 both set dev_addr to the new address.
>
> 2. bond_enslave calls dev_open, and the driver's open function
> programs the device's MAC to what's in dev_addr, which is now the
> master's MAC address.
I think 'bond_enslave' is called only on initial enslavement - the code
doesn't make sense for me otherwise (as it seems the IFF_SLAVE indication
will be removed only when the slave notify of NETDEV_UNREGISTER, i.e.,
when it is rmmoded and not the interface is closed).
>
> The above is true, unless fail_over_mac is enabled, and that's
> not a valid option for tlb mode.
>
> Also, in theory the bond will reset the slave's MAC address to
> its "permanent" address when it is released from the bond. The
> "permanent" address is whatever was in dev_addr when the device was
> enslaved.
Again, I think the permanent address is restored only when the bond
releases the slave, which I don't think happens when the slave is unloaded.
> >As I see it, either:
> >
> > 1. The bonding driver is flawed in balance-tlb mode and should be
> >fixed.
> >
> > 2. bnx2x's behaviour is flawed - it should have some persistent
> >shadow MAC which should contain the last MAC set - either factory value
> >or what was configured by the ndo, and use it instead of dev_addr when
> >configuring the HW MAC.
> >This would probably indicate that other drivers are flawed as well.
> >
> > 3. The test itself is flawed, since user should not unload slave
> >interfaces.
> >
> >What's the correct approach for fixing the issue?
>
> Well, I suspect it's not going to be #2. Loading and unloading
> slaves ought to work, and I'm willing to believe that bonding is doing
> something odd, but I don't see what it is from the above.
>
> -J
>
^ permalink raw reply
* Re: Question regarding failure utilizing bonding mode 5 (balance-tlb)
From: Jay Vosburgh @ 2013-08-02 20:53 UTC (permalink / raw)
To: Yuval Mintz; +Cc: netdev@vger.kernel.org, Ariel Elior
In-Reply-To: <979A8436335E3744ADCD3A9F2A2B68A52ACF959B@SJEXCHMB10.corp.ad.broadcom.com>
Yuval Mintz <yuvalmin@broadcom.com> wrote:
>> >We've had reports that load/unload tests using bonding driver in
>> >balance-tlb mode over bnx2x interfaces results in loss of traffic.
>>
>> I've also been looking into what I suspect is the same thing,
>> although using bnx2 and not bnx2x.
>
>Makes sense, given that both follow the same paradigms.
>
>> >When the active slave is unloaded, the ifconfig MAC (dev_addr) is
>> >swapped between the slaves directly, i.e., without calling the ndo. Once
>> >the interface of the previously active slave will be reloaded, it will
>> >configure it's HW MAC according to that dev_addr value (i.e., the
>> >bonding driver takes no additional measures to force it's own MAC on the
>> >interface when re-loading), causing it to have a configured MAC which
>> >differs from the one that is held by the bonding driver.
>> The part I don't follow is that in bond_enslave, this sequence
>> occurs:
>>
>> 1. bond_enslave calls dev_set_mac_address ("the ndo") to program
>> the newly added slave with the master's MAC. The ndo_set_mac_address
>> functions for bnx2x and bnx2 both set dev_addr to the new address.
>>
>> 2. bond_enslave calls dev_open, and the driver's open function
>> programs the device's MAC to what's in dev_addr, which is now the
>> master's MAC address.
>
>I think 'bond_enslave' is called only on initial enslavement - the code
>doesn't make sense for me otherwise (as it seems the IFF_SLAVE indication
>will be removed only when the slave notify of NETDEV_UNREGISTER, i.e.,
>when it is rmmoded and not the interface is closed).
>>
>> The above is true, unless fail_over_mac is enabled, and that's
>> not a valid option for tlb mode.
>>
>> Also, in theory the bond will reset the slave's MAC address to
>> its "permanent" address when it is released from the bond. The
>> "permanent" address is whatever was in dev_addr when the device was
>> enslaved.
>
>Again, I think the permanent address is restored only when the bond
>releases the slave, which I don't think happens when the slave is unloaded.
Ah, ok, I was understanding "unloaded" to mean "remove from the
bond." I think you actually mean "set administratively down," e.g., "ip
link set dev slave down" or the like. I don't think mere loss of
carrier would trigger the sequence of events, because that won't go
through a dev_close / dev_open cycle.
Doing that (an admin down / up bounce) would, indeed, cause a
failover, but the bond will not reprogram the MAC on the slave (it
presumes that a fail / recovery will not disrupt the MAC address, which
is apparently not true in this instance).
I'll have to look at the code a bit, but for now can you confirm
that what you actually mean is, essentially:
Given a bond0 with two slaves, eth0 and eth1, in tlb mode, eth0
being the active,
1) "ip link set dev eth0 down" which will fail over to eth1
(swapping the contents of their dev_addr fields).
2) "ip link set dev eth0 up" eth0 comes back up, reprograms its
MAC to the wrong thing (what was in dev_addr).
3) repeat steps 1 and 2 for eth1
Is this correct?
>> >As I see it, either:
>> >
>> > 1. The bonding driver is flawed in balance-tlb mode and should be
>> >fixed.
>> >
>> > 2. bnx2x's behaviour is flawed - it should have some persistent
>> >shadow MAC which should contain the last MAC set - either factory value
>> >or what was configured by the ndo, and use it instead of dev_addr when
>> >configuring the HW MAC.
>> >This would probably indicate that other drivers are flawed as well.
>> >
>> > 3. The test itself is flawed, since user should not unload slave
>> >interfaces.
>> >
>> >What's the correct approach for fixing the issue?
>>
>> Well, I suspect it's not going to be #2. Loading and unloading
>> slaves ought to work, and I'm willing to believe that bonding is doing
>> something odd, but I don't see what it is from the above.
I think my above statement is still true, but fixing this may be
a bit trickier, or may be a "best effort" type of thing. One reason is
that, nominally, the tlb mode does not require that the device be able
to change (meaning the ndo call to reprogram) its MAC while open.
This may not really be a meaningful restriction now, but when
the code was written, not every device / driver could change MAC while
open. I'm unsure if there are current users that rely on this.
-J
---
-Jay Vosburgh, IBM Linux Technology Center, fubar@us.ibm.com
^ permalink raw reply
* Re: [Patch net-next v2 1/8] net: introduce generic union inet_addr
From: David Miller @ 2013-08-02 21:50 UTC (permalink / raw)
To: amwang; +Cc: netdev, dborkman, joe, linux-kernel
In-Reply-To: <1375427674-21735-2-git-send-email-amwang@redhat.com>
From: Cong Wang <amwang@redhat.com>
Date: Fri, 2 Aug 2013 15:14:27 +0800
> From: Cong Wang <amwang@redhat.com>
>
> Introduce a generic IP address type, union inet_addr, so that
> subsystems don't have to use their own definitions. Because
> netpoll already defines union inet_addr, just move it to global.
> Some of the helper functions will be used by VXLAN IPv6 code too.
>
> This patch also reuses the "%pIS" specifier, to make it accept
> union inet_addr instead of struct sockaddr.
>
> Cc: Daniel Borkmann <dborkman@redhat.com>
> Cc: Joe Perches <joe@perches.com>
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Cong Wang <amwang@redhat.com>
Changing %pIS to %pIA is pure churn, and of zero value that I can see.
Every time I review this patch set I discover some new thing that I'm
very disappointed with.
You're going to have to stop being so ambitious, and start very small.
Maybe one tiny patch at a time if needed.
^ permalink raw reply
* Re: [Patch net-next v2 8/8] selinux: use generic union inet_addr
From: David Miller @ 2013-08-02 21:51 UTC (permalink / raw)
To: pmoore
Cc: amwang, netdev, james.l.morris, sds, eparis, linux-kernel,
linux-security-module
In-Reply-To: <4528870.px4VD3WrY3@sifl>
From: Paul Moore <pmoore@redhat.com>
Date: Fri, 02 Aug 2013 10:34:07 -0400
> On Friday, August 02, 2013 03:14:34 PM Cong Wang wrote:
>> From: Cong Wang <amwang@redhat.com>
>>
>> selinux has some similar definition like union inet_addr,
>> it can re-use the generic union inet_addr too.
>>
>> Cc: James Morris <james.l.morris@oracle.com>
>> Cc: Stephen Smalley <sds@tycho.nsa.gov>
>> Cc: Eric Paris <eparis@parisplace.org>
>> Cc: Paul Moore <pmoore@redhat.com>
>> Cc: linux-kernel@vger.kernel.org
>> Cc: linux-security-module@vger.kernel.org
>> Signed-off-by: Cong Wang <amwang@redhat.com>
>
> Perhaps I'm confusing this with another patch but I though DaveM said he
> wasn't going to merge these patches?
I didn't like how he added completely unused bloat to various
datastructures because he unconditionally put a port field into
there.
He removed that problem this time, but there are still a lot of
things I don't like about this patch series.
^ permalink raw reply
* Re: [PATCH net-next] htb: fix sign extension bug
From: David Miller @ 2013-08-02 21:52 UTC (permalink / raw)
To: eric.dumazet; +Cc: stephen, xiyou.wangcong, netdev
In-Reply-To: <1375450580.3927.12.camel@edumazet-glaptop>
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 02 Aug 2013 06:36:20 -0700
> On Thu, 2013-08-01 at 22:32 -0700, Stephen Hemminger wrote:
>> When userspace passes a large priority value
>> the assignment of the unsigned value hopt->prio
>> to signed int cl->prio causes cl->prio to become negative and the
>> comparison is with TC_HTB_NUMPRIO is always false.
>>
>> The result is that HTB crashes by referencing outside
>> the array when processing packets. With this patch the large value
>> wraps around like other values outside the normal range.
>>
>> See: https://bugzilla.kernel.org/show_bug.cgi?id=60669
>>
>> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
>>
>> --- a/net/sched/sch_htb.c 2013-06-20 09:22:46.489542435 -0700
>> +++ b/net/sched/sch_htb.c 2013-08-01 22:12:43.736307055 -0700
>> @@ -100,7 +100,7 @@ struct htb_class {
>> struct psched_ratecfg ceil;
>> s64 buffer, cbuffer;/* token bucket depth/rate */
>> s64 mbuffer; /* max wait time */
>> - int prio; /* these two are used only by leaves... */
>> + u32 prio; /* these two are used only by leaves... */
>> int quantum; /* but stored for parent-to-leaf return */
>>
>> struct tcf_proto *filter_list; /* class attached filters */
>> --
>
> Thanks Stephen.
>
> Acked-by: Eric Dumazet <edumazet@google.com>
>
> It seems appropriate for net tree (and stable)
Applied and queued up for -stable, thanks.
^ permalink raw reply
* Re: [PATCH net-next] htb: fix sign extension bug
From: David Miller @ 2013-08-02 21:53 UTC (permalink / raw)
To: stephen; +Cc: eric.dumazet, xiyou.wangcong, netdev
In-Reply-To: <20130802082404.600bc55c@nehalam.linuxnetplumber.net>
From: Stephen Hemminger <stephen@networkplumber.org>
Date: Fri, 2 Aug 2013 08:24:04 -0700
> There are more signed/unsigned bugs lurking here, and opportunities to
> shrink the structure. (for example prio could be u8). Overall this code
> uses int where unsigned should be used.
If any of them can cause an OOPS like this one could, let's get that
fixed as soon as possible.
Thanks.
^ permalink raw reply
* Re: [PATCH] net: ethernet: cpsw: drop IRQF_DISABLED
From: David Miller @ 2013-08-02 21:54 UTC (permalink / raw)
To: balbi; +Cc: mugunthanvnm, netdev, linux-omap
In-Reply-To: <1375429450-25454-1-git-send-email-balbi@ti.com>
From: Felipe Balbi <balbi@ti.com>
Date: Fri, 2 Aug 2013 10:44:10 +0300
> IRQF_DISABLED is a no-op by now and should be
> removed.
>
> Signed-off-by: Felipe Balbi <balbi@ti.com>
Applied.
^ permalink raw reply
* Re: [PATCH v3] r8169: remove "PHY reset until link up" log spam
From: David Miller @ 2013-08-02 21:55 UTC (permalink / raw)
To: romieu; +Cc: lekensteyn, sergei.shtylyov, netdev, nic_swsd
In-Reply-To: <20130802174754.GA24369@electric-eye.fr.zoreil.com>
From: Francois Romieu <romieu@fr.zoreil.com>
Date: Fri, 2 Aug 2013 19:47:54 +0200
> Peter Wu <lekensteyn@gmail.com> :
>> This message was added in commit a7154cb8 (June 2004, [PATCH] r8169:
>> link handling and phy reset rework) and is printed every ten seconds
>> when no cable is connected and runtime power management is disabled.
>> (Before that commit, "Reset RTL8169s PHY" would be printed instead.)
>>
>> Signed-off-by: Peter Wu <lekensteyn@gmail.com>
>
> Acked-by: Francois Romieu <romieu@fr.zoreil.com>
Applied.
^ permalink raw reply
* Re: [PATCH net] net: rtm_to_ifaddr: free ifa if ifa_cacheinfo processing fails
From: David Miller @ 2013-08-02 21:56 UTC (permalink / raw)
To: jiri; +Cc: dborkman, netdev
In-Reply-To: <20130802102229.GB1586@minipsycho.orion>
From: Jiri Pirko <jiri@resnulli.us>
Date: Fri, 2 Aug 2013 12:22:29 +0200
> Fri, Aug 02, 2013 at 11:32:43AM CEST, dborkman@redhat.com wrote:
>>Commit 5c766d642 ("ipv4: introduce address lifetime") leaves the ifa
>>resource that was allocated via inet_alloc_ifa() unfreed when returning
>>the function with -EINVAL. Thus, free it first via inet_free_ifa().
>>
>>Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
> Reviewed-by: Jiri Pirko <jiri@resnulli.us>
Applied and queued up for -stable, thanks.
^ permalink raw reply
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