92 lines
2.6 KiB
Diff
92 lines
2.6 KiB
Diff
From 4c0e75a22638da49dbbe78e46e61a334ada721b1 Mon Sep 17 00:00:00 2001
|
|
From: John Fastabend <john.r.fastabend@intel.com>
|
|
Date: Wed, 27 Jul 2011 15:07:48 -0700
|
|
Subject: [PATCH 14/29] lldpad: resolve segfault with ECP and bonding
|
|
|
|
A segfault occurs with ECP and bonded devices because
|
|
the port lookup fails on bonds. ECP does not verify
|
|
the port lookup is successful.
|
|
|
|
I do not believe VDP should run over the bonded interface
|
|
so this patch aborts VDP initialization on bond devices
|
|
and avoids port lookup completely.
|
|
|
|
Also add checks for null pointers in ECP.
|
|
|
|
CC: Jens Osterkamp <jens@linux.vnet.ibm.com>
|
|
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
|
|
Signed-off-by: Petr Sabata <contyk@redhat.com>
|
|
---
|
|
ecp/ecp_rx.c | 7 ++++++-
|
|
ecp/ecp_tx.c | 6 +++++-
|
|
lldp_vdp.c | 4 ++++
|
|
3 files changed, 15 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/ecp/ecp_rx.c b/ecp/ecp_rx.c
|
|
index bd5a1e1..74e9f32 100644
|
|
--- a/ecp/ecp_rx.c
|
|
+++ b/ecp/ecp_rx.c
|
|
@@ -211,7 +211,9 @@ void ecp_rx_ReceiveFrame(void *ctx, unsigned int ifindex, const u8 *buf, size_t
|
|
LLDPAD_DBG("%s(%i)-%s: received packet with size %i\n", __func__, __LINE__,
|
|
vd->ifname, (int) len);
|
|
|
|
- if (port->adminStatus == disabled || port->adminStatus == enabledTxOnly)
|
|
+ if (!port ||
|
|
+ port->adminStatus == disabled ||
|
|
+ port->adminStatus == enabledTxOnly)
|
|
return;
|
|
|
|
if (vd->ecp.rx.framein &&
|
|
@@ -534,6 +536,9 @@ bool ecp_set_rx_state(struct vdp_data *vd)
|
|
{
|
|
struct port *port = port_find_by_name(vd->ifname);
|
|
|
|
+ if (!port)
|
|
+ return false;
|
|
+
|
|
if (port->portEnabled == false) {
|
|
ecp_rx_change_state(vd, ECP_RX_IDLE);
|
|
}
|
|
diff --git a/ecp/ecp_tx.c b/ecp/ecp_tx.c
|
|
index cbf2e11..f9ee3d7 100644
|
|
--- a/ecp/ecp_tx.c
|
|
+++ b/ecp/ecp_tx.c
|
|
@@ -236,6 +236,11 @@ error:
|
|
*/
|
|
void ecp_tx_Initialize(struct vdp_data *vd)
|
|
{
|
|
+ struct port *port = port_find_by_name(vd->ifname);
|
|
+
|
|
+ if (!port)
|
|
+ return;
|
|
+
|
|
if (vd->ecp.tx.frameout) {
|
|
free(vd->ecp.tx.frameout);
|
|
vd->ecp.tx.frameout = NULL;
|
|
@@ -246,7 +251,6 @@ void ecp_tx_Initialize(struct vdp_data *vd)
|
|
vd->ecp.ackTimer = ECP_ACK_TIMER_STOPPED;
|
|
vd->ecp.retries = 0;
|
|
|
|
- struct port *port = port_find_by_name(vd->ifname);
|
|
l2_packet_get_port_state(vd->ecp.l2, (u8 *)&(port->portEnabled));
|
|
|
|
return;
|
|
diff --git a/lldp_vdp.c b/lldp_vdp.c
|
|
index 5a8ab55..2875bf5 100644
|
|
--- a/lldp_vdp.c
|
|
+++ b/lldp_vdp.c
|
|
@@ -1349,6 +1349,10 @@ void vdp_ifup(char *ifname)
|
|
struct port *port;
|
|
struct vsi_profile *p;
|
|
|
|
+ /* VDP does not support bonded devices */
|
|
+ if (is_bond(ifname))
|
|
+ return;
|
|
+
|
|
LLDPAD_DBG("%s(%i): starting VDP for if %s !\n", __func__, __LINE__, ifname);
|
|
|
|
vd = vdp_data(ifname);
|
|
--
|
|
1.7.6
|
|
|