* Re: [PATCH] net/bonding: bonding: Adjust coding style for bond_3ad files.
From: Rafael Aquini @ 2011-05-06 1:05 UTC (permalink / raw)
To: kernel-janitors
Cc: Joe Perches, Jay Vosburgh, Andy Gospodarek, netdev, shemminger
In-Reply-To: <1304549184.1788.128.camel@Joe-Laptop>
Howdy,
Thanks to Joe Perches & Stephen Hemminger for
taking time and proving valuable feedback.
Resubmitting the proposed patch.
---
drivers/net/bonding/bond_3ad.c | 836 +++++++++++++++++++++++-----------------
drivers/net/bonding/bond_3ad.h | 195 +++++-----
2 files changed, 579 insertions(+), 452 deletions(-)
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index 31912f1..fdb07be 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -34,14 +34,14 @@
#include "bonding.h"
#include "bond_3ad.h"
-// General definitions
+/* General definitions */
#define AD_SHORT_TIMEOUT 1
#define AD_LONG_TIMEOUT 0
#define AD_STANDBY 0x2
#define AD_MAX_TX_IN_SECOND 3
#define AD_COLLECTOR_MAX_DELAY 0
-// Timer definitions(43.4.4 in the 802.3ad standard)
+/* Timer definitions (43.4.4 in the 802.3ad standard) */
#define AD_FAST_PERIODIC_TIME 1
#define AD_SLOW_PERIODIC_TIME 30
#define AD_SHORT_TIMEOUT_TIME (3*AD_FAST_PERIODIC_TIME)
@@ -49,7 +49,7 @@
#define AD_CHURN_DETECTION_TIME 60
#define AD_AGGREGATE_WAIT_TIME 2
-// Port state definitions(43.4.2.2 in the 802.3ad standard)
+/* Port state definitions (43.4.2.2 in the 802.3ad standard) */
[raquini@x61 linux-2.6 (bond-patch %)]$ git format-patch --no-renames -k --stdout 5895198c56d131cc696556a45f7ff0ea99ac297b > ../../patches/linux-2.6-net-bonding-Adjust-codingstyle-for-bond_3ad-files.patch
[raquini@x61 linux-2.6 (bond-patch %)]$ vim ../../patches/linux-2.6-net-bonding-Adjust-codingstyle-for-bond_3ad-files.patch
[raquini@x61 linux-2.6 (bond-patch %)]$ cat ../../patches/linux-2.6-net-bonding-Adjust-codingstyle-for-bond_3ad-files.patch
>From 0784cebed3e82f2448492a17688b400c91408ecf Mon Sep 17 00:00:00 2001
From: Rafael Aquini <aquini@redhat.com>
Date: Thu, 5 May 2011 21:47:00 -0300
Subject: [net] bonding: Adjust coding style for bond_3ad files.
---
drivers/net/bonding/bond_3ad.c | 836 +++++++++++++++++++++++-----------------
drivers/net/bonding/bond_3ad.h | 195 +++++-----
2 files changed, 579 insertions(+), 452 deletions(-)
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index 31912f1..fdb07be 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -34,14 +34,14 @@
#include "bonding.h"
#include "bond_3ad.h"
-// General definitions
+/* General definitions */
#define AD_SHORT_TIMEOUT 1
#define AD_LONG_TIMEOUT 0
#define AD_STANDBY 0x2
#define AD_MAX_TX_IN_SECOND 3
#define AD_COLLECTOR_MAX_DELAY 0
-// Timer definitions(43.4.4 in the 802.3ad standard)
+/* Timer definitions (43.4.4 in the 802.3ad standard) */
#define AD_FAST_PERIODIC_TIME 1
#define AD_SLOW_PERIODIC_TIME 30
#define AD_SHORT_TIMEOUT_TIME (3*AD_FAST_PERIODIC_TIME)
@@ -49,7 +49,7 @@
#define AD_CHURN_DETECTION_TIME 60
#define AD_AGGREGATE_WAIT_TIME 2
-// Port state definitions(43.4.2.2 in the 802.3ad standard)
+/* Port state definitions (43.4.2.2 in the 802.3ad standard) */
#define AD_STATE_LACP_ACTIVITY 0x1
#define AD_STATE_LACP_TIMEOUT 0x2
#define AD_STATE_AGGREGATION 0x4
@@ -59,7 +59,9 @@
#define AD_STATE_DEFAULTED 0x40
#define AD_STATE_EXPIRED 0x80
-// Port Variables definitions used by the State Machines(43.4.7 in the 802.3ad standard)
+/* Port Variables definitions used by the State Machines
+ * (43.4.7 in the 802.3ad standard)
+ */
#define AD_PORT_BEGIN 0x1
#define AD_PORT_LACP_ENABLED 0x2
#define AD_PORT_ACTOR_CHURN 0x4
@@ -71,27 +73,23 @@
#define AD_PORT_SELECTED 0x100
#define AD_PORT_MOVED 0x200
-// Port Key definitions
-// key is determined according to the link speed, duplex and
-// user key(which is yet not supported)
-// ------------------------------------------------------------
-// Port key : | User key | Speed |Duplex|
-// ------------------------------------------------------------
-// 16 6 1 0
+/* Port Key definitions:
+ * key is determined according to the link speed, duplex and
+ * user key (which is yet not supported)
+ * ------------------------------------------------------------
+ * Port key: | User key | Speed |Duplex|
+ * ------------------------------------------------------------
+ * 16 6 1 0
+ */
#define AD_DUPLEX_KEY_BITS 0x1
#define AD_SPEED_KEY_BITS 0x3E
#define AD_USER_KEY_BITS 0xFFC0
-//dalloun
#define AD_LINK_SPEED_BITMASK_1MBPS 0x1
#define AD_LINK_SPEED_BITMASK_10MBPS 0x2
#define AD_LINK_SPEED_BITMASK_100MBPS 0x4
#define AD_LINK_SPEED_BITMASK_1000MBPS 0x8
#define AD_LINK_SPEED_BITMASK_10000MBPS 0x10
-//endalloun
-
-// compare MAC addresses
-#define MAC_ADDRESS_COMPARE(A, B) memcmp(A, B, ETH_ALEN)
static struct mac_addr null_mac_addr = { { 0, 0, 0, 0, 0, 0 } };
static u16 ad_ticks_per_sec;
@@ -99,7 +97,7 @@ static const int ad_delta_in_ticks = (AD_TIMER_INTERVAL * HZ) / 1000;
static const u8 lacpdu_mcast_addr[ETH_ALEN] = MULTICAST_LACPDU_ADDR;
-// ================= main 802.3ad protocol functions ==================
+/* ================= main 802.3ad protocol functions ================== */
static int ad_lacpdu_send(struct port *port);
static int ad_marker_send(struct port *port, struct bond_marker *marker);
static void ad_mux_machine(struct port *port);
@@ -113,14 +111,12 @@ static void ad_initialize_agg(struct aggregator *aggregator);
static void ad_initialize_port(struct port *port, int lacp_fast);
static void ad_enable_collecting_distributing(struct port *port);
static void ad_disable_collecting_distributing(struct port *port);
-static void ad_marker_info_received(struct bond_marker *marker_info, struct port *port);
-static void ad_marker_response_received(struct bond_marker *marker, struct port *port);
-
-
-/////////////////////////////////////////////////////////////////////////////////
-// ================= api to bonding and kernel code ==================
-/////////////////////////////////////////////////////////////////////////////////
+static void ad_marker_info_received(struct bond_marker *marker_info,
+ struct port *port);
+static void ad_marker_response_received(struct bond_marker *marker,
+ struct port *port);
+/* ================= api to bonding and kernel code ================== */
/**
* __get_bond_by_port - get the port's bonding struct
* @port: the port we're looking at
@@ -161,7 +157,7 @@ static inline struct port *__get_next_port(struct port *port)
struct bonding *bond = __get_bond_by_port(port);
struct slave *slave = port->slave;
- // If there's no bond for this port, or this is the last slave
+ /* If there's no bond for this port, or this is the last slave */
if ((bond == NULL) || (slave->next == bond->first_slave))
return NULL;
@@ -179,7 +175,7 @@ static inline struct aggregator *__get_first_agg(struct port *port)
{
struct bonding *bond = __get_bond_by_port(port);
- // If there's no bond for this port, or bond has no slaves
+ /* If there's no bond for this port, or bond has no slaves */
if ((bond == NULL) || (bond->slave_cnt == 0))
return NULL;
@@ -198,7 +194,7 @@ static inline struct aggregator *__get_next_agg(struct aggregator *aggregator)
struct slave *slave = aggregator->slave;
struct bonding *bond = bond_get_bond_by_slave(slave);
- // If there's no bond for this aggregator, or this is the last slave
+ /* If there's no bond for this aggregator, or this is the last slave */
if ((bond == NULL) || (slave->next == bond->first_slave))
return NULL;
@@ -316,10 +312,9 @@ static u16 __get_link_speed(struct port *port)
struct slave *slave = port->slave;
u16 speed;
- /* this if covers only a special case: when the configuration starts with
- * link down, it sets the speed to 0.
- * This is done in spite of the fact that the e100 driver reports 0 to be
- * compatible with MVT in the future.*/
+ /* handling a special case:
+ * when the configuration starts with link down, it sets the speed to 0
+ */
if (slave->link != BOND_LINK_UP)
speed = 0;
else {
@@ -341,7 +336,8 @@ static u16 __get_link_speed(struct port *port)
break;
default:
- speed = 0; // unknown speed value from ethtool. shouldn't happen
+ /* unknown speed value from ethtool. shouldn't happen */
+ speed = 0;
break;
}
}
@@ -365,8 +361,9 @@ static u8 __get_duplex(struct port *port)
u8 retval;
- // handling a special case: when the configuration starts with
- // link down, it sets the duplex to 0.
+ /* handling a special case:
+ * when the configuration starts with link down, it sets the duplex to 0
+ */
if (slave->link != BOND_LINK_UP)
retval = 0x0;
else {
@@ -394,12 +391,10 @@ static u8 __get_duplex(struct port *port)
*/
static inline void __initialize_port_locks(struct port *port)
{
- // make sure it isn't called twice
+ /* make sure it isn't called twice */
spin_lock_init(&(SLAVE_AD_INFO(port->slave).state_machine_lock));
}
-//conversions
-
/**
* __ad_timer_to_ticks - convert a given timer type to AD module ticks
* @timer_type: which timer to operate
@@ -411,36 +406,32 @@ static inline void __initialize_port_locks(struct port *port)
*/
static u16 __ad_timer_to_ticks(u16 timer_type, u16 par)
{
- u16 retval = 0; /* to silence the compiler */
+ u16 retval = 0;
switch (timer_type) {
- case AD_CURRENT_WHILE_TIMER: // for rx machine usage
+ case AD_CURRENT_WHILE_TIMER: /* for rx machine usage */
if (par)
- retval = (AD_SHORT_TIMEOUT_TIME*ad_ticks_per_sec); // short timeout
+ retval = (AD_SHORT_TIMEOUT_TIME*ad_ticks_per_sec);
else
- retval = (AD_LONG_TIMEOUT_TIME*ad_ticks_per_sec); // long timeout
+ retval = (AD_LONG_TIMEOUT_TIME*ad_ticks_per_sec);
break;
- case AD_ACTOR_CHURN_TIMER: // for local churn machine
+ case AD_ACTOR_CHURN_TIMER: /* for local churn machine */
retval = (AD_CHURN_DETECTION_TIME*ad_ticks_per_sec);
break;
- case AD_PERIODIC_TIMER: // for periodic machine
- retval = (par*ad_ticks_per_sec); // long timeout
+ case AD_PERIODIC_TIMER: /* for periodic machine */
+ retval = (par*ad_ticks_per_sec);
break;
- case AD_PARTNER_CHURN_TIMER: // for remote churn machine
+ case AD_PARTNER_CHURN_TIMER: /* for remote churn machine */
retval = (AD_CHURN_DETECTION_TIME*ad_ticks_per_sec);
break;
- case AD_WAIT_WHILE_TIMER: // for selection machine
+ case AD_WAIT_WHILE_TIMER: /* for selection machine */
retval = (AD_AGGREGATE_WAIT_TIME*ad_ticks_per_sec);
break;
}
return retval;
}
-
-/////////////////////////////////////////////////////////////////////////////////
-// ================= ad_rx_machine helper functions ==================
-/////////////////////////////////////////////////////////////////////////////////
-
+/* ================= ad_rx_machine helper functions ================== */
/**
* __choose_matched - update a port's matched variable from a received lacpdu
* @lacpdu: the lacpdu we've received
@@ -466,17 +457,17 @@ static u16 __ad_timer_to_ticks(u16 timer_type, u16 par)
*/
static void __choose_matched(struct lacpdu *lacpdu, struct port *port)
{
- // check if all parameters are alike
+ /* check if all parameters are alike */
if (((ntohs(lacpdu->partner_port) == port->actor_port_number) &&
(ntohs(lacpdu->partner_port_priority) == port->actor_port_priority) &&
- !MAC_ADDRESS_COMPARE(&(lacpdu->partner_system), &(port->actor_system)) &&
+ !compare_ether_addr((const u8 *)&(lacpdu->partner_system), (const u8 *)&(port->actor_system)) &&
(ntohs(lacpdu->partner_system_priority) == port->actor_system_priority) &&
(ntohs(lacpdu->partner_key) == port->actor_oper_port_key) &&
((lacpdu->partner_state & AD_STATE_AGGREGATION) == (port->actor_oper_port_state & AD_STATE_AGGREGATION))) ||
- // or this is individual link(aggregation == FALSE)
+ /* or this is individual link(aggregation == FALSE) */
((lacpdu->actor_state & AD_STATE_AGGREGATION) == 0)
) {
- // update the state machine Matched variable
+ /* update the state machine Matched variable */
port->sm_vars |= AD_PORT_MATCHED;
} else {
port->sm_vars &= ~AD_PORT_MATCHED;
@@ -498,7 +489,7 @@ static void __record_pdu(struct lacpdu *lacpdu, struct port *port)
struct port_params *partner = &port->partner_oper;
__choose_matched(lacpdu, port);
- // record the new parameter values for the partner operational
+ /* record the new values for the operational partner */
partner->port_number = ntohs(lacpdu->actor_port);
partner->port_priority = ntohs(lacpdu->actor_port_priority);
partner->system = lacpdu->actor_system;
@@ -506,12 +497,14 @@ static void __record_pdu(struct lacpdu *lacpdu, struct port *port)
partner->key = ntohs(lacpdu->actor_key);
partner->port_state = lacpdu->actor_state;
- // set actor_oper_port_state.defaulted to FALSE
+ /* set actor_oper_port_state.defaulted to FALSE */
port->actor_oper_port_state &= ~AD_STATE_DEFAULTED;
- // set the partner sync. to on if the partner is sync. and the port is matched
- if ((port->sm_vars & AD_PORT_MATCHED)
- && (lacpdu->actor_state & AD_STATE_SYNCHRONIZATION))
+ /* set the partner sync to on if the partner is sync
+ * and the port is matched.
+ */
+ if ((port->sm_vars & AD_PORT_MATCHED) &&
+ (lacpdu->actor_state & AD_STATE_SYNCHRONIZATION))
partner->port_state |= AD_STATE_SYNCHRONIZATION;
else
partner->port_state &= ~AD_STATE_SYNCHRONIZATION;
@@ -529,11 +522,8 @@ static void __record_pdu(struct lacpdu *lacpdu, struct port *port)
static void __record_default(struct port *port)
{
if (port) {
- // record the partner admin parameters
memcpy(&port->partner_oper, &port->partner_admin,
sizeof(struct port_params));
-
- // set actor_oper_port_state.defaulted to true
port->actor_oper_port_state |= AD_STATE_DEFAULTED;
}
}
@@ -556,14 +546,14 @@ static void __update_selected(struct lacpdu *lacpdu, struct port *port)
if (lacpdu && port) {
const struct port_params *partner = &port->partner_oper;
- // check if any parameter is different
+ /* check if any parameter is different */
if (ntohs(lacpdu->actor_port) != partner->port_number ||
ntohs(lacpdu->actor_port_priority) != partner->port_priority ||
- MAC_ADDRESS_COMPARE(&lacpdu->actor_system, &partner->system) ||
+ compare_ether_addr((const u8 *)&lacpdu->actor_system, (const u8 *)&partner->system) ||
ntohs(lacpdu->actor_system_priority) != partner->system_priority ||
ntohs(lacpdu->actor_key) != partner->key ||
(lacpdu->actor_state & AD_STATE_AGGREGATION) != (partner->port_state & AD_STATE_AGGREGATION)) {
- // update the state machine Selected variable
+ /* update the state machine Selected variable */
port->sm_vars &= ~AD_PORT_SELECTED;
}
}
@@ -587,15 +577,15 @@ static void __update_default_selected(struct port *port)
const struct port_params *admin = &port->partner_admin;
const struct port_params *oper = &port->partner_oper;
- // check if any parameter is different
if (admin->port_number != oper->port_number ||
admin->port_priority != oper->port_priority ||
- MAC_ADDRESS_COMPARE(&admin->system, &oper->system) ||
+ compare_ether_addr((const u8 *)&admin->system,
+ (const u8 *)&oper->system) ||
admin->system_priority != oper->system_priority ||
admin->key != oper->key ||
(admin->port_state & AD_STATE_AGGREGATION)
!= (oper->port_state & AD_STATE_AGGREGATION)) {
- // update the state machine Selected variable
+ /* update the state machine Selected variable */
port->sm_vars &= ~AD_PORT_SELECTED;
}
}
@@ -615,12 +605,12 @@ static void __update_default_selected(struct port *port)
*/
static void __update_ntt(struct lacpdu *lacpdu, struct port *port)
{
- // validate lacpdu and port
+ /* validate lacpdu and port */
if (lacpdu && port) {
- // check if any parameter is different
+ /* check if any parameter is different */
if ((ntohs(lacpdu->partner_port) != port->actor_port_number) ||
(ntohs(lacpdu->partner_port_priority) != port->actor_port_priority) ||
- MAC_ADDRESS_COMPARE(&(lacpdu->partner_system), &(port->actor_system)) ||
+ compare_ether_addr((const u8 *)&(lacpdu->partner_system), (const u8 *)&(port->actor_system)) ||
(ntohs(lacpdu->partner_system_priority) != port->actor_system_priority) ||
(ntohs(lacpdu->partner_key) != port->actor_oper_port_key) ||
((lacpdu->partner_state & AD_STATE_LACP_ACTIVITY) != (port->actor_oper_port_state & AD_STATE_LACP_ACTIVITY)) ||
@@ -628,7 +618,7 @@ static void __update_ntt(struct lacpdu *lacpdu, struct port *port)
((lacpdu->partner_state & AD_STATE_SYNCHRONIZATION) != (port->actor_oper_port_state & AD_STATE_SYNCHRONIZATION)) ||
((lacpdu->partner_state & AD_STATE_AGGREGATION) != (port->actor_oper_port_state & AD_STATE_AGGREGATION))
) {
-
+ /* set port ntt */
port->ntt = true;
}
}
@@ -644,9 +634,7 @@ static void __update_ntt(struct lacpdu *lacpdu, struct port *port)
*/
static void __attach_bond_to_agg(struct port *port)
{
- port = NULL; /* just to satisfy the compiler */
- // This function does nothing since the parser/multiplexer of the receive
- // and the parser/multiplexer of the aggregator are already combined
+ port = NULL;
}
/**
@@ -659,9 +647,7 @@ static void __attach_bond_to_agg(struct port *port)
*/
static void __detach_bond_from_agg(struct port *port)
{
- port = NULL; /* just to satisfy the compiler */
- // This function does nothing sience the parser/multiplexer of the receive
- // and the parser/multiplexer of the aggregator are already combined
+ port = NULL;
}
/**
@@ -675,7 +661,9 @@ static int __agg_ports_are_ready(struct aggregator *aggregator)
int retval = 1;
if (aggregator) {
- // scan all ports in this aggregator to verfy if they are all ready
+ /* scan all ports in this aggregator
+ * to verfy if they are all ready.
+ */
for (port = aggregator->lag_ports;
port;
port = port->next_port_in_aggregator) {
@@ -737,7 +725,7 @@ static u32 __get_agg_bandwidth(struct aggregator *aggregator)
bandwidth = aggregator->num_of_ports * 10000;
break;
default:
- bandwidth = 0; /*to silence the compiler ....*/
+ bandwidth = 0;
}
}
return bandwidth;
@@ -809,10 +797,7 @@ static inline void __update_lacpdu_from_port(struct port *port)
*/
}
-//////////////////////////////////////////////////////////////////////////////////////
-// ================= main 802.3ad protocol code ======================================
-//////////////////////////////////////////////////////////////////////////////////////
-
+/* ================= main 802.3ad protocol code ================= */
/**
* ad_lacpdu_send - send out a lacpdu packet on a given port
* @port: the port we're looking at
@@ -841,11 +826,12 @@ static int ad_lacpdu_send(struct port *port)
memcpy(lacpdu_header->hdr.h_dest, lacpdu_mcast_addr, ETH_ALEN);
/* Note: source address is set to be the member's PERMANENT address,
- because we use it to identify loopback lacpdus in receive. */
+ * because we use it to identify loopback lacpdus in receive.
+ */
memcpy(lacpdu_header->hdr.h_source, slave->perm_hwaddr, ETH_ALEN);
lacpdu_header->hdr.h_proto = PKT_TYPE_LACPDU;
- lacpdu_header->lacpdu = port->lacpdu; // struct copy
+ lacpdu_header->lacpdu = port->lacpdu;
dev_queue_xmit(skb);
@@ -886,7 +872,7 @@ static int ad_marker_send(struct port *port, struct bond_marker *marker)
memcpy(marker_header->hdr.h_source, slave->perm_hwaddr, ETH_ALEN);
marker_header->hdr.h_proto = PKT_TYPE_LACPDU;
- marker_header->marker = *marker; // struct copy
+ marker_header->marker = *marker;
dev_queue_xmit(skb);
@@ -902,80 +888,101 @@ static void ad_mux_machine(struct port *port)
{
mux_states_t last_state;
- // keep current State Machine state to compare later if it was changed
last_state = port->sm_mux_state;
if (port->sm_vars & AD_PORT_BEGIN) {
- port->sm_mux_state = AD_MUX_DETACHED; // next state
+ port->sm_mux_state = AD_MUX_DETACHED;
} else {
switch (port->sm_mux_state) {
case AD_MUX_DETACHED:
- if ((port->sm_vars & AD_PORT_SELECTED)
- || (port->sm_vars & AD_PORT_STANDBY))
+ if ((port->sm_vars & AD_PORT_SELECTED) ||
+ (port->sm_vars & AD_PORT_STANDBY))
/* if SELECTED or STANDBY */
- port->sm_mux_state = AD_MUX_WAITING; // next state
+ port->sm_mux_state = AD_MUX_WAITING;
break;
case AD_MUX_WAITING:
- // if SELECTED == FALSE return to DETACH state
- if (!(port->sm_vars & AD_PORT_SELECTED)) { // if UNSELECTED
+ /* if SELECTED == FALSE return to DETACH state */
+ if (!(port->sm_vars & AD_PORT_SELECTED)) {
port->sm_vars &= ~AD_PORT_READY_N;
- // in order to withhold the Selection Logic to check all ports READY_N value
- // every callback cycle to update ready variable, we check READY_N and update READY here
- __set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator));
- port->sm_mux_state = AD_MUX_DETACHED; // next state
+ /* in order to withhold the Selection Logic
+ * to check all ports READY_N value at every
+ * callback cycle to update ready variable,
+ * we check READY_N and update READY here
+ */
+ __set_agg_ports_ready(port->aggregator,
+ __agg_ports_are_ready(port->aggregator));
+ port->sm_mux_state = AD_MUX_DETACHED;
break;
}
- // check if the wait_while_timer expired
- if (port->sm_mux_timer_counter
- && !(--port->sm_mux_timer_counter))
+ /* check if the wait_while_timer expired */
+ if (port->sm_mux_timer_counter &&
+ !(--port->sm_mux_timer_counter))
port->sm_vars |= AD_PORT_READY_N;
- // in order to withhold the selection logic to check all ports READY_N value
- // every callback cycle to update ready variable, we check READY_N and update READY here
- __set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator));
-
- // if the wait_while_timer expired, and the port is in READY state, move to ATTACHED state
- if ((port->sm_vars & AD_PORT_READY)
- && !port->sm_mux_timer_counter)
- port->sm_mux_state = AD_MUX_ATTACHED; // next state
+ /* in order to withhold the selection logic
+ * to check all ports READY_N value at every
+ * callback cycle to update ready variable,
+ * we check READY_N and update READY here
+ */
+ __set_agg_ports_ready(port->aggregator,
+ __agg_ports_are_ready(port->aggregator));
+
+ /* if the wait_while_timer expired, and the port
+ * is in READY state, move to ATTACHED state
+ */
+ if ((port->sm_vars & AD_PORT_READY) &&
+ !port->sm_mux_timer_counter)
+ port->sm_mux_state = AD_MUX_ATTACHED;
break;
case AD_MUX_ATTACHED:
- // check also if agg_select_timer expired(so the edable port will take place only after this timer)
- if ((port->sm_vars & AD_PORT_SELECTED) && (port->partner_oper.port_state & AD_STATE_SYNCHRONIZATION) && !__check_agg_selection_timer(port)) {
- port->sm_mux_state = AD_MUX_COLLECTING_DISTRIBUTING;// next state
- } else if (!(port->sm_vars & AD_PORT_SELECTED) || (port->sm_vars & AD_PORT_STANDBY)) { // if UNSELECTED or STANDBY
+ /* check also if agg_select_timer expired
+ * so the enable port will take place
+ * only after this timer
+ */
+ if ((port->sm_vars & AD_PORT_SELECTED) &&
+ (port->partner_oper.port_state &
+ AD_STATE_SYNCHRONIZATION) &&
+ !__check_agg_selection_timer(port)) {
+ port->sm_mux_state =
+ AD_MUX_COLLECTING_DISTRIBUTING;
+ } else if (!(port->sm_vars & AD_PORT_SELECTED) ||
+ (port->sm_vars & AD_PORT_STANDBY)) {
+ /* if UNSELECTED or STANDBY */
port->sm_vars &= ~AD_PORT_READY_N;
- // in order to withhold the selection logic to check all ports READY_N value
- // every callback cycle to update ready variable, we check READY_N and update READY here
- __set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator));
- port->sm_mux_state = AD_MUX_DETACHED;// next state
+ /* in order to withhold the Selection Logic
+ * to check all ports READY_N value at every
+ * callback cycle to update ready variable,
+ * we check READY_N and update READY here
+ */
+ __set_agg_ports_ready(port->aggregator,
+ __agg_ports_are_ready(port->aggregator));
+ port->sm_mux_state = AD_MUX_DETACHED;
}
break;
case AD_MUX_COLLECTING_DISTRIBUTING:
- if (!(port->sm_vars & AD_PORT_SELECTED) || (port->sm_vars & AD_PORT_STANDBY) ||
- !(port->partner_oper.port_state & AD_STATE_SYNCHRONIZATION)
- ) {
- port->sm_mux_state = AD_MUX_ATTACHED;// next state
-
+ if (!(port->sm_vars & AD_PORT_SELECTED) ||
+ (port->sm_vars & AD_PORT_STANDBY) ||
+ !(port->partner_oper.port_state &
+ AD_STATE_SYNCHRONIZATION)) {
+ port->sm_mux_state = AD_MUX_ATTACHED;
} else {
- // if port state hasn't changed make
- // sure that a collecting distributing
- // port in an active aggregator is enabled
+ /* if port state hasn't changed make
+ * sure that a collecting distributing
+ * port in an active aggregator is enabled
+ */
if (port->aggregator &&
port->aggregator->is_active &&
- !__port_is_enabled(port)) {
-
+ !__port_is_enabled(port))
__enable_port(port);
- }
}
break;
- default: //to silence the compiler
+ default:
break;
}
}
- // check if the state machine was changed
+ /* check if the state machine was changed */
if (port->sm_mux_state != last_state) {
pr_debug("Mux Machine: Port=%d, Last State=%d, Curr State=%d\n",
port->actor_port_number, last_state,
@@ -983,14 +990,16 @@ static void ad_mux_machine(struct port *port)
switch (port->sm_mux_state) {
case AD_MUX_DETACHED:
__detach_bond_from_agg(port);
- port->actor_oper_port_state &= ~AD_STATE_SYNCHRONIZATION;
+ port->actor_oper_port_state &=
+ ~AD_STATE_SYNCHRONIZATION;
ad_disable_collecting_distributing(port);
port->actor_oper_port_state &= ~AD_STATE_COLLECTING;
port->actor_oper_port_state &= ~AD_STATE_DISTRIBUTING;
port->ntt = true;
break;
case AD_MUX_WAITING:
- port->sm_mux_timer_counter = __ad_timer_to_ticks(AD_WAIT_WHILE_TIMER, 0);
+ port->sm_mux_timer_counter =
+ __ad_timer_to_ticks(AD_WAIT_WHILE_TIMER, 0);
break;
case AD_MUX_ATTACHED:
__attach_bond_to_agg(port);
@@ -1006,7 +1015,7 @@ static void ad_mux_machine(struct port *port)
ad_enable_collecting_distributing(port);
port->ntt = true;
break;
- default: //to silence the compiler
+ default:
break;
}
}
@@ -1025,59 +1034,62 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
{
rx_states_t last_state;
- // keep current State Machine state to compare later if it was changed
last_state = port->sm_rx_state;
- // check if state machine should change state
- // first, check if port was reinitialized
+ /* check if state machine should change state
+ * first, check if port was reinitialized
+ */
if (port->sm_vars & AD_PORT_BEGIN)
/* next state */
port->sm_rx_state = AD_RX_INITIALIZE;
- // check if port is not enabled
- else if (!(port->sm_vars & AD_PORT_BEGIN)
- && !port->is_enabled && !(port->sm_vars & AD_PORT_MOVED))
+ /* check if port is not enabled */
+ else if (!(port->sm_vars & AD_PORT_BEGIN) &&
+ !port->is_enabled && !(port->sm_vars & AD_PORT_MOVED))
/* next state */
port->sm_rx_state = AD_RX_PORT_DISABLED;
- // check if new lacpdu arrived
- else if (lacpdu && ((port->sm_rx_state == AD_RX_EXPIRED) || (port->sm_rx_state == AD_RX_DEFAULTED) || (port->sm_rx_state == AD_RX_CURRENT))) {
- port->sm_rx_timer_counter = 0; // zero timer
+ /* check if new lacpdu arrived */
+ else if (lacpdu && ((port->sm_rx_state == AD_RX_EXPIRED) ||
+ (port->sm_rx_state == AD_RX_DEFAULTED) ||
+ (port->sm_rx_state == AD_RX_CURRENT))) {
+ port->sm_rx_timer_counter = 0; /* zero timer */
port->sm_rx_state = AD_RX_CURRENT;
} else {
- // if timer is on, and if it is expired
- if (port->sm_rx_timer_counter && !(--port->sm_rx_timer_counter)) {
+ /* if timer is on, and if it is expired */
+ if (port->sm_rx_timer_counter &&
+ !(--port->sm_rx_timer_counter)) {
switch (port->sm_rx_state) {
case AD_RX_EXPIRED:
- port->sm_rx_state = AD_RX_DEFAULTED; // next state
+ port->sm_rx_state = AD_RX_DEFAULTED;
break;
case AD_RX_CURRENT:
- port->sm_rx_state = AD_RX_EXPIRED; // next state
+ port->sm_rx_state = AD_RX_EXPIRED;
break;
- default: //to silence the compiler
+ default:
break;
}
} else {
- // if no lacpdu arrived and no timer is on
+ /* if no lacpdu arrived and no timer is on */
switch (port->sm_rx_state) {
case AD_RX_PORT_DISABLED:
if (port->sm_vars & AD_PORT_MOVED)
- port->sm_rx_state = AD_RX_INITIALIZE; // next state
- else if (port->is_enabled
- && (port->sm_vars
- & AD_PORT_LACP_ENABLED))
- port->sm_rx_state = AD_RX_EXPIRED; // next state
- else if (port->is_enabled
- && ((port->sm_vars
- & AD_PORT_LACP_ENABLED) == 0))
- port->sm_rx_state = AD_RX_LACP_DISABLED; // next state
+ port->sm_rx_state = AD_RX_INITIALIZE;
+ else if (port->is_enabled &&
+ (port->sm_vars &
+ AD_PORT_LACP_ENABLED))
+ port->sm_rx_state = AD_RX_EXPIRED;
+ else if (port->is_enabled &&
+ ((port->sm_vars &
+ AD_PORT_LACP_ENABLED) == 0))
+ port->sm_rx_state = AD_RX_LACP_DISABLED;
break;
- default: //to silence the compiler
+ default:
break;
}
}
}
- // check if the State machine was changed or new lacpdu arrived
+ /* check if the State machine was changed or new lacpdu arrived */
if ((port->sm_rx_state != last_state) || (lacpdu)) {
pr_debug("Rx Machine: Port=%d, Last State=%d, Curr State=%d\n",
port->actor_port_number, last_state,
@@ -1092,7 +1104,7 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
__record_default(port);
port->actor_oper_port_state &= ~AD_STATE_EXPIRED;
port->sm_vars &= ~AD_PORT_MOVED;
- port->sm_rx_state = AD_RX_PORT_DISABLED; // next state
+ port->sm_rx_state = AD_RX_PORT_DISABLED;
/*- Fall Through -*/
@@ -1107,14 +1119,20 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
port->actor_oper_port_state &= ~AD_STATE_EXPIRED;
break;
case AD_RX_EXPIRED:
- //Reset of the Synchronization flag. (Standard 43.4.12)
- //This reset cause to disable this port in the COLLECTING_DISTRIBUTING state of the
- //mux machine in case of EXPIRED even if LINK_DOWN didn't arrive for the port.
- port->partner_oper.port_state &= ~AD_STATE_SYNCHRONIZATION;
+ /* Reset of the Synchronization flag. (Standard 43.4.12)
+ * This reset cause to disable this port in the
+ * COLLECTING_DISTRIBUTING state of the mux machine
+ * in case of EXPIRED even if LINK_DOWN didn't arrive
+ * for the port.
+ */
+ port->partner_oper.port_state &=
+ ~AD_STATE_SYNCHRONIZATION;
port->sm_vars &= ~AD_PORT_MATCHED;
port->partner_oper.port_state |=
AD_STATE_LACP_ACTIVITY;
- port->sm_rx_timer_counter = __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER, (u16)(AD_SHORT_TIMEOUT));
+ port->sm_rx_timer_counter =
+ __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER,
+ (u16)(AD_SHORT_TIMEOUT));
port->actor_oper_port_state |= AD_STATE_EXPIRED;
break;
case AD_RX_DEFAULTED:
@@ -1124,12 +1142,13 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
port->actor_oper_port_state &= ~AD_STATE_EXPIRED;
break;
case AD_RX_CURRENT:
- // detect loopback situation
- if (!MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->actor_system))) {
- // INFO_RECEIVED_LOOPBACK_FRAMES
+ /* detect loopback situation */
+ if (!compare_ether_addr((const u8 *)&(lacpdu->actor_system), (const u8 *)&(port->actor_system))) {
+ /* INFO_RECEIVED_LOOPBACK_FRAMES */
pr_err("%s: An illegal loopback occurred on adapter (%s).\n"
"Check the configuration to verify that all adapters are connected to 802.3ad compliant switch ports\n",
- port->slave->dev->master->name, port->slave->dev->name);
+ port->slave->dev->master->name,
+ port->slave->dev->name);
return;
}
__update_selected(lacpdu, port);
@@ -1137,15 +1156,19 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
__record_pdu(lacpdu, port);
port->sm_rx_timer_counter = __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER, (u16)(port->actor_oper_port_state & AD_STATE_LACP_TIMEOUT));
port->actor_oper_port_state &= ~AD_STATE_EXPIRED;
- // verify that if the aggregator is enabled, the port is enabled too.
- //(because if the link goes down for a short time, the 802.3ad will not
- // catch it, and the port will continue to be disabled)
+
+ /* verify that if the aggregator is enabled,
+ * so the port is enabled too.
+ * because if the link goes down for a short time,
+ * the 802.3ad will not catch it,
+ * and the port will continue to be disabled
+ */
if (port->aggregator
&& port->aggregator->is_active
&& !__port_is_enabled(port))
__enable_port(port);
break;
- default: //to silence the compiler
+ default:
break;
}
}
@@ -1158,9 +1181,11 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
*/
static void ad_tx_machine(struct port *port)
{
- // check if tx timer expired, to verify that we do not send more than 3 packets per second
+ /* check if tx timer has expired,
+ * to verify that we do not send more than 3 packets per second
+ */
if (port->sm_tx_timer_counter && !(--port->sm_tx_timer_counter)) {
- // check if there is something to send
+ /* check if there is something to send */
if (port->ntt && (port->sm_vars & AD_PORT_LACP_ENABLED)) {
__update_lacpdu_from_port(port);
@@ -1168,14 +1193,17 @@ static void ad_tx_machine(struct port *port)
pr_debug("Sent LACPDU on port %d\n",
port->actor_port_number);
- /* mark ntt as false, so it will not be sent again until
- demanded */
+ /* mark ntt as false,
+ * so it won't be sent again until demanded
+ */
port->ntt = false;
}
}
- // restart tx timer(to verify that we will not exceed AD_MAX_TX_IN_SECOND
+ /* restart tx timer
+ * to verify that we won't exceed AD_MAX_TX_IN_SECOND
+ */
port->sm_tx_timer_counter =
- ad_ticks_per_sec/AD_MAX_TX_IN_SECOND;
+ ad_ticks_per_sec/AD_MAX_TX_IN_SECOND;
}
}
@@ -1189,76 +1217,87 @@ static void ad_periodic_machine(struct port *port)
{
periodic_states_t last_state;
- // keep current state machine state to compare later if it was changed
+ /* keep current state machine state to compare later if it was changed*/
last_state = port->sm_periodic_state;
- // check if port was reinitialized
- if (((port->sm_vars & AD_PORT_BEGIN) || !(port->sm_vars & AD_PORT_LACP_ENABLED) || !port->is_enabled) ||
- (!(port->actor_oper_port_state & AD_STATE_LACP_ACTIVITY) && !(port->partner_oper.port_state & AD_STATE_LACP_ACTIVITY))
- ) {
- port->sm_periodic_state = AD_NO_PERIODIC; // next state
+ /* check if port was reinitialized */
+ if (((port->sm_vars & AD_PORT_BEGIN) ||
+ !(port->sm_vars & AD_PORT_LACP_ENABLED) ||
+ !port->is_enabled) ||
+ (!(port->actor_oper_port_state & AD_STATE_LACP_ACTIVITY) &&
+ !(port->partner_oper.port_state & AD_STATE_LACP_ACTIVITY))) {
+ port->sm_periodic_state = AD_NO_PERIODIC; /* next state */
}
- // check if state machine should change state
+ /* check if state machine should change state */
else if (port->sm_periodic_timer_counter) {
- // check if periodic state machine expired
+ /* check if periodic state machine expired */
if (!(--port->sm_periodic_timer_counter)) {
- // if expired then do tx
- port->sm_periodic_state = AD_PERIODIC_TX; // next state
+ /* if expired then do tx, next state */
+ port->sm_periodic_state = AD_PERIODIC_TX;
} else {
- // If not expired, check if there is some new timeout parameter from the partner state
+ /* If not expired, check if there is some
+ * new timeout parameter from the partner state
+ */
switch (port->sm_periodic_state) {
case AD_FAST_PERIODIC:
if (!(port->partner_oper.port_state
& AD_STATE_LACP_TIMEOUT))
- port->sm_periodic_state = AD_SLOW_PERIODIC; // next state
+ port->sm_periodic_state = AD_SLOW_PERIODIC;
break;
case AD_SLOW_PERIODIC:
- if ((port->partner_oper.port_state & AD_STATE_LACP_TIMEOUT)) {
- // stop current timer
+ if ((port->partner_oper.port_state &
+ AD_STATE_LACP_TIMEOUT)) {
+ /* stop current timer */
port->sm_periodic_timer_counter = 0;
- port->sm_periodic_state = AD_PERIODIC_TX; // next state
+ port->sm_periodic_state = AD_PERIODIC_TX;
}
break;
- default: //to silence the compiler
+ default:
break;
}
}
} else {
switch (port->sm_periodic_state) {
case AD_NO_PERIODIC:
- port->sm_periodic_state = AD_FAST_PERIODIC; // next state
+ port->sm_periodic_state = AD_FAST_PERIODIC;
break;
case AD_PERIODIC_TX:
- if (!(port->partner_oper.port_state
- & AD_STATE_LACP_TIMEOUT))
- port->sm_periodic_state = AD_SLOW_PERIODIC; // next state
+ if (!(port->partner_oper.port_state &
+ AD_STATE_LACP_TIMEOUT))
+ port->sm_periodic_state = AD_SLOW_PERIODIC;
else
- port->sm_periodic_state = AD_FAST_PERIODIC; // next state
+ port->sm_periodic_state = AD_FAST_PERIODIC;
break;
- default: //to silence the compiler
+ default:
break;
}
}
- // check if the state machine was changed
+ /* check if the state machine was changed */
if (port->sm_periodic_state != last_state) {
pr_debug("Periodic Machine: Port=%d, Last State=%d, Curr State=%d\n",
port->actor_port_number, last_state,
port->sm_periodic_state);
switch (port->sm_periodic_state) {
case AD_NO_PERIODIC:
- port->sm_periodic_timer_counter = 0; // zero timer
+ port->sm_periodic_timer_counter = 0;
break;
case AD_FAST_PERIODIC:
- port->sm_periodic_timer_counter = __ad_timer_to_ticks(AD_PERIODIC_TIMER, (u16)(AD_FAST_PERIODIC_TIME))-1; // decrement 1 tick we lost in the PERIODIC_TX cycle
+ /* decrement 1 tick we lost in PERIODIC_TX cycle */
+ port->sm_periodic_timer_counter =
+ __ad_timer_to_ticks(AD_PERIODIC_TIMER,
+ (u16)(AD_FAST_PERIODIC_TIME))-1;
break;
case AD_SLOW_PERIODIC:
- port->sm_periodic_timer_counter = __ad_timer_to_ticks(AD_PERIODIC_TIMER, (u16)(AD_SLOW_PERIODIC_TIME))-1; // decrement 1 tick we lost in the PERIODIC_TX cycle
+ /* decrement 1 tick we lost in PERIODIC_TX cycle */
+ port->sm_periodic_timer_counter =
+ __ad_timer_to_ticks(AD_PERIODIC_TIMER,
+ (u16)(AD_SLOW_PERIODIC_TIME))-1;
break;
case AD_PERIODIC_TX:
port->ntt = true;
break;
- default: //to silence the compiler
+ default:
break;
}
}
@@ -1274,46 +1313,58 @@ static void ad_periodic_machine(struct port *port)
*/
static void ad_port_selection_logic(struct port *port)
{
- struct aggregator *aggregator, *free_aggregator = NULL, *temp_aggregator;
+ struct aggregator *aggregator, *temp_aggregator;
+ struct aggregator *free_aggregator = NULL;
struct port *last_port = NULL, *curr_port;
int found = 0;
- // if the port is already Selected, do nothing
+ /* if the port is already Selected, do nothing */
if (port->sm_vars & AD_PORT_SELECTED)
return;
- // if the port is connected to other aggregator, detach it
+ /* if the port is connected to other aggregator, detach it */
if (port->aggregator) {
- // detach the port from its former aggregator
+ /* detach the port from its former aggregator */
temp_aggregator = port->aggregator;
for (curr_port = temp_aggregator->lag_ports; curr_port;
last_port = curr_port,
curr_port = curr_port->next_port_in_aggregator) {
if (curr_port == port) {
temp_aggregator->num_of_ports--;
- if (!last_port) {// if it is the first port attached to the aggregator
+ if (!last_port) {
+ /* if it is the first port attached
+ to the aggregator */
temp_aggregator->lag_ports =
port->next_port_in_aggregator;
- } else {// not the first port attached to the aggregator
+ } else {
+ /* not the first port attached
+ to the aggregator */
last_port->next_port_in_aggregator =
port->next_port_in_aggregator;
}
- // clear the port's relations to this aggregator
+ /* clear the port's relations
+ to this aggregator */
port->aggregator = NULL;
port->next_port_in_aggregator = NULL;
port->actor_port_aggregator_identifier = 0;
pr_debug("Port %d left LAG %d\n",
- port->actor_port_number,
- temp_aggregator->aggregator_identifier);
- // if the aggregator is empty, clear its parameters, and set it ready to be attached
+ port->actor_port_number,
+ temp_aggregator->aggregator_identifier);
+ /* if the aggregator is empty,
+ * clear its parameters, and set it ready
+ * to be attached
+ */
if (!temp_aggregator->lag_ports)
ad_clear_agg(temp_aggregator);
break;
}
}
- if (!curr_port) { // meaning: the port was related to an aggregator but was not on the aggregator port list
+ if (!curr_port) {
+ /* meaning: the port was related to an aggregator
+ * but was not on the aggregator port list.
+ */
pr_warning("%s: Warning: Port %d (on %s) was related to aggregator %d but was not on its port list\n",
port->slave->dev->master->name,
port->actor_port_number,
@@ -1321,27 +1372,34 @@ static void ad_port_selection_logic(struct port *port)
port->aggregator->aggregator_identifier);
}
}
- // search on all aggregators for a suitable aggregator for this port
+ /* search on all aggregators for a suitable aggregator for this port */
for (aggregator = __get_first_agg(port); aggregator;
aggregator = __get_next_agg(aggregator)) {
- // keep a free aggregator for later use(if needed)
+ /* keep a free aggregator for later use (if needed) */
if (!aggregator->lag_ports) {
if (!free_aggregator)
free_aggregator = aggregator;
continue;
}
- // check if current aggregator suits us
- if (((aggregator->actor_oper_aggregator_key == port->actor_oper_port_key) && // if all parameters match AND
- !MAC_ADDRESS_COMPARE(&(aggregator->partner_system), &(port->partner_oper.system)) &&
+
+ /* check if current aggregator suits us
+ * a suitable aggregator must fit the following requirements,
+ * tested here:
+ * i. match all parameters;
+ * ii. has partner answers;
+ * iii. it is not individual
+ */
+ if (((aggregator->actor_oper_aggregator_key == port->actor_oper_port_key) &&
+ !compare_ether_addr((const u8 *)&(aggregator->partner_system), (const u8 *)&(port->partner_oper.system)) &&
(aggregator->partner_system_priority == port->partner_oper.system_priority) &&
(aggregator->partner_oper_aggregator_key == port->partner_oper.key)
) &&
- ((MAC_ADDRESS_COMPARE(&(port->partner_oper.system), &(null_mac_addr)) && // partner answers
- !aggregator->is_individual) // but is not individual OR
+ ((compare_ether_addr((const u8 *)&(port->partner_oper.system), (const u8 *)&(null_mac_addr)) &&
+ !aggregator->is_individual)
)
) {
- // attach to the founded aggregator
+ /* attach to the founded aggregator */
port->aggregator = aggregator;
port->actor_port_aggregator_identifier =
port->aggregator->aggregator_identifier;
@@ -1352,42 +1410,45 @@ static void ad_port_selection_logic(struct port *port)
port->actor_port_number,
port->aggregator->aggregator_identifier);
- // mark this port as selected
+ /* mark this port as selected */
port->sm_vars |= AD_PORT_SELECTED;
found = 1;
break;
}
}
- // the port couldn't find an aggregator - attach it to a new aggregator
+ /* the port couldn't find an aggregator, attach it to a new aggregator*/
if (!found) {
if (free_aggregator) {
- // assign port a new aggregator
+ /* assign port a new aggregator */
port->aggregator = free_aggregator;
port->actor_port_aggregator_identifier =
port->aggregator->aggregator_identifier;
- // update the new aggregator's parameters
- // if port was responsed from the end-user
+ /* update the new aggregator's parameters
+ if port was responsed from the end-user */
if (port->actor_oper_port_key & AD_DUPLEX_KEY_BITS)
/* if port is full duplex */
port->aggregator->is_individual = false;
else
port->aggregator->is_individual = true;
- port->aggregator->actor_admin_aggregator_key = port->actor_admin_port_key;
- port->aggregator->actor_oper_aggregator_key = port->actor_oper_port_key;
+ port->aggregator->actor_admin_aggregator_key =
+ port->actor_admin_port_key;
+ port->aggregator->actor_oper_aggregator_key =
+ port->actor_oper_port_key;
port->aggregator->partner_system =
- port->partner_oper.system;
+ port->partner_oper.system;
port->aggregator->partner_system_priority =
- port->partner_oper.system_priority;
- port->aggregator->partner_oper_aggregator_key = port->partner_oper.key;
+ port->partner_oper.system_priority;
+ port->aggregator->partner_oper_aggregator_key =
+ port->partner_oper.key;
port->aggregator->receive_state = 1;
port->aggregator->transmit_state = 1;
port->aggregator->lag_ports = port;
port->aggregator->num_of_ports++;
- // mark this port as selected
+ /* mark this port as selected */
port->sm_vars |= AD_PORT_SELECTED;
pr_debug("Port %d joined LAG %d(new LAG)\n",
@@ -1399,16 +1460,18 @@ static void ad_port_selection_logic(struct port *port)
port->actor_port_number, port->slave->dev->name);
}
}
- // if all aggregator's ports are READY_N == TRUE, set ready=TRUE in all aggregator's ports
- // else set ready=FALSE in all aggregator's ports
- __set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator));
+ /* if all aggregator's ports are READY_N == TRUE,
+ * set ready=TRUE in all aggregator's ports
+ * else set ready=FALSE in all aggregator's ports
+ */
+ __set_agg_ports_ready(port->aggregator,
+ __agg_ports_are_ready(port->aggregator));
aggregator = __get_first_agg(port);
ad_agg_selection_logic(aggregator);
}
-/*
- * Decide if "agg" is a better choice for the new active aggregator that
+/* Decide if "agg" is a better choice for the new active aggregator that
* the current best, according to the ad_select policy.
*/
static struct aggregator *ad_agg_selection_test(struct aggregator *best,
@@ -1533,16 +1596,15 @@ static void ad_agg_selection_logic(struct aggregator *agg)
if (best &&
__get_agg_selection_mode(best->lag_ports) == BOND_AD_STABLE) {
- /*
- * For the STABLE policy, don't replace the old active
- * aggregator if it's still active (it has an answering
- * partner) or if both the best and active don't have an
- * answering partner.
+
+ /* For the STABLE policy, don't replace the old active
+ * aggregator if it's still active (it has an answering partner)
+ * or if both the best and active don't have answering partners
*/
if (active && active->lag_ports &&
active->lag_ports->is_enabled &&
(__agg_has_partner(active) ||
- (!__agg_has_partner(active) && !__agg_has_partner(best)))) {
+ (!__agg_has_partner(active) && !__agg_has_partner(best)))) {
if (!(!active->actor_oper_aggregator_key &&
best->actor_oper_aggregator_key)) {
best = NULL;
@@ -1556,7 +1618,7 @@ static void ad_agg_selection_logic(struct aggregator *agg)
active->is_active = 1;
}
- // if there is new best aggregator, activate it
+ /* if there is new best aggregator, activate it */
if (best) {
pr_debug("best Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n",
best->aggregator_identifier, best->num_of_ports,
@@ -1577,7 +1639,7 @@ static void ad_agg_selection_logic(struct aggregator *agg)
agg->is_individual, agg->is_active);
}
- // check if any partner replys
+ /* check if any partner replys */
if (best->is_individual) {
pr_warning("%s: Warning: No 802.3ad response from the link partner for any adapters in the bond\n",
best->slave ? best->slave->dev->master->name : "NULL");
@@ -1592,7 +1654,9 @@ static void ad_agg_selection_logic(struct aggregator *agg)
best->partner_oper_aggregator_key,
best->is_individual, best->is_active);
- // disable the ports that were related to the former active_aggregator
+ /* disable the ports that were related to
+ * the former active_aggregator
+ */
if (active) {
for (port = active->lag_ports; port;
port = port->next_port_in_aggregator) {
@@ -1601,8 +1665,7 @@ static void ad_agg_selection_logic(struct aggregator *agg)
}
}
- /*
- * if the selected aggregator is of join individuals
+ /* if the selected aggregator is of join individuals
* (partner_system is NULL), enable their ports
*/
active = __get_active_agg(origin);
@@ -1701,8 +1764,10 @@ static void ad_initialize_port(struct port *port, int lacp_fast)
port->ntt = false;
port->actor_admin_port_key = 1;
port->actor_oper_port_key = 1;
- port->actor_admin_port_state = AD_STATE_AGGREGATION | AD_STATE_LACP_ACTIVITY;
- port->actor_oper_port_state = AD_STATE_AGGREGATION | AD_STATE_LACP_ACTIVITY;
+ port->actor_admin_port_state =
+ AD_STATE_AGGREGATION | AD_STATE_LACP_ACTIVITY;
+ port->actor_oper_port_state =
+ AD_STATE_AGGREGATION | AD_STATE_LACP_ACTIVITY;
if (lacp_fast)
port->actor_oper_port_state |= AD_STATE_LACP_TIMEOUT;
@@ -1711,7 +1776,7 @@ static void ad_initialize_port(struct port *port, int lacp_fast)
memcpy(&port->partner_oper, &tmpl, sizeof(tmpl));
port->is_enabled = true;
- // ****** private parameters ******
+ /* ****** private parameters ****** */
port->sm_vars = 0x3;
port->sm_rx_state = 0;
port->sm_rx_timer_counter = 0;
@@ -1753,7 +1818,9 @@ static void ad_enable_collecting_distributing(struct port *port)
*/
static void ad_disable_collecting_distributing(struct port *port)
{
- if (port->aggregator && MAC_ADDRESS_COMPARE(&(port->aggregator->partner_system), &(null_mac_addr))) {
+ if (port->aggregator &&
+ compare_ether_addr((const u8 *)&(port->aggregator->partner_system),
+ (const u8 *)&(null_mac_addr))) {
pr_debug("Disabling port %d(LAG %d)\n",
port->actor_port_number,
port->aggregator->aggregator_identifier);
@@ -1775,27 +1842,28 @@ static void ad_marker_info_send(struct port *port)
struct bond_marker marker;
u16 index;
- // fill the marker PDU with the appropriate values
+ /* fill the marker PDU with the appropriate values */
marker.subtype = 0x02;
marker.version_number = 0x01;
marker.tlv_type = AD_MARKER_INFORMATION_SUBTYPE;
marker.marker_length = 0x16;
- // convert requester_port to Big Endian
- marker.requester_port = (((port->actor_port_number & 0xFF) << 8) |((u16)(port->actor_port_number & 0xFF00) >> 8));
+ /* convert requester_port to Big Endian */
+ marker.requester_port = (((port->actor_port_number & 0xFF) << 8) |
+ ((u16)(port->actor_port_number & 0xFF00) >> 8));
marker.requester_system = port->actor_system;
- // convert requester_port(u32) to Big Endian
+ /* convert requester_port(u32) to Big Endian */
marker.requester_transaction_id =
- (((++port->transaction_id & 0xFF) << 24)
- | ((port->transaction_id & 0xFF00) << 8)
- | ((port->transaction_id & 0xFF0000) >> 8)
- | ((port->transaction_id & 0xFF000000) >> 24));
+ (((++port->transaction_id & 0xFF) << 24) |
+ ((port->transaction_id & 0xFF00) << 8) |
+ ((port->transaction_id & 0xFF0000) >> 8) |
+ ((port->transaction_id & 0xFF000000) >> 24));
marker.pad = 0;
marker.tlv_type_terminator = 0x00;
marker.terminator_length = 0x00;
for (index = 0; index < 90; index++)
marker.reserved_90[index] = 0;
- // send the marker information
+ /* send the marker information */
if (ad_marker_send(port, &marker) >= 0) {
pr_debug("Sent Marker Information on port %d\n",
port->actor_port_number);
@@ -1814,12 +1882,13 @@ static void ad_marker_info_received(struct bond_marker *marker_info,
{
struct bond_marker marker;
- // copy the received marker data to the response marker
- //marker = *marker_info;
+ /* copy the received marker data to the response marker
+ * marker = *marker_info;
+ */
memcpy(&marker, marker_info, sizeof(struct bond_marker));
- // change the marker subtype to marker response
+ /* change the marker subtype to marker response */
marker.tlv_type = AD_MARKER_RESPONSE_SUBTYPE;
- // send the marker response
+ /* send the marker response */
if (ad_marker_send(port, &marker) >= 0) {
pr_debug("Sent Marker Response on port %d\n",
@@ -1839,16 +1908,13 @@ static void ad_marker_info_received(struct bond_marker *marker_info,
static void ad_marker_response_received(struct bond_marker *marker,
struct port *port)
{
- marker = NULL; /* just to satisfy the compiler */
- port = NULL; /* just to satisfy the compiler */
- // DO NOTHING, SINCE WE DECIDED NOT TO IMPLEMENT THIS FEATURE FOR NOW
+ marker = NULL;
+ port = NULL;
}
-//////////////////////////////////////////////////////////////////////////////////////
-// ================= AD exported functions to the main bonding code ==================
-//////////////////////////////////////////////////////////////////////////////////////
+/* ============= AD exported functions to the main bonding code ============ */
-// Check aggregators status in team every T seconds
+/* Check aggregators status in team every T seconds */
#define AD_AGGREGATOR_SELECTION_TIMER 8
/*
@@ -1876,17 +1942,20 @@ static u16 aggregator_identifier;
*/
void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution, int lacp_fast)
{
- // check that the bond is not initialized yet
- if (MAC_ADDRESS_COMPARE(&(BOND_AD_INFO(bond).system.sys_mac_addr),
+ /* check that the bond is not initialized yet */
+ if (compare_ether_addr((const u8 *)&(BOND_AD_INFO(bond).system.sys_mac_addr),
bond->dev->dev_addr)) {
aggregator_identifier = 0;
BOND_AD_INFO(bond).lacp_fast = lacp_fast;
BOND_AD_INFO(bond).system.sys_priority = 0xFFFF;
- BOND_AD_INFO(bond).system.sys_mac_addr = *((struct mac_addr *)bond->dev->dev_addr);
+ BOND_AD_INFO(bond).system.sys_mac_addr =
+ *((struct mac_addr *)bond->dev->dev_addr);
- // initialize how many times this module is called in one second(should be about every 100ms)
+ /* initialize how many times this module is
+ * called in one second(should be about every 100ms)
+ */
ad_ticks_per_sec = tick_resolution;
bond_3ad_initiate_agg_selection(bond,
@@ -1914,31 +1983,37 @@ int bond_3ad_bind_slave(struct slave *slave)
return -1;
}
- //check that the slave has not been initialized yet.
+ /* check that the slave has not been initialized yet. */
if (SLAVE_AD_INFO(slave).port.slave != slave) {
- // port initialization
+ /* port initialization */
port = &(SLAVE_AD_INFO(slave).port);
ad_initialize_port(port, BOND_AD_INFO(bond).lacp_fast);
port->slave = slave;
port->actor_port_number = SLAVE_AD_INFO(slave).id;
- // key is determined according to the link speed, duplex and user key(which is yet not supported)
- // ------------------------------------------------------------
- // Port key : | User key | Speed |Duplex|
- // ------------------------------------------------------------
- // 16 6 1 0
- port->actor_admin_port_key = 0; // initialize this parameter
+ /* key is determined according to the link speed,
+ * duplex and user key(which is yet not supported)
+ * Port key:
+ * ------------------------------------------------------------
+ * | User key | Speed |Duplex|
+ * ------------------------------------------------------------
+ * 16 6 1 0
+ */
+ port->actor_admin_port_key = 0; /* initialize this parameter */
port->actor_admin_port_key |= __get_duplex(port);
port->actor_admin_port_key |= (__get_link_speed(port) << 1);
port->actor_oper_port_key = port->actor_admin_port_key;
- // if the port is not full duplex, then the port should be not lacp Enabled
+ /* if the port is not full duplex,
+ * then the port should be not lacp Enabled
+ */
if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_BITS))
port->sm_vars &= ~AD_PORT_LACP_ENABLED;
- // actor system is the bond's system
+ /* actor system is the bond's system */
port->actor_system = BOND_AD_INFO(bond).system.sys_mac_addr;
- // tx timer(to verify that no more than MAX_TX_IN_SECOND lacpdu's are sent in one second)
+
+ /* certify that no more than MAX_TX_IN_SECOND lacpdu sent/sec */
port->sm_tx_timer_counter = ad_ticks_per_sec/AD_MAX_TX_IN_SECOND;
port->aggregator = NULL;
port->next_port_in_aggregator = NULL;
@@ -1947,12 +2022,13 @@ int bond_3ad_bind_slave(struct slave *slave)
__initialize_port_locks(port);
- // aggregator initialization
+ /* aggregator initialization */
aggregator = &(SLAVE_AD_INFO(slave).aggregator);
ad_initialize_agg(aggregator);
- aggregator->aggregator_mac_address = *((struct mac_addr *)bond->dev->dev_addr);
+ aggregator->aggregator_mac_address =
+ *((struct mac_addr *)bond->dev->dev_addr);
aggregator->aggregator_identifier = (++aggregator_identifier);
aggregator->slave = slave;
aggregator->is_active = 0;
@@ -1976,13 +2052,13 @@ void bond_3ad_unbind_slave(struct slave *slave)
struct aggregator *aggregator, *new_aggregator, *temp_aggregator;
int select_new_active_agg = 0;
- // find the aggregator related to this slave
+ /* find the aggregator related to this slave */
aggregator = &(SLAVE_AD_INFO(slave).aggregator);
- // find the port related to this slave
+ /* find the port related to this slave */
port = &(SLAVE_AD_INFO(slave).port);
- // if slave is null, the whole port is not initialized
+ /* if slave is null, the whole port is not initialized */
if (!port->slave) {
pr_warning("Warning: %s: Trying to unbind an uninitialized port on %s\n",
slave->dev->master->name, slave->dev->name);
@@ -1997,32 +2073,43 @@ void bond_3ad_unbind_slave(struct slave *slave)
__update_lacpdu_from_port(port);
ad_lacpdu_send(port);
- // check if this aggregator is occupied
+ /* check if this aggregator is occupied */
if (aggregator->lag_ports) {
- // check if there are other ports related to this aggregator except
- // the port related to this slave(thats ensure us that there is a
- // reason to search for new aggregator, and that we will find one
- if ((aggregator->lag_ports != port) || (aggregator->lag_ports->next_port_in_aggregator)) {
- // find new aggregator for the related port(s)
+ /* check if there are other ports related to this aggregator
+ * except the port related to this slave
+ * (thats ensure us that there is a reason to search for
+ * new aggregator, and that we will find one)
+ */
+ if ((aggregator->lag_ports != port) ||
+ (aggregator->lag_ports->next_port_in_aggregator)) {
+ /* find new aggregator for the related port(s) */
new_aggregator = __get_first_agg(port);
- for (; new_aggregator; new_aggregator = __get_next_agg(new_aggregator)) {
- // if the new aggregator is empty, or it is connected to our port only
- if (!new_aggregator->lag_ports
- || ((new_aggregator->lag_ports == port)
- && !new_aggregator->lag_ports->next_port_in_aggregator))
+ for (; new_aggregator;
+ new_aggregator = __get_next_agg(new_aggregator)) {
+ /* if the new aggregator is empty,
+ or it is connected to our port only */
+ if (!new_aggregator->lag_ports ||
+ ((new_aggregator->lag_ports == port) &&
+ !new_aggregator->lag_ports->next_port_in_aggregator))
break;
}
- // if new aggregator found, copy the aggregator's parameters
- // and connect the related lag_ports to the new aggregator
- if ((new_aggregator) && ((!new_aggregator->lag_ports) || ((new_aggregator->lag_ports == port) && !new_aggregator->lag_ports->next_port_in_aggregator))) {
+ /* if new aggregator found, copy the aggregator's
+ * parameters and connect the related lag_ports to the
+ * new aggregator
+ */
+ if ((new_aggregator) &&
+ ((!new_aggregator->lag_ports) ||
+ ((new_aggregator->lag_ports == port) &&
+ !new_aggregator->lag_ports->next_port_in_aggregator))) {
pr_debug("Some port(s) related to LAG %d - replaceing with LAG %d\n",
aggregator->aggregator_identifier,
new_aggregator->aggregator_identifier);
- if ((new_aggregator->lag_ports == port) && new_aggregator->is_active) {
+ if ((new_aggregator->lag_ports == port) &&
+ new_aggregator->is_active) {
pr_info("%s: Removing an active aggregator\n",
aggregator->slave->dev->master->name);
- // select new active aggregator
+ /* select new active aggregator */
select_new_active_agg = 1;
}
@@ -2038,14 +2125,15 @@ void bond_3ad_unbind_slave(struct slave *slave)
new_aggregator->is_active = aggregator->is_active;
new_aggregator->num_of_ports = aggregator->num_of_ports;
- // update the information that is written on the ports about the aggregator
- for (temp_port = aggregator->lag_ports; temp_port;
- temp_port = temp_port->next_port_in_aggregator) {
+ /* update the information that is written on
+ * the ports about the aggregator
+ */
+ for (temp_port = aggregator->lag_ports; temp_port; temp_port = temp_port->next_port_in_aggregator) {
temp_port->aggregator = new_aggregator;
temp_port->actor_port_aggregator_identifier = new_aggregator->aggregator_identifier;
}
- // clear the aggregator
+ /* clear the aggregator */
ad_clear_agg(aggregator);
if (select_new_active_agg)
@@ -2054,42 +2142,50 @@ void bond_3ad_unbind_slave(struct slave *slave)
pr_warning("%s: Warning: unbinding aggregator, and could not find a new aggregator for its ports\n",
slave->dev->master->name);
}
- } else { // in case that the only port related to this aggregator is the one we want to remove
+ } else {
+ /* in case that the only port related to this
+ * aggregator is the one we want to remove
+ */
select_new_active_agg = aggregator->is_active;
- // clear the aggregator
+ /* clear the aggregator */
ad_clear_agg(aggregator);
if (select_new_active_agg) {
pr_info("%s: Removing an active aggregator\n",
slave->dev->master->name);
- // select new active aggregator
+ /* select new active aggregator */
ad_agg_selection_logic(__get_first_agg(port));
}
}
}
pr_debug("Unbinding port %d\n", port->actor_port_number);
- // find the aggregator that this port is connected to
+ /* find the aggregator that this port is connected to */
temp_aggregator = __get_first_agg(port);
- for (; temp_aggregator; temp_aggregator = __get_next_agg(temp_aggregator)) {
+ for (; temp_aggregator;
+ temp_aggregator = __get_next_agg(temp_aggregator)) {
prev_port = NULL;
- // search the port in the aggregator's related ports
+ /* search the port in the aggregator's related ports */
for (temp_port = temp_aggregator->lag_ports; temp_port;
prev_port = temp_port,
temp_port = temp_port->next_port_in_aggregator) {
- if (temp_port == port) { // the aggregator found - detach the port from this aggregator
+ if (temp_port == port) {
+ /* the aggregator found
+ detach the port from this aggregator */
if (prev_port)
- prev_port->next_port_in_aggregator = temp_port->next_port_in_aggregator;
+ prev_port->next_port_in_aggregator =
+ temp_port->next_port_in_aggregator;
else
- temp_aggregator->lag_ports = temp_port->next_port_in_aggregator;
+ temp_aggregator->lag_ports =
+ temp_port->next_port_in_aggregator;
temp_aggregator->num_of_ports--;
if (temp_aggregator->num_of_ports == 0) {
select_new_active_agg = temp_aggregator->is_active;
- // clear the aggregator
+ /* clear the aggregator */
ad_clear_agg(temp_aggregator);
if (select_new_active_agg) {
pr_info("%s: Removing an active aggregator\n",
slave->dev->master->name);
- // select new active aggregator
+ /* select new active aggreg */
ad_agg_selection_logic(__get_first_agg(port));
}
}
@@ -2125,13 +2221,14 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
if (bond->kill_timers)
goto out;
- //check if there are any slaves
+ /* check if there are any slaves */
if (bond->slave_cnt == 0)
goto re_arm;
- // check if agg_select_timer timer after initialize is timed out
- if (BOND_AD_INFO(bond).agg_select_timer && !(--BOND_AD_INFO(bond).agg_select_timer)) {
- // select the active aggregator for the bond
+ /* check if agg_select_timer timer after initialize is timed out */
+ if (BOND_AD_INFO(bond).agg_select_timer &&
+ !(--BOND_AD_INFO(bond).agg_select_timer)) {
+ /* select the active aggregator for the bond */
if ((port = __get_first_port(bond))) {
if (!port->slave) {
pr_warning("%s: Warning: bond's first port is uninitialized\n",
@@ -2145,17 +2242,18 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
bond_3ad_set_carrier(bond);
}
- // for each port run the state machines
- for (port = __get_first_port(bond); port; port = __get_next_port(port)) {
+ /* for each port run the state machines */
+ for (port = __get_first_port(bond); port;
+ port = __get_next_port(port)) {
if (!port->slave) {
pr_warning("%s: Warning: Found an uninitialized port\n",
bond->dev->name);
goto re_arm;
}
- /* Lock around state machines to protect data accessed
- * by all (e.g., port->sm_vars). ad_rx_machine may run
- * concurrently due to incoming LACPDU.
+ /* Lock around state machines to protect data accessed by all
+ * (e.g., port->sm_vars).
+ * ad_rx_machine may run concurrently due to incoming LACPDU.
*/
__get_state_machine_lock(port);
@@ -2165,7 +2263,7 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
ad_mux_machine(port);
ad_tx_machine(port);
- // turn off the BEGIN bit, since we already handled it
+ /* turn off the BEGIN bit, since we already handled it */
if (port->sm_vars & AD_PORT_BEGIN)
port->sm_vars &= ~AD_PORT_BEGIN;
@@ -2198,7 +2296,8 @@ static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u
if (!port->slave) {
pr_warning("%s: Warning: port of slave %s is uninitialized\n",
- slave->dev->name, slave->dev->master->name);
+ slave->dev->name,
+ slave->dev->master->name);
return;
}
@@ -2213,7 +2312,9 @@ static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u
break;
case AD_TYPE_MARKER:
- // No need to convert fields to Little Endian since we don't use the marker's fields.
+ /* No need to convert fields to Little Endian
+ * since we don't use the marker's fields.
+ */
switch (((struct bond_marker *)lacpdu)->tlv_type) {
case AD_MARKER_INFORMATION_SUBTYPE:
@@ -2248,19 +2349,22 @@ void bond_3ad_adapter_speed_changed(struct slave *slave)
port = &(SLAVE_AD_INFO(slave).port);
- // if slave is null, the whole port is not initialized
+ /* if slave is null, the whole port is not initialized */
if (!port->slave) {
pr_warning("Warning: %s: speed changed for uninitialized port on %s\n",
- slave->dev->master->name, slave->dev->name);
+ slave->dev->master->name,
+ slave->dev->name);
return;
}
port->actor_admin_port_key &= ~AD_SPEED_KEY_BITS;
port->actor_oper_port_key = port->actor_admin_port_key |=
(__get_link_speed(port) << 1);
+
pr_debug("Port %d changed speed\n", port->actor_port_number);
- // there is no need to reselect a new aggregator, just signal the
- // state machines to reinitialize
+ /* there is no need to reselect a new aggregator,
+ * just signal the state machines to reinitialize
+ */
port->sm_vars |= AD_PORT_BEGIN;
}
@@ -2276,19 +2380,22 @@ void bond_3ad_adapter_duplex_changed(struct slave *slave)
port = &(SLAVE_AD_INFO(slave).port);
- // if slave is null, the whole port is not initialized
+ /* if slave is null, the whole port is not initialized */
if (!port->slave) {
pr_warning("%s: Warning: duplex changed for uninitialized port on %s\n",
- slave->dev->master->name, slave->dev->name);
+ slave->dev->master->name,
+ slave->dev->name);
return;
}
port->actor_admin_port_key &= ~AD_DUPLEX_KEY_BITS;
port->actor_oper_port_key = port->actor_admin_port_key |=
__get_duplex(port);
+
pr_debug("Port %d changed duplex\n", port->actor_port_number);
- // there is no need to reselect a new aggregator, just signal the
- // state machines to reinitialize
+ /* there is no need to reselect a new aggregator,
+ * just signal the state machines to reinitialize
+ */
port->sm_vars |= AD_PORT_BEGIN;
}
@@ -2305,15 +2412,19 @@ void bond_3ad_handle_link_change(struct slave *slave, char link)
port = &(SLAVE_AD_INFO(slave).port);
- // if slave is null, the whole port is not initialized
+ /* if slave is null, the whole port is not initialized */
if (!port->slave) {
pr_warning("Warning: %s: link status changed for uninitialized port on %s\n",
- slave->dev->master->name, slave->dev->name);
+ slave->dev->master->name,
+ slave->dev->name);
return;
}
- // on link down we are zeroing duplex and speed since some of the adaptors(ce1000.lan) report full duplex/speed instead of N/A(duplex) / 0(speed)
- // on link up we are forcing recheck on the duplex and speed since some of he adaptors(ce1000.lan) report
+ /* on link down we are zeroing duplex and speed
+ * since some of the adaptors (ce1000.lan) report full duplex/speed
+ * instead of N/A (duplex) / 0(speed)
+ * on link up we are forcing recheck on the duplex and speed
+ */
if (link == BOND_LINK_UP) {
port->is_enabled = true;
port->actor_admin_port_key &= ~AD_DUPLEX_KEY_BITS;
@@ -2329,9 +2440,15 @@ void bond_3ad_handle_link_change(struct slave *slave, char link)
port->actor_oper_port_key = (port->actor_admin_port_key &=
~AD_SPEED_KEY_BITS);
}
- //BOND_PRINT_DBG(("Port %d changed link status to %s", port->actor_port_number, ((link == BOND_LINK_UP)?"UP":"DOWN")));
- // there is no need to reselect a new aggregator, just signal the
- // state machines to reinitialize
+
+ /* BOND_PRINT_DBG(("Port %d changed link status to %s",
+ * port->actor_port_number,
+ * ((link == BOND_LINK_UP)?"UP":"DOWN")));
+ */
+
+ /* there is no need to reselect a new aggregator,
+ * just signal the state machines to reinitialize
+ */
port->sm_vars |= AD_PORT_BEGIN;
}
@@ -2387,7 +2504,8 @@ int bond_3ad_get_active_agg_info(struct bonding *bond, struct ad_info *ad_info)
ad_info->ports = aggregator->num_of_ports;
ad_info->actor_key = aggregator->actor_oper_aggregator_key;
ad_info->partner_key = aggregator->partner_oper_aggregator_key;
- memcpy(ad_info->partner_system, aggregator->partner_system.mac_addr_value, ETH_ALEN);
+ memcpy(ad_info->partner_system,
+ aggregator->partner_system.mac_addr_value, ETH_ALEN);
return 0;
}
@@ -2405,9 +2523,7 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
struct ad_info ad_info;
int res = 1;
- /* make sure that the slaves list will
- * not change during tx
- */
+ /* make sure that the slaves list will not change during tx */
read_lock(&bond->lock);
if (!BOND_IS_OK(bond))
@@ -2442,7 +2558,7 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
if (slave_agg_no >= 0) {
pr_err("%s: Error: Couldn't find a slave to tx on for aggregator ID %d\n",
- dev->name, agg_id);
+ dev->name, agg_id);
goto out;
}
diff --git a/drivers/net/bonding/bond_3ad.h b/drivers/net/bonding/bond_3ad.h
index b28baff..83b0961 100644
--- a/drivers/net/bonding/bond_3ad.h
+++ b/drivers/net/bonding/bond_3ad.h
@@ -28,7 +28,7 @@
#include <linux/netdevice.h>
#include <linux/if_ether.h>
-// General definitions
+/* General definitions */
#define PKT_TYPE_LACPDU cpu_to_be16(ETH_P_SLOW)
#define AD_TIMER_INTERVAL 100 /*msec*/
@@ -47,54 +47,54 @@ enum {
BOND_AD_COUNT = 2,
};
-// rx machine states(43.4.11 in the 802.3ad standard)
+/* rx machine states (43.4.11 in the 802.3ad standard) */
typedef enum {
AD_RX_DUMMY,
- AD_RX_INITIALIZE, // rx Machine
- AD_RX_PORT_DISABLED, // rx Machine
- AD_RX_LACP_DISABLED, // rx Machine
- AD_RX_EXPIRED, // rx Machine
- AD_RX_DEFAULTED, // rx Machine
- AD_RX_CURRENT // rx Machine
+ AD_RX_INITIALIZE,
+ AD_RX_PORT_DISABLED,
+ AD_RX_LACP_DISABLED,
+ AD_RX_EXPIRED,
+ AD_RX_DEFAULTED,
+ AD_RX_CURRENT
} rx_states_t;
-// periodic machine states(43.4.12 in the 802.3ad standard)
+/* periodic machine states (43.4.12 in the 802.3ad standard) */
typedef enum {
AD_PERIODIC_DUMMY,
- AD_NO_PERIODIC, // periodic machine
- AD_FAST_PERIODIC, // periodic machine
- AD_SLOW_PERIODIC, // periodic machine
- AD_PERIODIC_TX // periodic machine
+ AD_NO_PERIODIC,
+ AD_FAST_PERIODIC,
+ AD_SLOW_PERIODIC,
+ AD_PERIODIC_TX
} periodic_states_t;
-// mux machine states(43.4.13 in the 802.3ad standard)
+/* mux machine states (43.4.13 in the 802.3ad standard) */
typedef enum {
AD_MUX_DUMMY,
- AD_MUX_DETACHED, // mux machine
- AD_MUX_WAITING, // mux machine
- AD_MUX_ATTACHED, // mux machine
- AD_MUX_COLLECTING_DISTRIBUTING // mux machine
+ AD_MUX_DETACHED,
+ AD_MUX_WAITING,
+ AD_MUX_ATTACHED,
+ AD_MUX_COLLECTING_DISTRIBUTING
} mux_states_t;
-// tx machine states(43.4.15 in the 802.3ad standard)
+/* tx machine states (43.4.15 in the 802.3ad standard) */
typedef enum {
AD_TX_DUMMY,
- AD_TRANSMIT // tx Machine
+ AD_TRANSMIT
} tx_states_t;
-// rx indication types
+/* rx indication types */
typedef enum {
- AD_TYPE_LACPDU = 1, // type lacpdu
- AD_TYPE_MARKER // type marker
+ AD_TYPE_LACPDU = 1,
+ AD_TYPE_MARKER
} pdu_type_t;
-// rx marker indication types
+/* rx marker indication types */
typedef enum {
- AD_MARKER_INFORMATION_SUBTYPE = 1, // marker imformation subtype
- AD_MARKER_RESPONSE_SUBTYPE // marker response subtype
+ AD_MARKER_INFORMATION_SUBTYPE = 1,
+ AD_MARKER_RESPONSE_SUBTYPE
} bond_marker_subtype_t;
-// timers types(43.4.9 in the 802.3ad standard)
+/* timers types (43.4.9 in the 802.3ad standard) */
typedef enum {
AD_CURRENT_WHILE_TIMER,
AD_ACTOR_CHURN_TIMER,
@@ -105,35 +105,37 @@ typedef enum {
#pragma pack(1)
-// Link Aggregation Control Protocol(LACP) data unit structure(43.4.2.2 in the 802.3ad standard)
+/* Link Aggregation Control Protocol (LACP) data unit structure
+ * (43.4.2.2 in the 802.3ad standard)
+ */
typedef struct lacpdu {
- u8 subtype; // = LACP(= 0x01)
+ u8 subtype; /* = LACP(= 0x01) */
u8 version_number;
- u8 tlv_type_actor_info; // = actor information(type/length/value)
- u8 actor_information_length; // = 20
+ u8 tlv_type_actor_info; /* = actor info(type/length/value)*/
+ u8 actor_information_length; /* = 20 */
__be16 actor_system_priority;
struct mac_addr actor_system;
__be16 actor_key;
__be16 actor_port_priority;
__be16 actor_port;
u8 actor_state;
- u8 reserved_3_1[3]; // = 0
- u8 tlv_type_partner_info; // = partner information
- u8 partner_information_length; // = 20
+ u8 reserved_3_1[3]; /* = 0 */
+ u8 tlv_type_partner_info; /* = partner information */
+ u8 partner_information_length; /* = 20 */
__be16 partner_system_priority;
struct mac_addr partner_system;
__be16 partner_key;
__be16 partner_port_priority;
__be16 partner_port;
u8 partner_state;
- u8 reserved_3_2[3]; // = 0
- u8 tlv_type_collector_info; // = collector information
- u8 collector_information_length; // = 16
+ u8 reserved_3_2[3]; /* = 0 */
+ u8 tlv_type_collector_info; /* = collector information */
+ u8 collector_information_length; /* = 16 */
__be16 collector_max_delay;
u8 reserved_12[12];
- u8 tlv_type_terminator; // = terminator
- u8 terminator_length; // = 0
- u8 reserved_50[50]; // = 0
+ u8 tlv_type_terminator; /* = terminator */
+ u8 terminator_length; /* = 0 */
+ u8 reserved_50[50]; /* = 0 */
} lacpdu_t;
typedef struct lacpdu_header {
@@ -141,20 +143,22 @@ typedef struct lacpdu_header {
struct lacpdu lacpdu;
} lacpdu_header_t;
-// Marker Protocol Data Unit(PDU) structure(43.5.3.2 in the 802.3ad standard)
+/* Marker Protocol Data Unit(PDU) structure
+ * (43.5.3.2 in the 802.3ad standard)
+ */
typedef struct bond_marker {
- u8 subtype; // = 0x02 (marker PDU)
- u8 version_number; // = 0x01
- u8 tlv_type; // = 0x01 (marker information)
- // = 0x02 (marker response information)
- u8 marker_length; // = 0x16
- u16 requester_port; // The number assigned to the port by the requester
- struct mac_addr requester_system; // The requester's system id
- u32 requester_transaction_id; // The transaction id allocated by the requester,
- u16 pad; // = 0
- u8 tlv_type_terminator; // = 0x00
- u8 terminator_length; // = 0x00
- u8 reserved_90[90]; // = 0
+ u8 subtype; /* = 0x02 (marker PDU) */
+ u8 version_number; /* = 0x01 */
+ u8 tlv_type; /* = 0x01 (marker information)
+ * = 0x02 (marker response info */
+ u8 marker_length; /* = 0x16 */
+ u16 requester_port;
+ struct mac_addr requester_system; /* The requester's system id */
+ u32 requester_transaction_id;
+ u16 pad; /* = 0 */
+ u8 tlv_type_terminator; /* = 0x00 */
+ u8 terminator_length; /* = 0x00 */
+ u8 reserved_90[90]; /* = 0 */
} bond_marker_t;
typedef struct bond_marker_header {
@@ -173,7 +177,7 @@ struct port;
#pragma pack(8)
#endif
-// aggregator structure(43.4.5 in the 802.3ad standard)
+/* aggregator structure (43.4.5 in the 802.3ad standard) */
typedef struct aggregator {
struct mac_addr aggregator_mac_address;
u16 aggregator_identifier;
@@ -183,12 +187,13 @@ typedef struct aggregator {
struct mac_addr partner_system;
u16 partner_system_priority;
u16 partner_oper_aggregator_key;
- u16 receive_state; // BOOLEAN
- u16 transmit_state; // BOOLEAN
+ u16 receive_state; /* BOOLEAN */
+ u16 transmit_state; /* BOOLEAN */
struct port *lag_ports;
- // ****** PRIVATE PARAMETERS ******
- struct slave *slave; // pointer to the bond slave that this aggregator belongs to
- u16 is_active; // BOOLEAN. Indicates if this aggregator is active
+ /* ****** PRIVATE PARAMETERS ****** */
+ struct slave *slave; /* poiter to the bond slave
+ that this aggregator belongs to */
+ u16 is_active; /* BOOLEAN. Indicates if the aggregator is active*/
u16 num_of_ports;
} aggregator_t;
@@ -201,12 +206,18 @@ struct port_params {
u16 port_state;
};
-// port structure(43.4.6 in the 802.3ad standard)
+/* port structure (43.4.6 in the 802.3ad standard) */
typedef struct port {
u16 actor_port_number;
u16 actor_port_priority;
- struct mac_addr actor_system; // This parameter is added here although it is not specified in the standard, just for simplification
- u16 actor_system_priority; // This parameter is added here although it is not specified in the standard, just for simplification
+
+ /* in a attempt to simplify operations the
+ * following two elements were included here
+ * despite they are not specified in the standard
+ */
+ struct mac_addr actor_system;
+ u16 actor_system_priority;
+
u16 actor_port_aggregator_identifier;
bool ntt;
u16 actor_admin_port_key;
@@ -219,21 +230,21 @@ typedef struct port {
bool is_enabled;
- // ****** PRIVATE PARAMETERS ******
- u16 sm_vars; // all state machines variables for this port
- rx_states_t sm_rx_state; // state machine rx state
- u16 sm_rx_timer_counter; // state machine rx timer counter
- periodic_states_t sm_periodic_state;// state machine periodic state
- u16 sm_periodic_timer_counter; // state machine periodic timer counter
- mux_states_t sm_mux_state; // state machine mux state
- u16 sm_mux_timer_counter; // state machine mux timer counter
- tx_states_t sm_tx_state; // state machine tx state
- u16 sm_tx_timer_counter; // state machine tx timer counter(allways on - enter to transmit state 3 time per second)
- struct slave *slave; // pointer to the bond slave that this port belongs to
- struct aggregator *aggregator; // pointer to an aggregator that this port related to
- struct port *next_port_in_aggregator; // Next port on the linked list of the parent aggregator
- u32 transaction_id; // continuous number for identification of Marker PDU's;
- struct lacpdu lacpdu; // the lacpdu that will be sent for this port
+ /* ****** PRIVATE PARAMETERS ****** */
+ u16 sm_vars;
+ rx_states_t sm_rx_state;
+ u16 sm_rx_timer_counter;
+ periodic_states_t sm_periodic_state;
+ u16 sm_periodic_timer_counter;
+ mux_states_t sm_mux_state;
+ u16 sm_mux_timer_counter;
+ tx_states_t sm_tx_state;
+ u16 sm_tx_timer_counter;
+ struct slave *slave;
+ struct aggregator *aggregator;
+ struct port *next_port_in_aggregator;
+ u32 transaction_id;
+ struct lacpdu lacpdu;
} port_t;
// system structure
@@ -246,41 +257,41 @@ struct ad_system {
#pragma pack()
#endif
#define BOND_AD_INFO(bond) ((bond)->ad_info)
#define SLAVE_AD_INFO(slave) ((slave)->ad_info)
struct ad_bond_info {
struct ad_system system; /* 802.3ad system structure */
- u32 agg_select_timer; // Timer to select aggregator after all adapter's hand shakes
- u32 agg_select_mode; // Mode of selection of active aggregator(bandwidth/count)
- int lacp_fast; /* whether fast periodic tx should be
- * requested
- */
+ u32 agg_select_timer; /* aggregator's selected timer */
+ u32 agg_select_mode; /* aggregator's selected mode */
+ int lacp_fast;
struct timer_list ad_timer;
struct packet_type ad_pkt_type;
};
struct ad_slave_info {
- struct aggregator aggregator; // 802.3ad aggregator structure
- struct port port; // 802.3ad port structure
- spinlock_t state_machine_lock; /* mutex state machines vs.
- incoming LACPDU */
+ struct aggregator aggregator; /* 802.3ad aggregator structure */
+ struct port port; /* 802.3ad port structure */
+ spinlock_t state_machine_lock; /* mutex state machines vs.
+ * incoming LACPDU */
u16 id;
};
-// ================= AD Exported functions to the main bonding code ==================
-void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution, int lacp_fast);
-int bond_3ad_bind_slave(struct slave *slave);
+/* ========= AD Exported functions to the main bonding code ========== */
+void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution,
+ int lacp_fast);
+int bond_3ad_bind_slave(struct slave *slave);
void bond_3ad_unbind_slave(struct slave *slave);
void bond_3ad_state_machine_handler(struct work_struct *);
void bond_3ad_initiate_agg_selection(struct bonding *bond, int timeout);
void bond_3ad_adapter_speed_changed(struct slave *slave);
void bond_3ad_adapter_duplex_changed(struct slave *slave);
void bond_3ad_handle_link_change(struct slave *slave, char link);
-int bond_3ad_get_active_agg_info(struct bonding *bond, struct ad_info *ad_info);
+int bond_3ad_get_active_agg_info(struct bonding *bond, struct ad_info *ad_info);
int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev);
-int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type* ptype, struct net_device *orig_dev);
+int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev,
+ struct packet_type* ptype, struct net_device *orig_dev);
int bond_3ad_set_carrier(struct bonding *bond);
#endif //__BOND_3AD_H__
--
1.7.4.4
^ permalink raw reply related
* Loan Opportunity At 2% Interest Rate
From: Finance @ 2011-05-06 3:08 UTC (permalink / raw)
We offer Loan to a serious individuals and Organizations.
Get back to us if interested contact Mr.smith lampard for loan application form
Email:ukfinaceworld@gmail.com
Mr.Smith Lampard
Advert Manager.
^ permalink raw reply
* Re: [PATCH] net/bonding: bonding: Adjust coding style for bond_3ad files.
From: David Miller @ 2011-05-06 3:41 UTC (permalink / raw)
To: aquini; +Cc: kernel-janitors, joe, fubar, andy, netdev, shemminger
In-Reply-To: <20110506010534.GA11772@x61.tchesoft.com>
From: Rafael Aquini <aquini@linux.com>
Date: Thu, 5 May 2011 22:05:37 -0300
> Howdy,
>
> Thanks to Joe Perches & Stephen Hemminger for
> taking time and proving valuable feedback.
>
> Resubmitting the proposed patch.
When resubmitting a patch you must make a full resubmission, this means
a full commit log message, and all necessary "Signed-off-by: " etc.
tags.
^ permalink raw reply
* Re: [E1000-devel] [PATCH] e1000: Allow the driver to be used on PA RISC C8000 workstation
From: Rolf Eike Beer @ 2011-05-06 5:58 UTC (permalink / raw)
To: Jesse Brandeburg
Cc: Guy Martin, Kirsher, Jeffrey T, kyle@mcmartin.ca,
e1000-devel@lists.sourceforge.net, linux-parisc@vger.kernel.org,
mikulas@artax.karlin.mff.cuni.cz, netdev
In-Reply-To: <1538517.jd8kKEpd3f@donald.sf-tec.de>
[-- Attachment #1: Type: text/plain, Size: 1682 bytes --]
Am Freitag, 18. März 2011, 17:39:57 schrieb Rolf Eike Beer:
> Am Mittwoch, 2. März 2011, 21:19:24 schrieb Jesse Brandeburg:
> > On Mon, Feb 28, 2011 at 5:40 AM, Guy Martin <gmsoft@tuxicoman.be> wrote:
> > > Hi Jeff,
> > >
> > > Any luck getting this into mainline ?
> >
> > Hi Guy, sorry for the delay,
> > We haven't been able to get our contacts in HP to give us a decent
> > response so far, we are following up with them to see whats up. We
> > have not lost the patch and are still tracking it internally.
> >
> > Give us a couple more weeks if that is okay and we should be able to
> > settle this by then.
> I wonder what exactly you are waiting for? This is a sanity check that we
> disable, so no working systems could get broken by this. And every single
> C8000 seems to be affected by this and is working fine with that patch. So
> maybe people at HP might have a clue _why_ this is screwed, but until then
> I don't see any point in waiting.
>
> So please just add my tested-by and push this upstream soon. Since this is
> basically a hardware quirk I would like to get this into stable also so we
> may run vanilla 2.6.38.1 or something like that on C8000.
>
> Tested-by: Rolf Eike Beer <eike-kernel@sf-tec.de>
For the netdev folks: it's this patch we are talking about
http://www.spinics.net/lists/linux-parisc/msg03091.html
I would love to see that someone finally picks this up and pushes this
upstream, CC stable. This is absolutely annoying as it breaks every time
anyone touches the kernel on one of this machines.
Jeff, David, James: can you please make a decision of who takes this and then
just do it?
Eike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply
* Re: [PATCHv4 2/2] tg3: Allow ethtool to enable/disable loopback.
From: Michał Mirosław @ 2011-05-06 6:35 UTC (permalink / raw)
To: Mahesh Bandewar
Cc: Matt Carlson, David Miller, netdev, Michael Chan, Tom Herbert
In-Reply-To: <BANLkTi=UxTgBU0ZEJ2PMAef1NzvJGqT_ZA@mail.gmail.com>
W dniu 6 maja 2011 01:16 użytkownik Mahesh Bandewar
<maheshb@google.com> napisał:
> On Thu, May 5, 2011 at 11:35 AM, Michał Mirosław <mirqus@gmail.com> wrote:
>> W dniu 5 maja 2011 19:47 użytkownik Mahesh Bandewar
>> <maheshb@google.com> napisał:
>>> On Wed, May 4, 2011 at 11:59 PM, Michał Mirosław <mirqus@gmail.com> wrote:
>>>> 2011/5/5 Mahesh Bandewar <maheshb@google.com>:
>>>>> This patch adds tg3_set_features() to handle loopback mode. Currently the
>>>>> capability is added for the devices which support internal MAC loopback mode.
>>>>> So when enabled, it enables internal-MAC loopback.
>> [...]
>>>>> @@ -9485,6 +9533,15 @@ static int tg3_open(struct net_device *dev)
>>>>>
>>>>> netif_tx_start_all_queues(dev);
>>>>>
>>>>> + /*
>>>>> + * Reset loopback feature if it was turned on while the device was down
>>>>> + * to avoid and any discrepancy in features reporting.
>>>>> + */
>>>>> + if (dev->features & NETIF_F_LOOPBACK) {
>>>>> + dev->features &= ~NETIF_F_LOOPBACK;
>>>>> + dev->wanted_features &= ~NETIF_F_LOOPBACK;
>>>>> + }
>>>>> +
>>>>
>>>> if (dev->features & NETIF_F_LOOPBACK)
>>>> tg3_set_loopback(dev, dev->features);
>>>>
>>> Unfortunately at this stage device will not be able to set-loopback so
>>> I resorted to clearing the bit(s).
>> ndo_fix_features+ndo_set_features might be caled before ndo_open - the
>> first might be just from register_netdev() so even before ndo_open
>> callback.
> ndo_open is the triggering event, so anything before that point does
> not really help.
You're right - I forgot that netif_running() becomes true just before
ndo_open is called. I have a hard time to convince myself that you
can't program the hardware for loopback just at the end of ndo_open
callback.
>>>> Whatever you do, don't modify wanted_features in drivers.
>>> Since just clearing the 'features' would leave wanted_features in
>>> discrepant state, I thought this will bring it to a sane state. So
>>> what is a preferred way?
>> If you really can't do other way, driver should keep additional state
>> that is checked in ndo_fix_features callback.
> ndo_fix_features callback is called just before calling
> ndo_set_features callback. Also this is called during update_features,
> so having the state maintained is not really going to help in this
> scenario since that is not happening when device reaches ready state
> (to remove this discrepancy in the feature-set).
You can call netdev_update_features() at the end of ndo_open. But that
would be the same in the end as just enabling the loopback there.
> There must be a reason (that you did not explain!) why driver code
> should not alter wanted_feature set. So in this scenario, just leaving
> the wanted_features as it is and clearing the features bit is correct
> / enough?
wanted_features reflects a set of features the user wants. I assume
that no code can change the user himself, so changing wanted_features
instead would break this connection. You can view wanted_features as a
cache of user's intention. ;-)
Best Regards,
Michał Mirosław
^ permalink raw reply
* Re: [PATCH] netfilter/IPv6: initialize TOS field in REJECT target module
From: Fernando Luis Vázquez Cao @ 2011-05-06 8:27 UTC (permalink / raw)
To: Pablo Neira Ayuso
Cc: David Miller, eric.dumazet, netfilter-devel, netdev, yoshfuji,
jengelh, Patrick McHardy
In-Reply-To: <4DB6E607.6000303@netfilter.org>
On Tue, 2011-04-26 at 17:34 +0200, Pablo Neira Ayuso wrote:
> On 26/04/11 07:25, Fernando Luis Vazquez Cao wrote:
> > Pablo, could you pull in the two patches below? They have already been
> > acked by Eric. It would be great it we could get them merged for the
> > next -rc and stable releases.
> >
> > [PATCH] netfilter/IPv6: fix DSCP mangle code
> > [PATCH] netfilter/IPv6: initialize TOS field in REJECT target module
>
> Patrick is the primary link to take patches, I'm including him in this
> CC. If he experiences any problem, I'll make sure that these hit -rc, so
> never mind.
It seems that the two patches above did not make it into 2.6.39-rc6. Any
chance we can get them merged before 2.6.39 is released?
Thanks,
Fernando
^ permalink raw reply
* Re: [PATCH v6 BONUS 4/3] ipv4: Store rtable entries directly in FIB
From: Julian Anastasov @ 2011-05-06 9:12 UTC (permalink / raw)
To: David Miller; +Cc: netdev, tgraf, jpirko, herbert, eric.dumazet
In-Reply-To: <20110505.163614.212671515.davem@davemloft.net>
Hello,
On Thu, 5 May 2011, David Miller wrote:
> Ok, here is the fun patch showing the scheme I'm working on. Two
> things going on here.
>
> First, we store pre-constructed rtable entries, on demand, inside of
> the routing table objects themselves.
>
> Second, we get rid of RT_TABLE_LOCAL and load all routes equally
> into RT_TABLE_MAIN.
>
> Signed-off-by: David S. Miller <davem@davemloft.net>
>
> diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
> index 10422ef..f3c9598 100644
> --- a/include/net/ip_fib.h
> +++ b/include/net/ip_fib.h
> @@ -44,6 +44,7 @@ struct fib_config {
> };
>
> struct fib_info;
> +struct rtable;
>
> struct fib_nh {
> struct net_device *nh_dev;
> @@ -62,6 +63,7 @@ struct fib_nh {
> __be32 nh_gw;
> __be32 nh_saddr;
> int nh_saddr_genid;
> + struct rtable *nh_rtable;
Caching results of __mkroute_output in NH does
not work well for RTN_MULTICAST because ip_check_mc_rcu
wants to further restrict local delivery depending on
the source address and protocol. Even the routing cache
does not cache the protocol as key. May be received IGMP report
can create input cache entry with RTCF_LOCAL flag and later the
UDP stack can see unwatned incoming traffic that should be
dropped by MCAST_INCLUDE/MCAST_EXCLUDE settings for the same
group. I.e. the routing code calls ip_check_mc_rcu for IGMP
but the cache prevents the next calls for UDP to drop these
sources.
Before now ip_rt_multicast_event was used to
notify about changes in subscriptions for groups and
the routing cache can update its information (RTCF_LOCAL)
per indev+saddr+daddr (but no protocol). Without routing cache
we can not solve the ip_check_mc_rcu problem with
nh_mc_genid fields because NH can be used for many
different saddr addresses.
Same problem is in ip_route_input_common,
we have to call ip_check_mc_rcu for every packet and
this can be a problem with long lists. But I'm not
sure if the stack can see many filters. If yes, may be
only using hash table for in_dev->mc_list and its
"sources" can help here because we have to call
ip_check_mc_rcu for every input and output packet
if dev+saddr+daddr+proto results are not cached for mcast.
Regards
--
Julian Anastasov <ja@ssi.bg>
^ permalink raw reply
* The late Ms.Ama Stevenson made you a beneficiary in his will to you in the Codicil. CONTACT THIS EMAIL FOR MORE INFORMATION: wstevenson@terra.es
From: Gospodarek, Gail @ 2011-05-06 8:58 UTC (permalink / raw)
^ permalink raw reply
* Re: [RFC v3 02/10] Revert "lsm: Remove the socket_post_accept() hook"
From: Samir Bellabes @ 2011-05-06 9:25 UTC (permalink / raw)
To: Tetsuo Handa
Cc: paul.moore, linux-security-module, linux-kernel, netdev,
netfilter-devel, hadi, kaber, zbr, root
In-Reply-To: <201105060643.JBD90633.MOQJtSFFLFHOOV@I-love.SAKURA.ne.jp>
Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> writes:
> Paul Moore wrote:
>> On Tuesday, May 03, 2011 10:28:24 PM Tetsuo Handa wrote:
>> > Paul Moore wrote:
>> > > On Tuesday, May 03, 2011 10:24:15 AM Samir Bellabes wrote:
>> > > > snet needs to reintroduce this hook, as it was designed to be: a hook
>> > > > for updating security informations on objects.
>> > >
>> > > Looking at this and 5/10 again, it seems that you should be able to do
>> > > what you need with the sock_graft() hook. Am I missing something?
>> > >
>> > > My apologies if we've already discussed this approach previously ...
>> >
>> > Second problem is that genlmsg_unicast() might return -EAGAIN because we
>> > can't sleep inside write_lock_bh()/write_unlock_bh().
>>
>> Ah yes, the real problem. I forgot that snet relied on a user space tool. I
>> tend to agree with others who have suggested this is not the right approach,
>> but I understand why you want the post_accept() hook; thanks for reminding me.
>>
> However, it sounds that Samir says genlmsg_unicast() failure is not fatal.
Actually, if the request to userspace is lost, no retransmission occurs.
there is a timeout to protect this case, and at the end of the tiemout,
a default verdict is apply. So no LSM decision is lost.
for the case of not checking return values, I fixed this in v4 with this
patch :
commit 955d0a69c31684703dbeb1b15a462b06d4c79b52
Author: Samir Bellabes <sam@synack.fr>
Date: Thu May 5 12:36:58 2011 +0200
snet: fix returned value of snet_do_verdict() and
snet_do_send_event()
Signed-off-by: Samir Bellabes <sam@synack.fr>
diff --git a/security/snet/snet_hooks.c b/security/snet/snet_hooks.c
index 84ea5fc..5eb3848 100644
--- a/security/snet/snet_hooks.c
+++ b/security/snet/snet_hooks.c
@@ -67,23 +67,22 @@ static inline int snet_check_listeners(enum
snet_verdict *verdict)
return 0;
}
-static int snet_do_verdict(enum snet_verdict *verdict, struct snet_info
*info)
+static void snet_do_verdict(enum snet_verdict *verdict, struct
snet_info *info)
{
if (info->verdict_id == 0)
- return -1;
+ return;
/* sending networking informations to userspace */
if (snet_nl_send_event(info) == 0)
/* waiting for userspace reply or timeout */
*verdict = snet_verdict_wait(info->verdict_id);
/* removing verdict */
snet_verdict_remove(info->verdict_id);
- return 0;
+ return;
}
-static void snet_do_send_event(struct snet_info *info)
+static int snet_do_send_event(struct snet_info *info)
{
- snet_nl_send_event(info);
- return;
+ return snet_nl_send_event(info);
}
/*
and introduce the statistics mecanism to count errors on all hooks
(statistics are available in /proc/snet/snet_stats)
for example:
if (snet_do_send_event(&info) < 0)
SNET_STATS_INC(SNET_STATS_REG_ERROR,
SNET_SOCKET_POST_ACCEPT);
else
SNET_STATS_INC(SNET_STATS_REG_GRANT,
SNET_SOCKET_POST_ACCEPT);
> Samir Bellabes wrote:
>> using snet_do_send_event() means that system is sending data to
>> userspace. the system is not waiting for a verdict from userspace.
>>
>> If error occurs, we actually loose the information data.
>> I may be able to write a solution which try to send the data again, but
>> we need a exit solution for this loop (a number of try ?).
>
> If genlmsg_unicast() failure is not fatal, snet doesn't need the
> socket_post_accept hook. Samir, is genlmsg_unicast() failure fatal for snet?
> (Although, I'd like to ask for revival of the hook for TOMOYO anyway.)
the main argument for socket_post_accept is to known informations of the
remote inet.
from socket_accept(), we have no clue of who (inet->daddr and
inet->saddr) is connecting to the local service.
with socket_post_accept(), inet->daddr and inet->saddr are filled with
the true distant informations.
This informations is interesting for next security operations on the
socket. (we known with who we are talking to).
thanks,
sam
^ permalink raw reply related
* Re: [PATCH] netfilter/IPv6: initialize TOS field in REJECT target module
From: Pablo Neira Ayuso @ 2011-05-06 10:38 UTC (permalink / raw)
To: Fernando Luis Vázquez Cao
Cc: David Miller, eric.dumazet, netfilter-devel, netdev, yoshfuji,
jengelh, Patrick McHardy
In-Reply-To: <1304670430.6581.45.camel@nexus.oss.ntt.co.jp>
On 06/05/11 10:27, Fernando Luis Vázquez Cao wrote:
> On Tue, 2011-04-26 at 17:34 +0200, Pablo Neira Ayuso wrote:
>> On 26/04/11 07:25, Fernando Luis Vazquez Cao wrote:
>>> Pablo, could you pull in the two patches below? They have already been
>>> acked by Eric. It would be great it we could get them merged for the
>>> next -rc and stable releases.
>>>
>>> [PATCH] netfilter/IPv6: fix DSCP mangle code
>>> [PATCH] netfilter/IPv6: initialize TOS field in REJECT target module
>>
>> Patrick is the primary link to take patches, I'm including him in this
>> CC. If he experiences any problem, I'll make sure that these hit -rc, so
>> never mind.
>
> It seems that the two patches above did not make it into 2.6.39-rc6. Any
> chance we can get them merged before 2.6.39 is released?
I'll pick them and push them to davem by monday. Thanks!
^ permalink raw reply
* Re: [PATCH] netfilter/IPv6: initialize TOS field in REJECT target module
From: Jan Engelhardt @ 2011-05-06 10:45 UTC (permalink / raw)
To: Pablo Neira Ayuso
Cc: Fernando Luis Vázquez Cao, David Miller, eric.dumazet,
netfilter-devel, netdev, yoshfuji, Patrick McHardy
In-Reply-To: <4DC3CFAD.8020305@netfilter.org>
On Friday 2011-05-06 12:38, Pablo Neira Ayuso wrote:
>On 06/05/11 10:27, Fernando Luis Vázquez Cao wrote:
>> On Tue, 2011-04-26 at 17:34 +0200, Pablo Neira Ayuso wrote:
>>> On 26/04/11 07:25, Fernando Luis Vazquez Cao wrote:
>>>> Pablo, could you pull in the two patches below? They have already been
>>>> acked by Eric. It would be great it we could get them merged for the
>>>> next -rc and stable releases.
>>>>
>>>> [PATCH] netfilter/IPv6: fix DSCP mangle code
>>>> [PATCH] netfilter/IPv6: initialize TOS field in REJECT target module
>>>
>>> Patrick is the primary link to take patches, I'm including him in this
>>> CC. If he experiences any problem, I'll make sure that these hit -rc, so
>>> never mind.
>>
>> It seems that the two patches above did not make it into 2.6.39-rc6. Any
>> chance we can get them merged before 2.6.39 is released?
>
>I'll pick them and push them to davem by monday. Thanks!
Also revert a2361c8735e07322023aedc36e4938b35af31eb0 please.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* [PATCH] net/bonding: adjust codingstyle for bond_3ad files.
From: Rafael Aquini @ 2011-05-06 11:50 UTC (permalink / raw)
To: kernel-janitors
Cc: David Miller, Joe Perches, Jay Vosburgh, Andy Gospodarek,
shemminger, netdev
Howdy,
While I was studying what bond_3ad has under its hood, I realized its coding
style did not follow all Documentation/CodingStyle recommendations. As a tiny
collaboration I did some mods there, in an attempt to make that code stick as
closely as possible with Kernel's coding style.
Modifications:
* switched all comments from C99-style to C89-style.
* replaced MAC_ADDRESS_COMPARE macro for compare_ether_addr()
Signed-off-by: Rafael Aquini <aquini@linux.com>
---
drivers/net/bonding/bond_3ad.c | 836 +++++++++++++++++++++++-----------------
drivers/net/bonding/bond_3ad.h | 195 +++++-----
2 files changed, 579 insertions(+), 452 deletions(-)
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index 31912f1..fdb07be 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -34,14 +34,14 @@
#include "bonding.h"
#include "bond_3ad.h"
-// General definitions
+/* General definitions */
#define AD_SHORT_TIMEOUT 1
#define AD_LONG_TIMEOUT 0
#define AD_STANDBY 0x2
#define AD_MAX_TX_IN_SECOND 3
#define AD_COLLECTOR_MAX_DELAY 0
-// Timer definitions(43.4.4 in the 802.3ad standard)
+/* Timer definitions (43.4.4 in the 802.3ad standard) */
#define AD_FAST_PERIODIC_TIME 1
#define AD_SLOW_PERIODIC_TIME 30
#define AD_SHORT_TIMEOUT_TIME (3*AD_FAST_PERIODIC_TIME)
@@ -49,7 +49,7 @@
#define AD_CHURN_DETECTION_TIME 60
#define AD_AGGREGATE_WAIT_TIME 2
-// Port state definitions(43.4.2.2 in the 802.3ad standard)
+/* Port state definitions (43.4.2.2 in the 802.3ad standard) */
#define AD_STATE_LACP_ACTIVITY 0x1
#define AD_STATE_LACP_TIMEOUT 0x2
#define AD_STATE_AGGREGATION 0x4
@@ -59,7 +59,9 @@
#define AD_STATE_DEFAULTED 0x40
#define AD_STATE_EXPIRED 0x80
-// Port Variables definitions used by the State Machines(43.4.7 in the 802.3ad standard)
+/* Port Variables definitions used by the State Machines
+ * (43.4.7 in the 802.3ad standard)
+ */
#define AD_PORT_BEGIN 0x1
#define AD_PORT_LACP_ENABLED 0x2
#define AD_PORT_ACTOR_CHURN 0x4
@@ -71,27 +73,23 @@
#define AD_PORT_SELECTED 0x100
#define AD_PORT_MOVED 0x200
-// Port Key definitions
-// key is determined according to the link speed, duplex and
-// user key(which is yet not supported)
-// ------------------------------------------------------------
-// Port key : | User key | Speed |Duplex|
-// ------------------------------------------------------------
-// 16 6 1 0
+/* Port Key definitions:
+ * key is determined according to the link speed, duplex and
+ * user key (which is yet not supported)
+ * ------------------------------------------------------------
+ * Port key: | User key | Speed |Duplex|
+ * ------------------------------------------------------------
+ * 16 6 1 0
+ */
#define AD_DUPLEX_KEY_BITS 0x1
#define AD_SPEED_KEY_BITS 0x3E
#define AD_USER_KEY_BITS 0xFFC0
-//dalloun
#define AD_LINK_SPEED_BITMASK_1MBPS 0x1
#define AD_LINK_SPEED_BITMASK_10MBPS 0x2
#define AD_LINK_SPEED_BITMASK_100MBPS 0x4
#define AD_LINK_SPEED_BITMASK_1000MBPS 0x8
#define AD_LINK_SPEED_BITMASK_10000MBPS 0x10
-//endalloun
-
-// compare MAC addresses
-#define MAC_ADDRESS_COMPARE(A, B) memcmp(A, B, ETH_ALEN)
static struct mac_addr null_mac_addr = { { 0, 0, 0, 0, 0, 0 } };
static u16 ad_ticks_per_sec;
@@ -99,7 +97,7 @@ static const int ad_delta_in_ticks = (AD_TIMER_INTERVAL * HZ) / 1000;
static const u8 lacpdu_mcast_addr[ETH_ALEN] = MULTICAST_LACPDU_ADDR;
-// ================= main 802.3ad protocol functions ==================
+/* ================= main 802.3ad protocol functions ================== */
static int ad_lacpdu_send(struct port *port);
static int ad_marker_send(struct port *port, struct bond_marker *marker);
static void ad_mux_machine(struct port *port);
@@ -113,14 +111,12 @@ static void ad_initialize_agg(struct aggregator *aggregator);
static void ad_initialize_port(struct port *port, int lacp_fast);
static void ad_enable_collecting_distributing(struct port *port);
static void ad_disable_collecting_distributing(struct port *port);
-static void ad_marker_info_received(struct bond_marker *marker_info, struct port *port);
-static void ad_marker_response_received(struct bond_marker *marker, struct port *port);
-
-
-/////////////////////////////////////////////////////////////////////////////////
-// ================= api to bonding and kernel code ==================
-/////////////////////////////////////////////////////////////////////////////////
+static void ad_marker_info_received(struct bond_marker *marker_info,
+ struct port *port);
+static void ad_marker_response_received(struct bond_marker *marker,
+ struct port *port);
+/* ================= api to bonding and kernel code ================== */
/**
* __get_bond_by_port - get the port's bonding struct
* @port: the port we're looking at
@@ -161,7 +157,7 @@ static inline struct port *__get_next_port(struct port *port)
struct bonding *bond = __get_bond_by_port(port);
struct slave *slave = port->slave;
- // If there's no bond for this port, or this is the last slave
+ /* If there's no bond for this port, or this is the last slave */
if ((bond == NULL) || (slave->next == bond->first_slave))
return NULL;
@@ -179,7 +175,7 @@ static inline struct aggregator *__get_first_agg(struct port *port)
{
struct bonding *bond = __get_bond_by_port(port);
- // If there's no bond for this port, or bond has no slaves
+ /* If there's no bond for this port, or bond has no slaves */
if ((bond == NULL) || (bond->slave_cnt == 0))
return NULL;
@@ -198,7 +194,7 @@ static inline struct aggregator *__get_next_agg(struct aggregator *aggregator)
struct slave *slave = aggregator->slave;
struct bonding *bond = bond_get_bond_by_slave(slave);
- // If there's no bond for this aggregator, or this is the last slave
+ /* If there's no bond for this aggregator, or this is the last slave */
if ((bond == NULL) || (slave->next == bond->first_slave))
return NULL;
@@ -316,10 +312,9 @@ static u16 __get_link_speed(struct port *port)
struct slave *slave = port->slave;
u16 speed;
- /* this if covers only a special case: when the configuration starts with
- * link down, it sets the speed to 0.
- * This is done in spite of the fact that the e100 driver reports 0 to be
- * compatible with MVT in the future.*/
+ /* handling a special case:
+ * when the configuration starts with link down, it sets the speed to 0
+ */
if (slave->link != BOND_LINK_UP)
speed = 0;
else {
@@ -341,7 +336,8 @@ static u16 __get_link_speed(struct port *port)
break;
default:
- speed = 0; // unknown speed value from ethtool. shouldn't happen
+ /* unknown speed value from ethtool. shouldn't happen */
+ speed = 0;
break;
}
}
@@ -365,8 +361,9 @@ static u8 __get_duplex(struct port *port)
u8 retval;
- // handling a special case: when the configuration starts with
- // link down, it sets the duplex to 0.
+ /* handling a special case:
+ * when the configuration starts with link down, it sets the duplex to 0
+ */
if (slave->link != BOND_LINK_UP)
retval = 0x0;
else {
@@ -394,12 +391,10 @@ static u8 __get_duplex(struct port *port)
*/
static inline void __initialize_port_locks(struct port *port)
{
- // make sure it isn't called twice
+ /* make sure it isn't called twice */
spin_lock_init(&(SLAVE_AD_INFO(port->slave).state_machine_lock));
}
-//conversions
-
/**
* __ad_timer_to_ticks - convert a given timer type to AD module ticks
* @timer_type: which timer to operate
@@ -411,36 +406,32 @@ static inline void __initialize_port_locks(struct port *port)
*/
static u16 __ad_timer_to_ticks(u16 timer_type, u16 par)
{
- u16 retval = 0; /* to silence the compiler */
+ u16 retval = 0;
switch (timer_type) {
- case AD_CURRENT_WHILE_TIMER: // for rx machine usage
+ case AD_CURRENT_WHILE_TIMER: /* for rx machine usage */
if (par)
- retval = (AD_SHORT_TIMEOUT_TIME*ad_ticks_per_sec); // short timeout
+ retval = (AD_SHORT_TIMEOUT_TIME*ad_ticks_per_sec);
else
- retval = (AD_LONG_TIMEOUT_TIME*ad_ticks_per_sec); // long timeout
+ retval = (AD_LONG_TIMEOUT_TIME*ad_ticks_per_sec);
break;
- case AD_ACTOR_CHURN_TIMER: // for local churn machine
+ case AD_ACTOR_CHURN_TIMER: /* for local churn machine */
retval = (AD_CHURN_DETECTION_TIME*ad_ticks_per_sec);
break;
- case AD_PERIODIC_TIMER: // for periodic machine
- retval = (par*ad_ticks_per_sec); // long timeout
+ case AD_PERIODIC_TIMER: /* for periodic machine */
+ retval = (par*ad_ticks_per_sec);
break;
- case AD_PARTNER_CHURN_TIMER: // for remote churn machine
+ case AD_PARTNER_CHURN_TIMER: /* for remote churn machine */
retval = (AD_CHURN_DETECTION_TIME*ad_ticks_per_sec);
break;
- case AD_WAIT_WHILE_TIMER: // for selection machine
+ case AD_WAIT_WHILE_TIMER: /* for selection machine */
retval = (AD_AGGREGATE_WAIT_TIME*ad_ticks_per_sec);
break;
}
return retval;
}
-
-/////////////////////////////////////////////////////////////////////////////////
-// ================= ad_rx_machine helper functions ==================
-/////////////////////////////////////////////////////////////////////////////////
-
+/* ================= ad_rx_machine helper functions ================== */
/**
* __choose_matched - update a port's matched variable from a received lacpdu
* @lacpdu: the lacpdu we've received
@@ -466,17 +457,17 @@ static u16 __ad_timer_to_ticks(u16 timer_type, u16 par)
*/
static void __choose_matched(struct lacpdu *lacpdu, struct port *port)
{
- // check if all parameters are alike
+ /* check if all parameters are alike */
if (((ntohs(lacpdu->partner_port) == port->actor_port_number) &&
(ntohs(lacpdu->partner_port_priority) == port->actor_port_priority) &&
- !MAC_ADDRESS_COMPARE(&(lacpdu->partner_system), &(port->actor_system)) &&
+ !compare_ether_addr((const u8 *)&(lacpdu->partner_system), (const u8 *)&(port->actor_system)) &&
(ntohs(lacpdu->partner_system_priority) == port->actor_system_priority) &&
(ntohs(lacpdu->partner_key) == port->actor_oper_port_key) &&
((lacpdu->partner_state & AD_STATE_AGGREGATION) == (port->actor_oper_port_state & AD_STATE_AGGREGATION))) ||
- // or this is individual link(aggregation == FALSE)
+ /* or this is individual link(aggregation == FALSE) */
((lacpdu->actor_state & AD_STATE_AGGREGATION) == 0)
) {
- // update the state machine Matched variable
+ /* update the state machine Matched variable */
port->sm_vars |= AD_PORT_MATCHED;
} else {
port->sm_vars &= ~AD_PORT_MATCHED;
@@ -498,7 +489,7 @@ static void __record_pdu(struct lacpdu *lacpdu, struct port *port)
struct port_params *partner = &port->partner_oper;
__choose_matched(lacpdu, port);
- // record the new parameter values for the partner operational
+ /* record the new values for the operational partner */
partner->port_number = ntohs(lacpdu->actor_port);
partner->port_priority = ntohs(lacpdu->actor_port_priority);
partner->system = lacpdu->actor_system;
@@ -506,12 +497,14 @@ static void __record_pdu(struct lacpdu *lacpdu, struct port *port)
partner->key = ntohs(lacpdu->actor_key);
partner->port_state = lacpdu->actor_state;
- // set actor_oper_port_state.defaulted to FALSE
+ /* set actor_oper_port_state.defaulted to FALSE */
port->actor_oper_port_state &= ~AD_STATE_DEFAULTED;
- // set the partner sync. to on if the partner is sync. and the port is matched
- if ((port->sm_vars & AD_PORT_MATCHED)
- && (lacpdu->actor_state & AD_STATE_SYNCHRONIZATION))
+ /* set the partner sync to on if the partner is sync
+ * and the port is matched.
+ */
+ if ((port->sm_vars & AD_PORT_MATCHED) &&
+ (lacpdu->actor_state & AD_STATE_SYNCHRONIZATION))
partner->port_state |= AD_STATE_SYNCHRONIZATION;
else
partner->port_state &= ~AD_STATE_SYNCHRONIZATION;
@@ -529,11 +522,8 @@ static void __record_pdu(struct lacpdu *lacpdu, struct port *port)
static void __record_default(struct port *port)
{
if (port) {
- // record the partner admin parameters
memcpy(&port->partner_oper, &port->partner_admin,
sizeof(struct port_params));
-
- // set actor_oper_port_state.defaulted to true
port->actor_oper_port_state |= AD_STATE_DEFAULTED;
}
}
@@ -556,14 +546,14 @@ static void __update_selected(struct lacpdu *lacpdu, struct port *port)
if (lacpdu && port) {
const struct port_params *partner = &port->partner_oper;
- // check if any parameter is different
+ /* check if any parameter is different */
if (ntohs(lacpdu->actor_port) != partner->port_number ||
ntohs(lacpdu->actor_port_priority) != partner->port_priority ||
- MAC_ADDRESS_COMPARE(&lacpdu->actor_system, &partner->system) ||
+ compare_ether_addr((const u8 *)&lacpdu->actor_system, (const u8 *)&partner->system) ||
ntohs(lacpdu->actor_system_priority) != partner->system_priority ||
ntohs(lacpdu->actor_key) != partner->key ||
(lacpdu->actor_state & AD_STATE_AGGREGATION) != (partner->port_state & AD_STATE_AGGREGATION)) {
- // update the state machine Selected variable
+ /* update the state machine Selected variable */
port->sm_vars &= ~AD_PORT_SELECTED;
}
}
@@ -587,15 +577,15 @@ static void __update_default_selected(struct port *port)
const struct port_params *admin = &port->partner_admin;
const struct port_params *oper = &port->partner_oper;
- // check if any parameter is different
if (admin->port_number != oper->port_number ||
admin->port_priority != oper->port_priority ||
- MAC_ADDRESS_COMPARE(&admin->system, &oper->system) ||
+ compare_ether_addr((const u8 *)&admin->system,
+ (const u8 *)&oper->system) ||
admin->system_priority != oper->system_priority ||
admin->key != oper->key ||
(admin->port_state & AD_STATE_AGGREGATION)
!= (oper->port_state & AD_STATE_AGGREGATION)) {
- // update the state machine Selected variable
+ /* update the state machine Selected variable */
port->sm_vars &= ~AD_PORT_SELECTED;
}
}
@@ -615,12 +605,12 @@ static void __update_default_selected(struct port *port)
*/
static void __update_ntt(struct lacpdu *lacpdu, struct port *port)
{
- // validate lacpdu and port
+ /* validate lacpdu and port */
if (lacpdu && port) {
- // check if any parameter is different
+ /* check if any parameter is different */
if ((ntohs(lacpdu->partner_port) != port->actor_port_number) ||
(ntohs(lacpdu->partner_port_priority) != port->actor_port_priority) ||
- MAC_ADDRESS_COMPARE(&(lacpdu->partner_system), &(port->actor_system)) ||
+ compare_ether_addr((const u8 *)&(lacpdu->partner_system), (const u8 *)&(port->actor_system)) ||
(ntohs(lacpdu->partner_system_priority) != port->actor_system_priority) ||
(ntohs(lacpdu->partner_key) != port->actor_oper_port_key) ||
((lacpdu->partner_state & AD_STATE_LACP_ACTIVITY) != (port->actor_oper_port_state & AD_STATE_LACP_ACTIVITY)) ||
@@ -628,7 +618,7 @@ static void __update_ntt(struct lacpdu *lacpdu, struct port *port)
((lacpdu->partner_state & AD_STATE_SYNCHRONIZATION) != (port->actor_oper_port_state & AD_STATE_SYNCHRONIZATION)) ||
((lacpdu->partner_state & AD_STATE_AGGREGATION) != (port->actor_oper_port_state & AD_STATE_AGGREGATION))
) {
-
+ /* set port ntt */
port->ntt = true;
}
}
@@ -644,9 +634,7 @@ static void __update_ntt(struct lacpdu *lacpdu, struct port *port)
*/
static void __attach_bond_to_agg(struct port *port)
{
- port = NULL; /* just to satisfy the compiler */
- // This function does nothing since the parser/multiplexer of the receive
- // and the parser/multiplexer of the aggregator are already combined
+ port = NULL;
}
/**
@@ -659,9 +647,7 @@ static void __attach_bond_to_agg(struct port *port)
*/
static void __detach_bond_from_agg(struct port *port)
{
- port = NULL; /* just to satisfy the compiler */
- // This function does nothing sience the parser/multiplexer of the receive
- // and the parser/multiplexer of the aggregator are already combined
+ port = NULL;
}
/**
@@ -675,7 +661,9 @@ static int __agg_ports_are_ready(struct aggregator *aggregator)
int retval = 1;
if (aggregator) {
- // scan all ports in this aggregator to verfy if they are all ready
+ /* scan all ports in this aggregator
+ * to verify if they are all ready.
+ */
for (port = aggregator->lag_ports;
port;
port = port->next_port_in_aggregator) {
@@ -737,7 +725,7 @@ static u32 __get_agg_bandwidth(struct aggregator *aggregator)
bandwidth = aggregator->num_of_ports * 10000;
break;
default:
- bandwidth = 0; /*to silence the compiler ....*/
+ bandwidth = 0;
}
}
return bandwidth;
@@ -809,10 +797,7 @@ static inline void __update_lacpdu_from_port(struct port *port)
*/
}
-//////////////////////////////////////////////////////////////////////////////////////
-// ================= main 802.3ad protocol code ======================================
-//////////////////////////////////////////////////////////////////////////////////////
-
+/* ================= main 802.3ad protocol code ================= */
/**
* ad_lacpdu_send - send out a lacpdu packet on a given port
* @port: the port we're looking at
@@ -841,11 +826,12 @@ static int ad_lacpdu_send(struct port *port)
memcpy(lacpdu_header->hdr.h_dest, lacpdu_mcast_addr, ETH_ALEN);
/* Note: source address is set to be the member's PERMANENT address,
- because we use it to identify loopback lacpdus in receive. */
+ * because we use it to identify loopback lacpdus in receive.
+ */
memcpy(lacpdu_header->hdr.h_source, slave->perm_hwaddr, ETH_ALEN);
lacpdu_header->hdr.h_proto = PKT_TYPE_LACPDU;
- lacpdu_header->lacpdu = port->lacpdu; // struct copy
+ lacpdu_header->lacpdu = port->lacpdu;
dev_queue_xmit(skb);
@@ -886,7 +872,7 @@ static int ad_marker_send(struct port *port, struct bond_marker *marker)
memcpy(marker_header->hdr.h_source, slave->perm_hwaddr, ETH_ALEN);
marker_header->hdr.h_proto = PKT_TYPE_LACPDU;
- marker_header->marker = *marker; // struct copy
+ marker_header->marker = *marker;
dev_queue_xmit(skb);
@@ -902,80 +888,101 @@ static void ad_mux_machine(struct port *port)
{
mux_states_t last_state;
- // keep current State Machine state to compare later if it was changed
last_state = port->sm_mux_state;
if (port->sm_vars & AD_PORT_BEGIN) {
- port->sm_mux_state = AD_MUX_DETACHED; // next state
+ port->sm_mux_state = AD_MUX_DETACHED;
} else {
switch (port->sm_mux_state) {
case AD_MUX_DETACHED:
- if ((port->sm_vars & AD_PORT_SELECTED)
- || (port->sm_vars & AD_PORT_STANDBY))
+ if ((port->sm_vars & AD_PORT_SELECTED) ||
+ (port->sm_vars & AD_PORT_STANDBY))
/* if SELECTED or STANDBY */
- port->sm_mux_state = AD_MUX_WAITING; // next state
+ port->sm_mux_state = AD_MUX_WAITING;
break;
case AD_MUX_WAITING:
- // if SELECTED == FALSE return to DETACH state
- if (!(port->sm_vars & AD_PORT_SELECTED)) { // if UNSELECTED
+ /* if SELECTED == FALSE return to DETACH state */
+ if (!(port->sm_vars & AD_PORT_SELECTED)) {
port->sm_vars &= ~AD_PORT_READY_N;
- // in order to withhold the Selection Logic to check all ports READY_N value
- // every callback cycle to update ready variable, we check READY_N and update READY here
- __set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator));
- port->sm_mux_state = AD_MUX_DETACHED; // next state
+ /* in order to withhold the Selection Logic
+ * to check all ports READY_N value at every
+ * callback cycle to update ready variable,
+ * we check READY_N and update READY here
+ */
+ __set_agg_ports_ready(port->aggregator,
+ __agg_ports_are_ready(port->aggregator));
+ port->sm_mux_state = AD_MUX_DETACHED;
break;
}
- // check if the wait_while_timer expired
- if (port->sm_mux_timer_counter
- && !(--port->sm_mux_timer_counter))
+ /* check if the wait_while_timer expired */
+ if (port->sm_mux_timer_counter &&
+ !(--port->sm_mux_timer_counter))
port->sm_vars |= AD_PORT_READY_N;
- // in order to withhold the selection logic to check all ports READY_N value
- // every callback cycle to update ready variable, we check READY_N and update READY here
- __set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator));
-
- // if the wait_while_timer expired, and the port is in READY state, move to ATTACHED state
- if ((port->sm_vars & AD_PORT_READY)
- && !port->sm_mux_timer_counter)
- port->sm_mux_state = AD_MUX_ATTACHED; // next state
+ /* in order to withhold the selection logic
+ * to check all ports READY_N value at every
+ * callback cycle to update ready variable,
+ * we check READY_N and update READY here
+ */
+ __set_agg_ports_ready(port->aggregator,
+ __agg_ports_are_ready(port->aggregator));
+
+ /* if the wait_while_timer expired, and the port
+ * is in READY state, move to ATTACHED state
+ */
+ if ((port->sm_vars & AD_PORT_READY) &&
+ !port->sm_mux_timer_counter)
+ port->sm_mux_state = AD_MUX_ATTACHED;
break;
case AD_MUX_ATTACHED:
- // check also if agg_select_timer expired(so the edable port will take place only after this timer)
- if ((port->sm_vars & AD_PORT_SELECTED) && (port->partner_oper.port_state & AD_STATE_SYNCHRONIZATION) && !__check_agg_selection_timer(port)) {
- port->sm_mux_state = AD_MUX_COLLECTING_DISTRIBUTING;// next state
- } else if (!(port->sm_vars & AD_PORT_SELECTED) || (port->sm_vars & AD_PORT_STANDBY)) { // if UNSELECTED or STANDBY
+ /* check also if agg_select_timer expired
+ * so the enable port will take place
+ * only after this timer
+ */
+ if ((port->sm_vars & AD_PORT_SELECTED) &&
+ (port->partner_oper.port_state &
+ AD_STATE_SYNCHRONIZATION) &&
+ !__check_agg_selection_timer(port)) {
+ port->sm_mux_state =
+ AD_MUX_COLLECTING_DISTRIBUTING;
+ } else if (!(port->sm_vars & AD_PORT_SELECTED) ||
+ (port->sm_vars & AD_PORT_STANDBY)) {
+ /* if UNSELECTED or STANDBY */
port->sm_vars &= ~AD_PORT_READY_N;
- // in order to withhold the selection logic to check all ports READY_N value
- // every callback cycle to update ready variable, we check READY_N and update READY here
- __set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator));
- port->sm_mux_state = AD_MUX_DETACHED;// next state
+ /* in order to withhold the Selection Logic
+ * to check all ports READY_N value at every
+ * callback cycle to update ready variable,
+ * we check READY_N and update READY here
+ */
+ __set_agg_ports_ready(port->aggregator,
+ __agg_ports_are_ready(port->aggregator));
+ port->sm_mux_state = AD_MUX_DETACHED;
}
break;
case AD_MUX_COLLECTING_DISTRIBUTING:
- if (!(port->sm_vars & AD_PORT_SELECTED) || (port->sm_vars & AD_PORT_STANDBY) ||
- !(port->partner_oper.port_state & AD_STATE_SYNCHRONIZATION)
- ) {
- port->sm_mux_state = AD_MUX_ATTACHED;// next state
-
+ if (!(port->sm_vars & AD_PORT_SELECTED) ||
+ (port->sm_vars & AD_PORT_STANDBY) ||
+ !(port->partner_oper.port_state &
+ AD_STATE_SYNCHRONIZATION)) {
+ port->sm_mux_state = AD_MUX_ATTACHED;
} else {
- // if port state hasn't changed make
- // sure that a collecting distributing
- // port in an active aggregator is enabled
+ /* if port state hasn't changed make
+ * sure that a collecting distributing
+ * port in an active aggregator is enabled
+ */
if (port->aggregator &&
port->aggregator->is_active &&
- !__port_is_enabled(port)) {
-
+ !__port_is_enabled(port))
__enable_port(port);
- }
}
break;
- default: //to silence the compiler
+ default:
break;
}
}
- // check if the state machine was changed
+ /* check if the state machine was changed */
if (port->sm_mux_state != last_state) {
pr_debug("Mux Machine: Port=%d, Last State=%d, Curr State=%d\n",
port->actor_port_number, last_state,
@@ -983,14 +990,16 @@ static void ad_mux_machine(struct port *port)
switch (port->sm_mux_state) {
case AD_MUX_DETACHED:
__detach_bond_from_agg(port);
- port->actor_oper_port_state &= ~AD_STATE_SYNCHRONIZATION;
+ port->actor_oper_port_state &=
+ ~AD_STATE_SYNCHRONIZATION;
ad_disable_collecting_distributing(port);
port->actor_oper_port_state &= ~AD_STATE_COLLECTING;
port->actor_oper_port_state &= ~AD_STATE_DISTRIBUTING;
port->ntt = true;
break;
case AD_MUX_WAITING:
- port->sm_mux_timer_counter = __ad_timer_to_ticks(AD_WAIT_WHILE_TIMER, 0);
+ port->sm_mux_timer_counter =
+ __ad_timer_to_ticks(AD_WAIT_WHILE_TIMER, 0);
break;
case AD_MUX_ATTACHED:
__attach_bond_to_agg(port);
@@ -1006,7 +1015,7 @@ static void ad_mux_machine(struct port *port)
ad_enable_collecting_distributing(port);
port->ntt = true;
break;
- default: //to silence the compiler
+ default:
break;
}
}
@@ -1025,59 +1034,62 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
{
rx_states_t last_state;
- // keep current State Machine state to compare later if it was changed
last_state = port->sm_rx_state;
- // check if state machine should change state
- // first, check if port was reinitialized
+ /* check if state machine should change state
+ * first, check if port was reinitialized
+ */
if (port->sm_vars & AD_PORT_BEGIN)
/* next state */
port->sm_rx_state = AD_RX_INITIALIZE;
- // check if port is not enabled
- else if (!(port->sm_vars & AD_PORT_BEGIN)
- && !port->is_enabled && !(port->sm_vars & AD_PORT_MOVED))
+ /* check if port is not enabled */
+ else if (!(port->sm_vars & AD_PORT_BEGIN) &&
+ !port->is_enabled && !(port->sm_vars & AD_PORT_MOVED))
/* next state */
port->sm_rx_state = AD_RX_PORT_DISABLED;
- // check if new lacpdu arrived
- else if (lacpdu && ((port->sm_rx_state == AD_RX_EXPIRED) || (port->sm_rx_state == AD_RX_DEFAULTED) || (port->sm_rx_state == AD_RX_CURRENT))) {
- port->sm_rx_timer_counter = 0; // zero timer
+ /* check if new lacpdu arrived */
+ else if (lacpdu && ((port->sm_rx_state == AD_RX_EXPIRED) ||
+ (port->sm_rx_state == AD_RX_DEFAULTED) ||
+ (port->sm_rx_state == AD_RX_CURRENT))) {
+ port->sm_rx_timer_counter = 0; /* zero timer */
port->sm_rx_state = AD_RX_CURRENT;
} else {
- // if timer is on, and if it is expired
- if (port->sm_rx_timer_counter && !(--port->sm_rx_timer_counter)) {
+ /* if timer is on, and if it is expired */
+ if (port->sm_rx_timer_counter &&
+ !(--port->sm_rx_timer_counter)) {
switch (port->sm_rx_state) {
case AD_RX_EXPIRED:
- port->sm_rx_state = AD_RX_DEFAULTED; // next state
+ port->sm_rx_state = AD_RX_DEFAULTED;
break;
case AD_RX_CURRENT:
- port->sm_rx_state = AD_RX_EXPIRED; // next state
+ port->sm_rx_state = AD_RX_EXPIRED;
break;
- default: //to silence the compiler
+ default:
break;
}
} else {
- // if no lacpdu arrived and no timer is on
+ /* if no lacpdu arrived and no timer is on */
switch (port->sm_rx_state) {
case AD_RX_PORT_DISABLED:
if (port->sm_vars & AD_PORT_MOVED)
- port->sm_rx_state = AD_RX_INITIALIZE; // next state
- else if (port->is_enabled
- && (port->sm_vars
- & AD_PORT_LACP_ENABLED))
- port->sm_rx_state = AD_RX_EXPIRED; // next state
- else if (port->is_enabled
- && ((port->sm_vars
- & AD_PORT_LACP_ENABLED) == 0))
- port->sm_rx_state = AD_RX_LACP_DISABLED; // next state
+ port->sm_rx_state = AD_RX_INITIALIZE;
+ else if (port->is_enabled &&
+ (port->sm_vars &
+ AD_PORT_LACP_ENABLED))
+ port->sm_rx_state = AD_RX_EXPIRED;
+ else if (port->is_enabled &&
+ ((port->sm_vars &
+ AD_PORT_LACP_ENABLED) == 0))
+ port->sm_rx_state = AD_RX_LACP_DISABLED;
break;
- default: //to silence the compiler
+ default:
break;
}
}
}
- // check if the State machine was changed or new lacpdu arrived
+ /* check if the State machine was changed or new lacpdu arrived */
if ((port->sm_rx_state != last_state) || (lacpdu)) {
pr_debug("Rx Machine: Port=%d, Last State=%d, Curr State=%d\n",
port->actor_port_number, last_state,
@@ -1092,7 +1104,7 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
__record_default(port);
port->actor_oper_port_state &= ~AD_STATE_EXPIRED;
port->sm_vars &= ~AD_PORT_MOVED;
- port->sm_rx_state = AD_RX_PORT_DISABLED; // next state
+ port->sm_rx_state = AD_RX_PORT_DISABLED;
/*- Fall Through -*/
@@ -1107,14 +1119,20 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
port->actor_oper_port_state &= ~AD_STATE_EXPIRED;
break;
case AD_RX_EXPIRED:
- //Reset of the Synchronization flag. (Standard 43.4.12)
- //This reset cause to disable this port in the COLLECTING_DISTRIBUTING state of the
- //mux machine in case of EXPIRED even if LINK_DOWN didn't arrive for the port.
- port->partner_oper.port_state &= ~AD_STATE_SYNCHRONIZATION;
+ /* Reset of the Synchronization flag. (Standard 43.4.12)
+ * This reset cause to disable this port in the
+ * COLLECTING_DISTRIBUTING state of the mux machine
+ * in case of EXPIRED even if LINK_DOWN didn't arrive
+ * for the port.
+ */
+ port->partner_oper.port_state &=
+ ~AD_STATE_SYNCHRONIZATION;
port->sm_vars &= ~AD_PORT_MATCHED;
port->partner_oper.port_state |=
AD_STATE_LACP_ACTIVITY;
- port->sm_rx_timer_counter = __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER, (u16)(AD_SHORT_TIMEOUT));
+ port->sm_rx_timer_counter =
+ __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER,
+ (u16)(AD_SHORT_TIMEOUT));
port->actor_oper_port_state |= AD_STATE_EXPIRED;
break;
case AD_RX_DEFAULTED:
@@ -1124,12 +1142,13 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
port->actor_oper_port_state &= ~AD_STATE_EXPIRED;
break;
case AD_RX_CURRENT:
- // detect loopback situation
- if (!MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->actor_system))) {
- // INFO_RECEIVED_LOOPBACK_FRAMES
+ /* detect loopback situation */
+ if (!compare_ether_addr((const u8 *)&(lacpdu->actor_system), (const u8 *)&(port->actor_system))) {
+ /* INFO_RECEIVED_LOOPBACK_FRAMES */
pr_err("%s: An illegal loopback occurred on adapter (%s).\n"
"Check the configuration to verify that all adapters are connected to 802.3ad compliant switch ports\n",
- port->slave->dev->master->name, port->slave->dev->name);
+ port->slave->dev->master->name,
+ port->slave->dev->name);
return;
}
__update_selected(lacpdu, port);
@@ -1137,15 +1156,19 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
__record_pdu(lacpdu, port);
port->sm_rx_timer_counter = __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER, (u16)(port->actor_oper_port_state & AD_STATE_LACP_TIMEOUT));
port->actor_oper_port_state &= ~AD_STATE_EXPIRED;
- // verify that if the aggregator is enabled, the port is enabled too.
- //(because if the link goes down for a short time, the 802.3ad will not
- // catch it, and the port will continue to be disabled)
+
+ /* verify that if the aggregator is enabled,
+ * so the port is enabled too.
+ * because if the link goes down for a short time,
+ * the 802.3ad will not catch it,
+ * and the port will continue to be disabled
+ */
if (port->aggregator
&& port->aggregator->is_active
&& !__port_is_enabled(port))
__enable_port(port);
break;
- default: //to silence the compiler
+ default:
break;
}
}
@@ -1158,9 +1181,11 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
*/
static void ad_tx_machine(struct port *port)
{
- // check if tx timer expired, to verify that we do not send more than 3 packets per second
+ /* check if tx timer has expired,
+ * to verify that we do not send more than 3 packets per second
+ */
if (port->sm_tx_timer_counter && !(--port->sm_tx_timer_counter)) {
- // check if there is something to send
+ /* check if there is something to send */
if (port->ntt && (port->sm_vars & AD_PORT_LACP_ENABLED)) {
__update_lacpdu_from_port(port);
@@ -1168,14 +1193,17 @@ static void ad_tx_machine(struct port *port)
pr_debug("Sent LACPDU on port %d\n",
port->actor_port_number);
- /* mark ntt as false, so it will not be sent again until
- demanded */
+ /* mark ntt as false,
+ * so it won't be sent again until demanded
+ */
port->ntt = false;
}
}
- // restart tx timer(to verify that we will not exceed AD_MAX_TX_IN_SECOND
+ /* restart tx timer
+ * to verify that we won't exceed AD_MAX_TX_IN_SECOND
+ */
port->sm_tx_timer_counter =
- ad_ticks_per_sec/AD_MAX_TX_IN_SECOND;
+ ad_ticks_per_sec/AD_MAX_TX_IN_SECOND;
}
}
@@ -1189,76 +1217,87 @@ static void ad_periodic_machine(struct port *port)
{
periodic_states_t last_state;
- // keep current state machine state to compare later if it was changed
+ /* keep current state machine state to compare later if it was changed*/
last_state = port->sm_periodic_state;
- // check if port was reinitialized
- if (((port->sm_vars & AD_PORT_BEGIN) || !(port->sm_vars & AD_PORT_LACP_ENABLED) || !port->is_enabled) ||
- (!(port->actor_oper_port_state & AD_STATE_LACP_ACTIVITY) && !(port->partner_oper.port_state & AD_STATE_LACP_ACTIVITY))
- ) {
- port->sm_periodic_state = AD_NO_PERIODIC; // next state
+ /* check if port was reinitialized */
+ if (((port->sm_vars & AD_PORT_BEGIN) ||
+ !(port->sm_vars & AD_PORT_LACP_ENABLED) ||
+ !port->is_enabled) ||
+ (!(port->actor_oper_port_state & AD_STATE_LACP_ACTIVITY) &&
+ !(port->partner_oper.port_state & AD_STATE_LACP_ACTIVITY))) {
+ port->sm_periodic_state = AD_NO_PERIODIC; /* next state */
}
- // check if state machine should change state
+ /* check if state machine should change state */
else if (port->sm_periodic_timer_counter) {
- // check if periodic state machine expired
+ /* check if periodic state machine expired */
if (!(--port->sm_periodic_timer_counter)) {
- // if expired then do tx
- port->sm_periodic_state = AD_PERIODIC_TX; // next state
+ /* if expired then do tx, next state */
+ port->sm_periodic_state = AD_PERIODIC_TX;
} else {
- // If not expired, check if there is some new timeout parameter from the partner state
+ /* If not expired, check if there is some
+ * new timeout parameter from the partner state
+ */
switch (port->sm_periodic_state) {
case AD_FAST_PERIODIC:
if (!(port->partner_oper.port_state
& AD_STATE_LACP_TIMEOUT))
- port->sm_periodic_state = AD_SLOW_PERIODIC; // next state
+ port->sm_periodic_state = AD_SLOW_PERIODIC;
break;
case AD_SLOW_PERIODIC:
- if ((port->partner_oper.port_state & AD_STATE_LACP_TIMEOUT)) {
- // stop current timer
+ if ((port->partner_oper.port_state &
+ AD_STATE_LACP_TIMEOUT)) {
+ /* stop current timer */
port->sm_periodic_timer_counter = 0;
- port->sm_periodic_state = AD_PERIODIC_TX; // next state
+ port->sm_periodic_state = AD_PERIODIC_TX;
}
break;
- default: //to silence the compiler
+ default:
break;
}
}
} else {
switch (port->sm_periodic_state) {
case AD_NO_PERIODIC:
- port->sm_periodic_state = AD_FAST_PERIODIC; // next state
+ port->sm_periodic_state = AD_FAST_PERIODIC;
break;
case AD_PERIODIC_TX:
- if (!(port->partner_oper.port_state
- & AD_STATE_LACP_TIMEOUT))
- port->sm_periodic_state = AD_SLOW_PERIODIC; // next state
+ if (!(port->partner_oper.port_state &
+ AD_STATE_LACP_TIMEOUT))
+ port->sm_periodic_state = AD_SLOW_PERIODIC;
else
- port->sm_periodic_state = AD_FAST_PERIODIC; // next state
+ port->sm_periodic_state = AD_FAST_PERIODIC;
break;
- default: //to silence the compiler
+ default:
break;
}
}
- // check if the state machine was changed
+ /* check if the state machine was changed */
if (port->sm_periodic_state != last_state) {
pr_debug("Periodic Machine: Port=%d, Last State=%d, Curr State=%d\n",
port->actor_port_number, last_state,
port->sm_periodic_state);
switch (port->sm_periodic_state) {
case AD_NO_PERIODIC:
- port->sm_periodic_timer_counter = 0; // zero timer
+ port->sm_periodic_timer_counter = 0;
break;
case AD_FAST_PERIODIC:
- port->sm_periodic_timer_counter = __ad_timer_to_ticks(AD_PERIODIC_TIMER, (u16)(AD_FAST_PERIODIC_TIME))-1; // decrement 1 tick we lost in the PERIODIC_TX cycle
+ /* decrement 1 tick we lost in PERIODIC_TX cycle */
+ port->sm_periodic_timer_counter =
+ __ad_timer_to_ticks(AD_PERIODIC_TIMER,
+ (u16)(AD_FAST_PERIODIC_TIME))-1;
break;
case AD_SLOW_PERIODIC:
- port->sm_periodic_timer_counter = __ad_timer_to_ticks(AD_PERIODIC_TIMER, (u16)(AD_SLOW_PERIODIC_TIME))-1; // decrement 1 tick we lost in the PERIODIC_TX cycle
+ /* decrement 1 tick we lost in PERIODIC_TX cycle */
+ port->sm_periodic_timer_counter =
+ __ad_timer_to_ticks(AD_PERIODIC_TIMER,
+ (u16)(AD_SLOW_PERIODIC_TIME))-1;
break;
case AD_PERIODIC_TX:
port->ntt = true;
break;
- default: //to silence the compiler
+ default:
break;
}
}
@@ -1274,46 +1313,58 @@ static void ad_periodic_machine(struct port *port)
*/
static void ad_port_selection_logic(struct port *port)
{
- struct aggregator *aggregator, *free_aggregator = NULL, *temp_aggregator;
+ struct aggregator *aggregator, *temp_aggregator;
+ struct aggregator *free_aggregator = NULL;
struct port *last_port = NULL, *curr_port;
int found = 0;
- // if the port is already Selected, do nothing
+ /* if the port is already Selected, do nothing */
if (port->sm_vars & AD_PORT_SELECTED)
return;
- // if the port is connected to other aggregator, detach it
+ /* if the port is connected to other aggregator, detach it */
if (port->aggregator) {
- // detach the port from its former aggregator
+ /* detach the port from its former aggregator */
temp_aggregator = port->aggregator;
for (curr_port = temp_aggregator->lag_ports; curr_port;
last_port = curr_port,
curr_port = curr_port->next_port_in_aggregator) {
if (curr_port == port) {
temp_aggregator->num_of_ports--;
- if (!last_port) {// if it is the first port attached to the aggregator
+ if (!last_port) {
+ /* if it is the first port attached
+ to the aggregator */
temp_aggregator->lag_ports =
port->next_port_in_aggregator;
- } else {// not the first port attached to the aggregator
+ } else {
+ /* not the first port attached
+ to the aggregator */
last_port->next_port_in_aggregator =
port->next_port_in_aggregator;
}
- // clear the port's relations to this aggregator
+ /* clear the port's relations
+ to this aggregator */
port->aggregator = NULL;
port->next_port_in_aggregator = NULL;
port->actor_port_aggregator_identifier = 0;
pr_debug("Port %d left LAG %d\n",
- port->actor_port_number,
- temp_aggregator->aggregator_identifier);
- // if the aggregator is empty, clear its parameters, and set it ready to be attached
+ port->actor_port_number,
+ temp_aggregator->aggregator_identifier);
+ /* if the aggregator is empty,
+ * clear its parameters, and set it ready
+ * to be attached
+ */
if (!temp_aggregator->lag_ports)
ad_clear_agg(temp_aggregator);
break;
}
}
- if (!curr_port) { // meaning: the port was related to an aggregator but was not on the aggregator port list
+ if (!curr_port) {
+ /* meaning: the port was related to an aggregator
+ * but was not on the aggregator port list.
+ */
pr_warning("%s: Warning: Port %d (on %s) was related to aggregator %d but was not on its port list\n",
port->slave->dev->master->name,
port->actor_port_number,
@@ -1321,27 +1372,34 @@ static void ad_port_selection_logic(struct port *port)
port->aggregator->aggregator_identifier);
}
}
- // search on all aggregators for a suitable aggregator for this port
+ /* search on all aggregators for a suitable aggregator for this port */
for (aggregator = __get_first_agg(port); aggregator;
aggregator = __get_next_agg(aggregator)) {
- // keep a free aggregator for later use(if needed)
+ /* keep a free aggregator for later use (if needed) */
if (!aggregator->lag_ports) {
if (!free_aggregator)
free_aggregator = aggregator;
continue;
}
- // check if current aggregator suits us
- if (((aggregator->actor_oper_aggregator_key == port->actor_oper_port_key) && // if all parameters match AND
- !MAC_ADDRESS_COMPARE(&(aggregator->partner_system), &(port->partner_oper.system)) &&
+
+ /* check if current aggregator suits us
+ * a suitable aggregator must fit the following requirements,
+ * tested here:
+ * i. match all parameters;
+ * ii. has partner answers;
+ * iii. it is not individual
+ */
+ if (((aggregator->actor_oper_aggregator_key == port->actor_oper_port_key) &&
+ !compare_ether_addr((const u8 *)&(aggregator->partner_system), (const u8 *)&(port->partner_oper.system)) &&
(aggregator->partner_system_priority == port->partner_oper.system_priority) &&
(aggregator->partner_oper_aggregator_key == port->partner_oper.key)
) &&
- ((MAC_ADDRESS_COMPARE(&(port->partner_oper.system), &(null_mac_addr)) && // partner answers
- !aggregator->is_individual) // but is not individual OR
+ ((compare_ether_addr((const u8 *)&(port->partner_oper.system), (const u8 *)&(null_mac_addr)) &&
+ !aggregator->is_individual)
)
) {
- // attach to the founded aggregator
+ /* attach to the founded aggregator */
port->aggregator = aggregator;
port->actor_port_aggregator_identifier =
port->aggregator->aggregator_identifier;
@@ -1352,42 +1410,45 @@ static void ad_port_selection_logic(struct port *port)
port->actor_port_number,
port->aggregator->aggregator_identifier);
- // mark this port as selected
+ /* mark this port as selected */
port->sm_vars |= AD_PORT_SELECTED;
found = 1;
break;
}
}
- // the port couldn't find an aggregator - attach it to a new aggregator
+ /* the port couldn't find an aggregator, attach it to a new aggregator*/
if (!found) {
if (free_aggregator) {
- // assign port a new aggregator
+ /* assign port a new aggregator */
port->aggregator = free_aggregator;
port->actor_port_aggregator_identifier =
port->aggregator->aggregator_identifier;
- // update the new aggregator's parameters
- // if port was responsed from the end-user
+ /* update the new aggregator's parameters
+ if port was responsed from the end-user */
if (port->actor_oper_port_key & AD_DUPLEX_KEY_BITS)
/* if port is full duplex */
port->aggregator->is_individual = false;
else
port->aggregator->is_individual = true;
- port->aggregator->actor_admin_aggregator_key = port->actor_admin_port_key;
- port->aggregator->actor_oper_aggregator_key = port->actor_oper_port_key;
+ port->aggregator->actor_admin_aggregator_key =
+ port->actor_admin_port_key;
+ port->aggregator->actor_oper_aggregator_key =
+ port->actor_oper_port_key;
port->aggregator->partner_system =
- port->partner_oper.system;
+ port->partner_oper.system;
port->aggregator->partner_system_priority =
- port->partner_oper.system_priority;
- port->aggregator->partner_oper_aggregator_key = port->partner_oper.key;
+ port->partner_oper.system_priority;
+ port->aggregator->partner_oper_aggregator_key =
+ port->partner_oper.key;
port->aggregator->receive_state = 1;
port->aggregator->transmit_state = 1;
port->aggregator->lag_ports = port;
port->aggregator->num_of_ports++;
- // mark this port as selected
+ /* mark this port as selected */
port->sm_vars |= AD_PORT_SELECTED;
pr_debug("Port %d joined LAG %d(new LAG)\n",
@@ -1399,16 +1460,18 @@ static void ad_port_selection_logic(struct port *port)
port->actor_port_number, port->slave->dev->name);
}
}
- // if all aggregator's ports are READY_N == TRUE, set ready=TRUE in all aggregator's ports
- // else set ready=FALSE in all aggregator's ports
- __set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator));
+ /* if all aggregator's ports are READY_N == TRUE,
+ * set ready=TRUE in all aggregator's ports
+ * else set ready=FALSE in all aggregator's ports
+ */
+ __set_agg_ports_ready(port->aggregator,
+ __agg_ports_are_ready(port->aggregator));
aggregator = __get_first_agg(port);
ad_agg_selection_logic(aggregator);
}
-/*
- * Decide if "agg" is a better choice for the new active aggregator that
+/* Decide if "agg" is a better choice for the new active aggregator that
* the current best, according to the ad_select policy.
*/
static struct aggregator *ad_agg_selection_test(struct aggregator *best,
@@ -1533,16 +1596,15 @@ static void ad_agg_selection_logic(struct aggregator *agg)
if (best &&
__get_agg_selection_mode(best->lag_ports) == BOND_AD_STABLE) {
- /*
- * For the STABLE policy, don't replace the old active
- * aggregator if it's still active (it has an answering
- * partner) or if both the best and active don't have an
- * answering partner.
+
+ /* For the STABLE policy, don't replace the old active
+ * aggregator if it's still active (it has an answering partner)
+ * or if both the best and active don't have answering partners
*/
if (active && active->lag_ports &&
active->lag_ports->is_enabled &&
(__agg_has_partner(active) ||
- (!__agg_has_partner(active) && !__agg_has_partner(best)))) {
+ (!__agg_has_partner(active) && !__agg_has_partner(best)))) {
if (!(!active->actor_oper_aggregator_key &&
best->actor_oper_aggregator_key)) {
best = NULL;
@@ -1556,7 +1618,7 @@ static void ad_agg_selection_logic(struct aggregator *agg)
active->is_active = 1;
}
- // if there is new best aggregator, activate it
+ /* if there is new best aggregator, activate it */
if (best) {
pr_debug("best Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n",
best->aggregator_identifier, best->num_of_ports,
@@ -1577,7 +1639,7 @@ static void ad_agg_selection_logic(struct aggregator *agg)
agg->is_individual, agg->is_active);
}
- // check if any partner replys
+ /* check if any partner replies */
if (best->is_individual) {
pr_warning("%s: Warning: No 802.3ad response from the link partner for any adapters in the bond\n",
best->slave ? best->slave->dev->master->name : "NULL");
@@ -1592,7 +1654,9 @@ static void ad_agg_selection_logic(struct aggregator *agg)
best->partner_oper_aggregator_key,
best->is_individual, best->is_active);
- // disable the ports that were related to the former active_aggregator
+ /* disable the ports that were related to
+ * the former active_aggregator
+ */
if (active) {
for (port = active->lag_ports; port;
port = port->next_port_in_aggregator) {
@@ -1601,8 +1665,7 @@ static void ad_agg_selection_logic(struct aggregator *agg)
}
}
- /*
- * if the selected aggregator is of join individuals
+ /* if the selected aggregator is of join individuals
* (partner_system is NULL), enable their ports
*/
active = __get_active_agg(origin);
@@ -1701,8 +1764,10 @@ static void ad_initialize_port(struct port *port, int lacp_fast)
port->ntt = false;
port->actor_admin_port_key = 1;
port->actor_oper_port_key = 1;
- port->actor_admin_port_state = AD_STATE_AGGREGATION | AD_STATE_LACP_ACTIVITY;
- port->actor_oper_port_state = AD_STATE_AGGREGATION | AD_STATE_LACP_ACTIVITY;
+ port->actor_admin_port_state =
+ AD_STATE_AGGREGATION | AD_STATE_LACP_ACTIVITY;
+ port->actor_oper_port_state =
+ AD_STATE_AGGREGATION | AD_STATE_LACP_ACTIVITY;
if (lacp_fast)
port->actor_oper_port_state |= AD_STATE_LACP_TIMEOUT;
@@ -1711,7 +1776,7 @@ static void ad_initialize_port(struct port *port, int lacp_fast)
memcpy(&port->partner_oper, &tmpl, sizeof(tmpl));
port->is_enabled = true;
- // ****** private parameters ******
+ /* ****** private parameters ****** */
port->sm_vars = 0x3;
port->sm_rx_state = 0;
port->sm_rx_timer_counter = 0;
@@ -1753,7 +1818,9 @@ static void ad_enable_collecting_distributing(struct port *port)
*/
static void ad_disable_collecting_distributing(struct port *port)
{
- if (port->aggregator && MAC_ADDRESS_COMPARE(&(port->aggregator->partner_system), &(null_mac_addr))) {
+ if (port->aggregator &&
+ compare_ether_addr((const u8 *)&(port->aggregator->partner_system),
+ (const u8 *)&(null_mac_addr))) {
pr_debug("Disabling port %d(LAG %d)\n",
port->actor_port_number,
port->aggregator->aggregator_identifier);
@@ -1775,27 +1842,28 @@ static void ad_marker_info_send(struct port *port)
struct bond_marker marker;
u16 index;
- // fill the marker PDU with the appropriate values
+ /* fill the marker PDU with the appropriate values */
marker.subtype = 0x02;
marker.version_number = 0x01;
marker.tlv_type = AD_MARKER_INFORMATION_SUBTYPE;
marker.marker_length = 0x16;
- // convert requester_port to Big Endian
- marker.requester_port = (((port->actor_port_number & 0xFF) << 8) |((u16)(port->actor_port_number & 0xFF00) >> 8));
+ /* convert requester_port to Big Endian */
+ marker.requester_port = (((port->actor_port_number & 0xFF) << 8) |
+ ((u16)(port->actor_port_number & 0xFF00) >> 8));
marker.requester_system = port->actor_system;
- // convert requester_port(u32) to Big Endian
+ /* convert requester_port(u32) to Big Endian */
marker.requester_transaction_id =
- (((++port->transaction_id & 0xFF) << 24)
- | ((port->transaction_id & 0xFF00) << 8)
- | ((port->transaction_id & 0xFF0000) >> 8)
- | ((port->transaction_id & 0xFF000000) >> 24));
+ (((++port->transaction_id & 0xFF) << 24) |
+ ((port->transaction_id & 0xFF00) << 8) |
+ ((port->transaction_id & 0xFF0000) >> 8) |
+ ((port->transaction_id & 0xFF000000) >> 24));
marker.pad = 0;
marker.tlv_type_terminator = 0x00;
marker.terminator_length = 0x00;
for (index = 0; index < 90; index++)
marker.reserved_90[index] = 0;
- // send the marker information
+ /* send the marker information */
if (ad_marker_send(port, &marker) >= 0) {
pr_debug("Sent Marker Information on port %d\n",
port->actor_port_number);
@@ -1814,12 +1882,13 @@ static void ad_marker_info_received(struct bond_marker *marker_info,
{
struct bond_marker marker;
- // copy the received marker data to the response marker
- //marker = *marker_info;
+ /* copy the received marker data to the response marker
+ * marker = *marker_info;
+ */
memcpy(&marker, marker_info, sizeof(struct bond_marker));
- // change the marker subtype to marker response
+ /* change the marker subtype to marker response */
marker.tlv_type = AD_MARKER_RESPONSE_SUBTYPE;
- // send the marker response
+ /* send the marker response */
if (ad_marker_send(port, &marker) >= 0) {
pr_debug("Sent Marker Response on port %d\n",
@@ -1839,16 +1908,13 @@ static void ad_marker_info_received(struct bond_marker *marker_info,
static void ad_marker_response_received(struct bond_marker *marker,
struct port *port)
{
- marker = NULL; /* just to satisfy the compiler */
- port = NULL; /* just to satisfy the compiler */
- // DO NOTHING, SINCE WE DECIDED NOT TO IMPLEMENT THIS FEATURE FOR NOW
+ marker = NULL;
+ port = NULL;
}
-//////////////////////////////////////////////////////////////////////////////////////
-// ================= AD exported functions to the main bonding code ==================
-//////////////////////////////////////////////////////////////////////////////////////
+/* ============= AD exported functions to the main bonding code ============ */
-// Check aggregators status in team every T seconds
+/* Check aggregators status in team every T seconds */
#define AD_AGGREGATOR_SELECTION_TIMER 8
/*
@@ -1876,17 +1942,20 @@ static u16 aggregator_identifier;
*/
void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution, int lacp_fast)
{
- // check that the bond is not initialized yet
- if (MAC_ADDRESS_COMPARE(&(BOND_AD_INFO(bond).system.sys_mac_addr),
+ /* check that the bond is not initialized yet */
+ if (compare_ether_addr((const u8 *)&(BOND_AD_INFO(bond).system.sys_mac_addr),
bond->dev->dev_addr)) {
aggregator_identifier = 0;
BOND_AD_INFO(bond).lacp_fast = lacp_fast;
BOND_AD_INFO(bond).system.sys_priority = 0xFFFF;
- BOND_AD_INFO(bond).system.sys_mac_addr = *((struct mac_addr *)bond->dev->dev_addr);
+ BOND_AD_INFO(bond).system.sys_mac_addr =
+ *((struct mac_addr *)bond->dev->dev_addr);
- // initialize how many times this module is called in one second(should be about every 100ms)
+ /* initialize how many times this module is
+ * called in one second(should be about every 100ms)
+ */
ad_ticks_per_sec = tick_resolution;
bond_3ad_initiate_agg_selection(bond,
@@ -1914,31 +1983,37 @@ int bond_3ad_bind_slave(struct slave *slave)
return -1;
}
- //check that the slave has not been initialized yet.
+ /* check that the slave has not been initialized yet. */
if (SLAVE_AD_INFO(slave).port.slave != slave) {
- // port initialization
+ /* port initialization */
port = &(SLAVE_AD_INFO(slave).port);
ad_initialize_port(port, BOND_AD_INFO(bond).lacp_fast);
port->slave = slave;
port->actor_port_number = SLAVE_AD_INFO(slave).id;
- // key is determined according to the link speed, duplex and user key(which is yet not supported)
- // ------------------------------------------------------------
- // Port key : | User key | Speed |Duplex|
- // ------------------------------------------------------------
- // 16 6 1 0
- port->actor_admin_port_key = 0; // initialize this parameter
+ /* key is determined according to the link speed,
+ * duplex and user key(which is yet not supported)
+ * Port key:
+ * ------------------------------------------------------------
+ * | User key | Speed |Duplex|
+ * ------------------------------------------------------------
+ * 16 6 1 0
+ */
+ port->actor_admin_port_key = 0; /* initialize this parameter */
port->actor_admin_port_key |= __get_duplex(port);
port->actor_admin_port_key |= (__get_link_speed(port) << 1);
port->actor_oper_port_key = port->actor_admin_port_key;
- // if the port is not full duplex, then the port should be not lacp Enabled
+ /* if the port is not full duplex,
+ * then the port should be not lacp Enabled
+ */
if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_BITS))
port->sm_vars &= ~AD_PORT_LACP_ENABLED;
- // actor system is the bond's system
+ /* actor system is the bond's system */
port->actor_system = BOND_AD_INFO(bond).system.sys_mac_addr;
- // tx timer(to verify that no more than MAX_TX_IN_SECOND lacpdu's are sent in one second)
+
+ /* certify that no more than MAX_TX_IN_SECOND lacpdu sent/sec */
port->sm_tx_timer_counter = ad_ticks_per_sec/AD_MAX_TX_IN_SECOND;
port->aggregator = NULL;
port->next_port_in_aggregator = NULL;
@@ -1947,12 +2022,13 @@ int bond_3ad_bind_slave(struct slave *slave)
__initialize_port_locks(port);
- // aggregator initialization
+ /* aggregator initialization */
aggregator = &(SLAVE_AD_INFO(slave).aggregator);
ad_initialize_agg(aggregator);
- aggregator->aggregator_mac_address = *((struct mac_addr *)bond->dev->dev_addr);
+ aggregator->aggregator_mac_address =
+ *((struct mac_addr *)bond->dev->dev_addr);
aggregator->aggregator_identifier = (++aggregator_identifier);
aggregator->slave = slave;
aggregator->is_active = 0;
@@ -1976,13 +2052,13 @@ void bond_3ad_unbind_slave(struct slave *slave)
struct aggregator *aggregator, *new_aggregator, *temp_aggregator;
int select_new_active_agg = 0;
- // find the aggregator related to this slave
+ /* find the aggregator related to this slave */
aggregator = &(SLAVE_AD_INFO(slave).aggregator);
- // find the port related to this slave
+ /* find the port related to this slave */
port = &(SLAVE_AD_INFO(slave).port);
- // if slave is null, the whole port is not initialized
+ /* if slave is null, the whole port is not initialized */
if (!port->slave) {
pr_warning("Warning: %s: Trying to unbind an uninitialized port on %s\n",
slave->dev->master->name, slave->dev->name);
@@ -1997,32 +2073,43 @@ void bond_3ad_unbind_slave(struct slave *slave)
__update_lacpdu_from_port(port);
ad_lacpdu_send(port);
- // check if this aggregator is occupied
+ /* check if this aggregator is occupied */
if (aggregator->lag_ports) {
- // check if there are other ports related to this aggregator except
- // the port related to this slave(thats ensure us that there is a
- // reason to search for new aggregator, and that we will find one
- if ((aggregator->lag_ports != port) || (aggregator->lag_ports->next_port_in_aggregator)) {
- // find new aggregator for the related port(s)
+ /* check if there are other ports related to this aggregator
+ * except the port related to this slave
+ * (it ensures us that there is a reason to search for
+ * new aggregator, and that we will find one)
+ */
+ if ((aggregator->lag_ports != port) ||
+ (aggregator->lag_ports->next_port_in_aggregator)) {
+ /* find new aggregator for the related port(s) */
new_aggregator = __get_first_agg(port);
- for (; new_aggregator; new_aggregator = __get_next_agg(new_aggregator)) {
- // if the new aggregator is empty, or it is connected to our port only
- if (!new_aggregator->lag_ports
- || ((new_aggregator->lag_ports == port)
- && !new_aggregator->lag_ports->next_port_in_aggregator))
+ for (; new_aggregator;
+ new_aggregator = __get_next_agg(new_aggregator)) {
+ /* if the new aggregator is empty,
+ or it is connected to our port only */
+ if (!new_aggregator->lag_ports ||
+ ((new_aggregator->lag_ports == port) &&
+ !new_aggregator->lag_ports->next_port_in_aggregator))
break;
}
- // if new aggregator found, copy the aggregator's parameters
- // and connect the related lag_ports to the new aggregator
- if ((new_aggregator) && ((!new_aggregator->lag_ports) || ((new_aggregator->lag_ports == port) && !new_aggregator->lag_ports->next_port_in_aggregator))) {
+ /* if new aggregator found, copy the aggregator's
+ * parameters and connect the related lag_ports to the
+ * new aggregator
+ */
+ if ((new_aggregator) &&
+ ((!new_aggregator->lag_ports) ||
+ ((new_aggregator->lag_ports == port) &&
+ !new_aggregator->lag_ports->next_port_in_aggregator))) {
pr_debug("Some port(s) related to LAG %d - replacing with LAG %d\n",
aggregator->aggregator_identifier,
new_aggregator->aggregator_identifier);
- if ((new_aggregator->lag_ports == port) && new_aggregator->is_active) {
+ if ((new_aggregator->lag_ports == port) &&
+ new_aggregator->is_active) {
pr_info("%s: Removing an active aggregator\n",
aggregator->slave->dev->master->name);
- // select new active aggregator
+ /* select new active aggregator */
select_new_active_agg = 1;
}
@@ -2038,14 +2125,15 @@ void bond_3ad_unbind_slave(struct slave *slave)
new_aggregator->is_active = aggregator->is_active;
new_aggregator->num_of_ports = aggregator->num_of_ports;
- // update the information that is written on the ports about the aggregator
- for (temp_port = aggregator->lag_ports; temp_port;
- temp_port = temp_port->next_port_in_aggregator) {
+ /* update the information that is written on
+ * the ports about the aggregator
+ */
+ for (temp_port = aggregator->lag_ports; temp_port; temp_port = temp_port->next_port_in_aggregator) {
temp_port->aggregator = new_aggregator;
temp_port->actor_port_aggregator_identifier = new_aggregator->aggregator_identifier;
}
- // clear the aggregator
+ /* clear the aggregator */
ad_clear_agg(aggregator);
if (select_new_active_agg)
@@ -2054,42 +2142,50 @@ void bond_3ad_unbind_slave(struct slave *slave)
pr_warning("%s: Warning: unbinding aggregator, and could not find a new aggregator for its ports\n",
slave->dev->master->name);
}
- } else { // in case that the only port related to this aggregator is the one we want to remove
+ } else {
+ /* in case that the only port related to this
+ * aggregator is the one we want to remove
+ */
select_new_active_agg = aggregator->is_active;
- // clear the aggregator
+ /* clear the aggregator */
ad_clear_agg(aggregator);
if (select_new_active_agg) {
pr_info("%s: Removing an active aggregator\n",
slave->dev->master->name);
- // select new active aggregator
+ /* select new active aggregator */
ad_agg_selection_logic(__get_first_agg(port));
}
}
}
pr_debug("Unbinding port %d\n", port->actor_port_number);
- // find the aggregator that this port is connected to
+ /* find the aggregator that this port is connected to */
temp_aggregator = __get_first_agg(port);
- for (; temp_aggregator; temp_aggregator = __get_next_agg(temp_aggregator)) {
+ for (; temp_aggregator;
+ temp_aggregator = __get_next_agg(temp_aggregator)) {
prev_port = NULL;
- // search the port in the aggregator's related ports
+ /* search the port in the aggregator's related ports */
for (temp_port = temp_aggregator->lag_ports; temp_port;
prev_port = temp_port,
temp_port = temp_port->next_port_in_aggregator) {
- if (temp_port == port) { // the aggregator found - detach the port from this aggregator
+ if (temp_port == port) {
+ /* the aggregator found
+ detach the port from this aggregator */
if (prev_port)
- prev_port->next_port_in_aggregator = temp_port->next_port_in_aggregator;
+ prev_port->next_port_in_aggregator =
+ temp_port->next_port_in_aggregator;
else
- temp_aggregator->lag_ports = temp_port->next_port_in_aggregator;
+ temp_aggregator->lag_ports =
+ temp_port->next_port_in_aggregator;
temp_aggregator->num_of_ports--;
if (temp_aggregator->num_of_ports == 0) {
select_new_active_agg = temp_aggregator->is_active;
- // clear the aggregator
+ /* clear the aggregator */
ad_clear_agg(temp_aggregator);
if (select_new_active_agg) {
pr_info("%s: Removing an active aggregator\n",
slave->dev->master->name);
- // select new active aggregator
+ /* select new active aggreg */
ad_agg_selection_logic(__get_first_agg(port));
}
}
@@ -2125,13 +2221,14 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
if (bond->kill_timers)
goto out;
- //check if there are any slaves
+ /* check if there are any slaves */
if (bond->slave_cnt == 0)
goto re_arm;
- // check if agg_select_timer timer after initialize is timed out
- if (BOND_AD_INFO(bond).agg_select_timer && !(--BOND_AD_INFO(bond).agg_select_timer)) {
- // select the active aggregator for the bond
+ /* check if agg_select_timer timer after initialize is timed out */
+ if (BOND_AD_INFO(bond).agg_select_timer &&
+ !(--BOND_AD_INFO(bond).agg_select_timer)) {
+ /* select the active aggregator for the bond */
if ((port = __get_first_port(bond))) {
if (!port->slave) {
pr_warning("%s: Warning: bond's first port is uninitialized\n",
@@ -2145,17 +2242,18 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
bond_3ad_set_carrier(bond);
}
- // for each port run the state machines
- for (port = __get_first_port(bond); port; port = __get_next_port(port)) {
+ /* for each port run the state machines */
+ for (port = __get_first_port(bond); port;
+ port = __get_next_port(port)) {
if (!port->slave) {
pr_warning("%s: Warning: Found an uninitialized port\n",
bond->dev->name);
goto re_arm;
}
- /* Lock around state machines to protect data accessed
- * by all (e.g., port->sm_vars). ad_rx_machine may run
- * concurrently due to incoming LACPDU.
+ /* Lock around state machines to protect data accessed by all
+ * (e.g., port->sm_vars).
+ * ad_rx_machine may run concurrently due to incoming LACPDU.
*/
__get_state_machine_lock(port);
@@ -2165,7 +2263,7 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
ad_mux_machine(port);
ad_tx_machine(port);
- // turn off the BEGIN bit, since we already handled it
+ /* turn off the BEGIN bit, since we already handled it */
if (port->sm_vars & AD_PORT_BEGIN)
port->sm_vars &= ~AD_PORT_BEGIN;
@@ -2198,7 +2296,8 @@ static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u
if (!port->slave) {
pr_warning("%s: Warning: port of slave %s is uninitialized\n",
- slave->dev->name, slave->dev->master->name);
+ slave->dev->name,
+ slave->dev->master->name);
return;
}
@@ -2213,7 +2312,9 @@ static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u
break;
case AD_TYPE_MARKER:
- // No need to convert fields to Little Endian since we don't use the marker's fields.
+ /* No need to convert fields to Little Endian
+ * since we don't use the marker's fields.
+ */
switch (((struct bond_marker *)lacpdu)->tlv_type) {
case AD_MARKER_INFORMATION_SUBTYPE:
@@ -2248,19 +2349,22 @@ void bond_3ad_adapter_speed_changed(struct slave *slave)
port = &(SLAVE_AD_INFO(slave).port);
- // if slave is null, the whole port is not initialized
+ /* if slave is null, the whole port is not initialized */
if (!port->slave) {
pr_warning("Warning: %s: speed changed for uninitialized port on %s\n",
- slave->dev->master->name, slave->dev->name);
+ slave->dev->master->name,
+ slave->dev->name);
return;
}
port->actor_admin_port_key &= ~AD_SPEED_KEY_BITS;
port->actor_oper_port_key = port->actor_admin_port_key |=
(__get_link_speed(port) << 1);
+
pr_debug("Port %d changed speed\n", port->actor_port_number);
- // there is no need to reselect a new aggregator, just signal the
- // state machines to reinitialize
+ /* there is no need to reselect a new aggregator,
+ * just signal the state machines to reinitialize
+ */
port->sm_vars |= AD_PORT_BEGIN;
}
@@ -2276,19 +2380,22 @@ void bond_3ad_adapter_duplex_changed(struct slave *slave)
port = &(SLAVE_AD_INFO(slave).port);
- // if slave is null, the whole port is not initialized
+ /* if slave is null, the whole port is not initialized */
if (!port->slave) {
pr_warning("%s: Warning: duplex changed for uninitialized port on %s\n",
- slave->dev->master->name, slave->dev->name);
+ slave->dev->master->name,
+ slave->dev->name);
return;
}
port->actor_admin_port_key &= ~AD_DUPLEX_KEY_BITS;
port->actor_oper_port_key = port->actor_admin_port_key |=
__get_duplex(port);
+
pr_debug("Port %d changed duplex\n", port->actor_port_number);
- // there is no need to reselect a new aggregator, just signal the
- // state machines to reinitialize
+ /* there is no need to reselect a new aggregator,
+ * just signal the state machines to reinitialize
+ */
port->sm_vars |= AD_PORT_BEGIN;
}
@@ -2305,15 +2412,19 @@ void bond_3ad_handle_link_change(struct slave *slave, char link)
port = &(SLAVE_AD_INFO(slave).port);
- // if slave is null, the whole port is not initialized
+ /* if slave is null, the whole port is not initialized */
if (!port->slave) {
pr_warning("Warning: %s: link status changed for uninitialized port on %s\n",
- slave->dev->master->name, slave->dev->name);
+ slave->dev->master->name,
+ slave->dev->name);
return;
}
- // on link down we are zeroing duplex and speed since some of the adaptors(ce1000.lan) report full duplex/speed instead of N/A(duplex) / 0(speed)
- // on link up we are forcing recheck on the duplex and speed since some of he adaptors(ce1000.lan) report
+ /* on link down we are zeroing duplex and speed
+ * since some of the adaptors (ce1000.lan) report full duplex/speed
+ * instead of N/A (duplex) / 0(speed)
+ * on link up we are forcing recheck on the duplex and speed
+ */
if (link == BOND_LINK_UP) {
port->is_enabled = true;
port->actor_admin_port_key &= ~AD_DUPLEX_KEY_BITS;
@@ -2329,9 +2440,15 @@ void bond_3ad_handle_link_change(struct slave *slave, char link)
port->actor_oper_port_key = (port->actor_admin_port_key &=
~AD_SPEED_KEY_BITS);
}
- //BOND_PRINT_DBG(("Port %d changed link status to %s", port->actor_port_number, ((link == BOND_LINK_UP)?"UP":"DOWN")));
- // there is no need to reselect a new aggregator, just signal the
- // state machines to reinitialize
+
+ /* BOND_PRINT_DBG(("Port %d changed link status to %s",
+ * port->actor_port_number,
+ * ((link == BOND_LINK_UP)?"UP":"DOWN")));
+ */
+
+ /* there is no need to reselect a new aggregator,
+ * just signal the state machines to reinitialize
+ */
port->sm_vars |= AD_PORT_BEGIN;
}
@@ -2387,7 +2504,8 @@ int bond_3ad_get_active_agg_info(struct bonding *bond, struct ad_info *ad_info)
ad_info->ports = aggregator->num_of_ports;
ad_info->actor_key = aggregator->actor_oper_aggregator_key;
ad_info->partner_key = aggregator->partner_oper_aggregator_key;
- memcpy(ad_info->partner_system, aggregator->partner_system.mac_addr_value, ETH_ALEN);
+ memcpy(ad_info->partner_system,
+ aggregator->partner_system.mac_addr_value, ETH_ALEN);
return 0;
}
@@ -2405,9 +2523,7 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
struct ad_info ad_info;
int res = 1;
- /* make sure that the slaves list will
- * not change during tx
- */
+ /* make sure that the slaves list will not change during tx */
read_lock(&bond->lock);
if (!BOND_IS_OK(bond))
@@ -2442,7 +2558,7 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
if (slave_agg_no >= 0) {
pr_err("%s: Error: Couldn't find a slave to tx on for aggregator ID %d\n",
- dev->name, agg_id);
+ dev->name, agg_id);
goto out;
}
diff --git a/drivers/net/bonding/bond_3ad.h b/drivers/net/bonding/bond_3ad.h
index b28baff..83b0961 100644
--- a/drivers/net/bonding/bond_3ad.h
+++ b/drivers/net/bonding/bond_3ad.h
@@ -28,7 +28,7 @@
#include <linux/netdevice.h>
#include <linux/if_ether.h>
-// General definitions
+/* General definitions */
#define PKT_TYPE_LACPDU cpu_to_be16(ETH_P_SLOW)
#define AD_TIMER_INTERVAL 100 /*msec*/
@@ -47,54 +47,54 @@ enum {
BOND_AD_COUNT = 2,
};
-// rx machine states(43.4.11 in the 802.3ad standard)
+/* rx machine states (43.4.11 in the 802.3ad standard) */
typedef enum {
AD_RX_DUMMY,
- AD_RX_INITIALIZE, // rx Machine
- AD_RX_PORT_DISABLED, // rx Machine
- AD_RX_LACP_DISABLED, // rx Machine
- AD_RX_EXPIRED, // rx Machine
- AD_RX_DEFAULTED, // rx Machine
- AD_RX_CURRENT // rx Machine
+ AD_RX_INITIALIZE,
+ AD_RX_PORT_DISABLED,
+ AD_RX_LACP_DISABLED,
+ AD_RX_EXPIRED,
+ AD_RX_DEFAULTED,
+ AD_RX_CURRENT
} rx_states_t;
-// periodic machine states(43.4.12 in the 802.3ad standard)
+/* periodic machine states (43.4.12 in the 802.3ad standard) */
typedef enum {
AD_PERIODIC_DUMMY,
- AD_NO_PERIODIC, // periodic machine
- AD_FAST_PERIODIC, // periodic machine
- AD_SLOW_PERIODIC, // periodic machine
- AD_PERIODIC_TX // periodic machine
+ AD_NO_PERIODIC,
+ AD_FAST_PERIODIC,
+ AD_SLOW_PERIODIC,
+ AD_PERIODIC_TX
} periodic_states_t;
-// mux machine states(43.4.13 in the 802.3ad standard)
+/* mux machine states (43.4.13 in the 802.3ad standard) */
typedef enum {
AD_MUX_DUMMY,
- AD_MUX_DETACHED, // mux machine
- AD_MUX_WAITING, // mux machine
- AD_MUX_ATTACHED, // mux machine
- AD_MUX_COLLECTING_DISTRIBUTING // mux machine
+ AD_MUX_DETACHED,
+ AD_MUX_WAITING,
+ AD_MUX_ATTACHED,
+ AD_MUX_COLLECTING_DISTRIBUTING
} mux_states_t;
-// tx machine states(43.4.15 in the 802.3ad standard)
+/* tx machine states (43.4.15 in the 802.3ad standard) */
typedef enum {
AD_TX_DUMMY,
- AD_TRANSMIT // tx Machine
+ AD_TRANSMIT
} tx_states_t;
-// rx indication types
+/* rx indication types */
typedef enum {
- AD_TYPE_LACPDU = 1, // type lacpdu
- AD_TYPE_MARKER // type marker
+ AD_TYPE_LACPDU = 1,
+ AD_TYPE_MARKER
} pdu_type_t;
-// rx marker indication types
+/* rx marker indication types */
typedef enum {
- AD_MARKER_INFORMATION_SUBTYPE = 1, // marker imformation subtype
- AD_MARKER_RESPONSE_SUBTYPE // marker response subtype
+ AD_MARKER_INFORMATION_SUBTYPE = 1,
+ AD_MARKER_RESPONSE_SUBTYPE
} bond_marker_subtype_t;
-// timers types(43.4.9 in the 802.3ad standard)
+/* timers types (43.4.9 in the 802.3ad standard) */
typedef enum {
AD_CURRENT_WHILE_TIMER,
AD_ACTOR_CHURN_TIMER,
@@ -105,35 +105,37 @@ typedef enum {
#pragma pack(1)
-// Link Aggregation Control Protocol(LACP) data unit structure(43.4.2.2 in the 802.3ad standard)
+/* Link Aggregation Control Protocol (LACP) data unit structure
+ * (43.4.2.2 in the 802.3ad standard)
+ */
typedef struct lacpdu {
- u8 subtype; // = LACP(= 0x01)
+ u8 subtype; /* = LACP(= 0x01) */
u8 version_number;
- u8 tlv_type_actor_info; // = actor information(type/length/value)
- u8 actor_information_length; // = 20
+ u8 tlv_type_actor_info; /* = actor info(type/length/value)*/
+ u8 actor_information_length; /* = 20 */
__be16 actor_system_priority;
struct mac_addr actor_system;
__be16 actor_key;
__be16 actor_port_priority;
__be16 actor_port;
u8 actor_state;
- u8 reserved_3_1[3]; // = 0
- u8 tlv_type_partner_info; // = partner information
- u8 partner_information_length; // = 20
+ u8 reserved_3_1[3]; /* = 0 */
+ u8 tlv_type_partner_info; /* = partner information */
+ u8 partner_information_length; /* = 20 */
__be16 partner_system_priority;
struct mac_addr partner_system;
__be16 partner_key;
__be16 partner_port_priority;
__be16 partner_port;
u8 partner_state;
- u8 reserved_3_2[3]; // = 0
- u8 tlv_type_collector_info; // = collector information
- u8 collector_information_length; // = 16
+ u8 reserved_3_2[3]; /* = 0 */
+ u8 tlv_type_collector_info; /* = collector information */
+ u8 collector_information_length; /* = 16 */
__be16 collector_max_delay;
u8 reserved_12[12];
- u8 tlv_type_terminator; // = terminator
- u8 terminator_length; // = 0
- u8 reserved_50[50]; // = 0
+ u8 tlv_type_terminator; /* = terminator */
+ u8 terminator_length; /* = 0 */
+ u8 reserved_50[50]; /* = 0 */
} lacpdu_t;
typedef struct lacpdu_header {
@@ -141,20 +143,22 @@ typedef struct lacpdu_header {
struct lacpdu lacpdu;
} lacpdu_header_t;
-// Marker Protocol Data Unit(PDU) structure(43.5.3.2 in the 802.3ad standard)
+/* Marker Protocol Data Unit(PDU) structure
+ * (43.5.3.2 in the 802.3ad standard)
+ */
typedef struct bond_marker {
- u8 subtype; // = 0x02 (marker PDU)
- u8 version_number; // = 0x01
- u8 tlv_type; // = 0x01 (marker information)
- // = 0x02 (marker response information)
- u8 marker_length; // = 0x16
- u16 requester_port; // The number assigned to the port by the requester
- struct mac_addr requester_system; // The requester's system id
- u32 requester_transaction_id; // The transaction id allocated by the requester,
- u16 pad; // = 0
- u8 tlv_type_terminator; // = 0x00
- u8 terminator_length; // = 0x00
- u8 reserved_90[90]; // = 0
+ u8 subtype; /* = 0x02 (marker PDU) */
+ u8 version_number; /* = 0x01 */
+ u8 tlv_type; /* = 0x01 (marker information)
+ * = 0x02 (marker response info */
+ u8 marker_length; /* = 0x16 */
+ u16 requester_port;
+ struct mac_addr requester_system; /* The requester's system id */
+ u32 requester_transaction_id;
+ u16 pad; /* = 0 */
+ u8 tlv_type_terminator; /* = 0x00 */
+ u8 terminator_length; /* = 0x00 */
+ u8 reserved_90[90]; /* = 0 */
} bond_marker_t;
typedef struct bond_marker_header {
@@ -173,7 +177,7 @@ struct port;
#pragma pack(8)
#endif
-// aggregator structure(43.4.5 in the 802.3ad standard)
+/* aggregator structure (43.4.5 in the 802.3ad standard) */
typedef struct aggregator {
struct mac_addr aggregator_mac_address;
u16 aggregator_identifier;
@@ -183,12 +187,13 @@ typedef struct aggregator {
struct mac_addr partner_system;
u16 partner_system_priority;
u16 partner_oper_aggregator_key;
- u16 receive_state; // BOOLEAN
- u16 transmit_state; // BOOLEAN
+ u16 receive_state; /* BOOLEAN */
+ u16 transmit_state; /* BOOLEAN */
struct port *lag_ports;
- // ****** PRIVATE PARAMETERS ******
- struct slave *slave; // pointer to the bond slave that this aggregator belongs to
- u16 is_active; // BOOLEAN. Indicates if this aggregator is active
+ /* ****** PRIVATE PARAMETERS ****** */
+ struct slave *slave; /* pointer to the bond slave
+ that this aggregator belongs to */
+ u16 is_active; /* BOOLEAN. Indicates if the aggregator is active*/
u16 num_of_ports;
} aggregator_t;
@@ -201,12 +206,18 @@ struct port_params {
u16 port_state;
};
-// port structure(43.4.6 in the 802.3ad standard)
+/* port structure (43.4.6 in the 802.3ad standard) */
typedef struct port {
u16 actor_port_number;
u16 actor_port_priority;
- struct mac_addr actor_system; // This parameter is added here although it is not specified in the standard, just for simplification
- u16 actor_system_priority; // This parameter is added here although it is not specified in the standard, just for simplification
+
+ /* in a attempt to simplify operations the
+ * following two elements were included here
+ * despite they are not specified in the standard
+ */
+ struct mac_addr actor_system;
+ u16 actor_system_priority;
+
u16 actor_port_aggregator_identifier;
bool ntt;
u16 actor_admin_port_key;
@@ -219,21 +230,21 @@ typedef struct port {
bool is_enabled;
- // ****** PRIVATE PARAMETERS ******
- u16 sm_vars; // all state machines variables for this port
- rx_states_t sm_rx_state; // state machine rx state
- u16 sm_rx_timer_counter; // state machine rx timer counter
- periodic_states_t sm_periodic_state;// state machine periodic state
- u16 sm_periodic_timer_counter; // state machine periodic timer counter
- mux_states_t sm_mux_state; // state machine mux state
- u16 sm_mux_timer_counter; // state machine mux timer counter
- tx_states_t sm_tx_state; // state machine tx state
- u16 sm_tx_timer_counter; // state machine tx timer counter(allways on - enter to transmit state 3 time per second)
- struct slave *slave; // pointer to the bond slave that this port belongs to
- struct aggregator *aggregator; // pointer to an aggregator that this port related to
- struct port *next_port_in_aggregator; // Next port on the linked list of the parent aggregator
- u32 transaction_id; // continuous number for identification of Marker PDU's;
- struct lacpdu lacpdu; // the lacpdu that will be sent for this port
+ /* ****** PRIVATE PARAMETERS ****** */
+ u16 sm_vars;
+ rx_states_t sm_rx_state;
+ u16 sm_rx_timer_counter;
+ periodic_states_t sm_periodic_state;
+ u16 sm_periodic_timer_counter;
+ mux_states_t sm_mux_state;
+ u16 sm_mux_timer_counter;
+ tx_states_t sm_tx_state;
+ u16 sm_tx_timer_counter;
+ struct slave *slave;
+ struct aggregator *aggregator;
+ struct port *next_port_in_aggregator;
+ u32 transaction_id;
+ struct lacpdu lacpdu;
} port_t;
// system structure
@@ -246,41 +257,41 @@ struct ad_system {
#pragma pack()
#endif
-// ================= AD Exported structures to the main bonding code ==================
+/* =========== AD Exported structures to the main bonding code ============ */
#define BOND_AD_INFO(bond) ((bond)->ad_info)
#define SLAVE_AD_INFO(slave) ((slave)->ad_info)
struct ad_bond_info {
struct ad_system system; /* 802.3ad system structure */
- u32 agg_select_timer; // Timer to select aggregator after all adapter's hand shakes
- u32 agg_select_mode; // Mode of selection of active aggregator(bandwidth/count)
- int lacp_fast; /* whether fast periodic tx should be
- * requested
- */
+ u32 agg_select_timer; /* aggregator's selected timer */
+ u32 agg_select_mode; /* aggregator's selected mode */
+ int lacp_fast;
struct timer_list ad_timer;
struct packet_type ad_pkt_type;
};
struct ad_slave_info {
- struct aggregator aggregator; // 802.3ad aggregator structure
- struct port port; // 802.3ad port structure
- spinlock_t state_machine_lock; /* mutex state machines vs.
- incoming LACPDU */
+ struct aggregator aggregator; /* 802.3ad aggregator structure */
+ struct port port; /* 802.3ad port structure */
+ spinlock_t state_machine_lock; /* mutex state machines vs.
+ * incoming LACPDU */
u16 id;
};
-// ================= AD Exported functions to the main bonding code ==================
-void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution, int lacp_fast);
-int bond_3ad_bind_slave(struct slave *slave);
+/* ========= AD Exported functions to the main bonding code ========== */
+void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution,
+ int lacp_fast);
+int bond_3ad_bind_slave(struct slave *slave);
void bond_3ad_unbind_slave(struct slave *slave);
void bond_3ad_state_machine_handler(struct work_struct *);
void bond_3ad_initiate_agg_selection(struct bonding *bond, int timeout);
void bond_3ad_adapter_speed_changed(struct slave *slave);
void bond_3ad_adapter_duplex_changed(struct slave *slave);
void bond_3ad_handle_link_change(struct slave *slave, char link);
-int bond_3ad_get_active_agg_info(struct bonding *bond, struct ad_info *ad_info);
+int bond_3ad_get_active_agg_info(struct bonding *bond, struct ad_info *ad_info);
int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev);
-int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type* ptype, struct net_device *orig_dev);
+int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev,
+ struct packet_type* ptype, struct net_device *orig_dev);
int bond_3ad_set_carrier(struct bonding *bond);
#endif //__BOND_3AD_H__
--
1.7.4.4
--
Rafael Aquini <aquini@linux.com>
^ permalink raw reply related
* [RFC v2] virtio: add virtio-over-PCI driver
From: Kushwaha Prabhakar-B32579 @ 2011-05-06 12:00 UTC (permalink / raw)
To: iws@ovro.caltech.edu
Cc: Zang Roy-R61911, Gala Kumar-B11780, Gupta Maneesh-B18878,
Aggrwal Poonam-B10812, Kalra Ashish-B00888,
linux-kernel@vger.kernel.org, linuxppc-dev@ozlabs.org,
netdev@vger.kernel.org
Hi,
I want to use this patch as base patch for "FSL 85xx platform" to support PCIe Agent.
The work looks to be little old now. So wanted to understand if any development has happened further on it.
In case no, I would take this work forward for PCIe Agent.
Any help/suggestions are most appreciated in this regard.
Thanks,
Prabhakar
-----Original Message-----
From: linux-kernel-owner@vger.kernel.org [mailto:linux-kernel-owner@vger.kernel.org] On Behalf Of Ira Snyder
Sent: Friday, 27 February, 2009 3:19 AM
To: Arnd Bergmann
Cc: linux-kernel@vger.kernel.org; Rusty Russell; Jan-Bernd Themann; linuxppc-dev@ozlabs.org; netdev@vger.kernel.org
Subject: Re: [RFC v2] virtio: add virtio-over-PCI driver
On Thu, Feb 26, 2009 at 09:37:14PM +0100, Arnd Bergmann wrote:
> On Thursday 26 February 2009, Ira Snyder wrote:
> > On Thu, Feb 26, 2009 at 05:15:27PM +0100, Arnd Bergmann wrote:
> >
> > I think so too. I was just getting something working, and thought it
> > would be better to have it "out there" rather than be working on it
> > forever. I'll try to break things up as I have time.
>
> Ok, perfect!
>
> > For the "libraries", would you suggest breaking things into seperate
> > code files, and using EXPORT_SYMBOL_GPL()? I'm not very familiar
> > with doing that, I've mostly been writing code within the existing
> > device driver frameworks. Or do I need export symbol at all? I'm not sure...
>
> You have both options. When you list each file as a separate module in
> the Makefile, you use EXPORT_SYMBOL_GPL to mark functions that get
> called by dependent modules, but this will work only in one way.
>
> You can also link multiple files together into one module, although it
> is less common to link a single source file into multiple modules.
>
Ok. I'm more familiar with the EXPORT_SYMBOL_GPL interface, so I'll do that. If we decide it sucks later, we'll change it.
> > I always thought you were supposed to use packed for data structures
> > that are external to the system. I purposely designed the structures
> > so they wouldn't need padding.
>
> That would only make sense for structures that are explicitly
> unaligned, like a register layout using
>
> struct my_registers {
> __le16 first;
> __le32 second __attribute__((packed));
> __le16 third;
> };
>
> Even here, I'd recommend listing the individual members as packed
> rather than the entire struct. Obviously if you layout the members in
> a sane way, you don't need either.
>
Ok. I'll drop the __attribute__((packed)) and make sure there aren't problems. I don't suspect any, though.
> > I mostly don't need it. In fact, the only place I'm using registers
> > not specific to the messaging unit is in the probe routine, where I
> > setup the 1GB window into host memory and setting up access to the
> > guest memory on the PCI bus.
>
> You could add the registers you need for this to the "reg" property of
> your device, to be mapped with of_iomap.
>
> If the registers for setting up this window don't logically fit into
> the same device as the one you already use, the cleanest solution
> would be to have another device just for this and then make a function
> call into that driver to set up the window.
>
The registers are part of the board control registers. They don't fit at all in the message unit. Doing this in the bootloader seems like a logical place, but that would require any testers to flash a new U-Boot image into their mpc8349emds boards.
The first set of access is used to set up a 1GB region in the memory map that accesses the host's memory. Any reads/writes to addresses 0x80000000-0xc0000000 actually hit the host's memory.
The last access sets up PCI BAR1 to hit the memory from dma_alloc_coherent(). The bootloader already sets up the window as 16K, it just doesn't point it anywhere. Maybe this /should/ go into the bootloader. Like above, it would require testers to flash a new U-Boot image into their mpc8349emds boards.
> > Now, I wouldn't need to access these registers at all if the
> > bootloader could handle it. I just don't know if it is possible to
> > have Linux not use some memory that the bootloader allocated, other
> > than with the mem=XXX trick, which I'm sure wouldn't be acceptable.
> > I've just used regular RAM so this is portable to my custom board
> > (mpc8349emds based) and a regular mpc8349emds. I didn't want to
> > change anything board specific.
> >
> > I would love to have the bootloader allocate (or reserve somewhere
> > in the memory map) 16K of RAM, and not be required to allocate it
> > with dma_alloc_coherent(). It would save me plenty of headaches.
>
> I believe you can do that through the "memory" devices in the device
> tree, by leaving out a small part of the description of main memory,
> at putting it into the "reg" property of your own device.
>
I'll explore this option. I didn't even know you could do this. Is a driver that requires the trick acceptable for mainline inclusion? Just like setting up the 16K PCI window, this is very platform specific.
This limits the guest driver to systems which are able to change Linux's view of their memory somehow. Maybe this isn't a problem.
> > Code complexity only. Also, it was easier to write 80-char lines
> > with something like:
> >
> > vop_get_desc(vq, idx, &desc);
> > if (desc.flags & VOP_DESC_F_NEXT) {
> > /* do something */
> > }
> >
> > Instead of:
> > if (le16_to_cpu(vq->desc[idx].flags) & VOP_DESC_F_NEXT) {
> > /* do something */
> > }
> >
> > Plus, I didn't have to remember how many bits were in each field. I
> > just thought it made everything simpler to understand. Suggestions?
>
> hmm, in this particular case, you could change the definition of
> VOP_DESC_F_NEXT to
>
> #define VOP_DESC_F_NEXT cpu_to_le16(1)
>
> and then do the code as the even simpler (source and object code wise)
>
> if (vq->desc[idx].flags) & VOP_DESC_F_NEXT)
>
> I'm not sure if you can do something along these lines for the other
> cases as well though.
>
That's a good idea. It wouldn't fix the addresses, lengths, and next fields, though. I'll make the change and see how bad it is, then report back. It may not be so bad after all.
> > I used 3 so they would would align to 1024 byte boundaries within a
> > 4K page. Then the layout was 16K on the bus, each 4K page is a
> > single virtio-device, and each 1K block is a single virtqueue. The
> > first 1K is for virtio-device status and feature bits, etc.
> >
> > Packing them differently isn't a problem. It was just easier to code
> > because setting up a window with the correct size is so platform
> > specific.
>
> Ok. I guess the important question is what part of the code makes this
> decision. Ideally, the virtio-net glue would instantiate the device
> with the right number of queues.
>
Yeah, virtio doesn't work that way.
The virtio drivers just call find_vq() with a different index for each queue they want to use. You have no way of knowing how many queues each virtio driver will want, unless you go read their source code.
virtio-net currently uses 3 queues, but we only support the first two.
The third is optional (for now...), and non-symmetric.
Thanks again,
Ira
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply
* Award center Unit
From: cesconte @ 2011-05-06 12:10 UTC (permalink / raw)
Your E-mail ID qualify you for a lump sum of 1.200,000,00 Pounds in the Royal Dutch Online Programm.Send
your: Names,Country,Sex,Tel,Occupation
^ permalink raw reply
* [PATCH 1/2] PCH_GbE : Fixed the issue of collision detection
From: Toshiharu Okada @ 2011-05-06 12:53 UTC (permalink / raw)
To: ML netdev, David S. Miller
Cc: Tomoya Morinaga, LKML, Wang, Qi, Wang, Yong Y, Andrew, Intel OTC,
Ewe, Kok Howg
The collision detection setting was invalid.
When collision occurred, because data was not resenr,
there was an issue to which a transmitting throughput falls.
This patch enables the collision detection.
Signed-off-by: Toshiharu Okada <toshiharu-linux@dsn.okisemi.com>
---
drivers/net/pch_gbe/pch_gbe_main.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/drivers/net/pch_gbe/pch_gbe_main.c b/drivers/net/pch_gbe/pch_gbe_main.c
index 8300f64..babe663 100644
--- a/drivers/net/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/pch_gbe/pch_gbe_main.c
@@ -43,8 +43,7 @@ const char pch_driver_version[] = DRV_VERSION;
#define PCH_GBE_MAC_RGMII_CTRL_SETTING ( \
PCH_GBE_CHIP_TYPE_INTERNAL | \
- PCH_GBE_RGMII_MODE_RGMII | \
- PCH_GBE_CRS_SEL \
+ PCH_GBE_RGMII_MODE_RGMII \
)
/* Ethertype field values */
--
1.6.2.5
^ permalink raw reply related
* [PATCH 2/2] PCH_GbE : Fixed the issue of checksum judgment
From: Toshiharu Okada @ 2011-05-06 12:53 UTC (permalink / raw)
To: ML netdev, David S. Miller
Cc: Tomoya Morinaga, LKML, Wang, Qi, Wang, Yong Y, Andrew, Intel OTC,
Ewe, Kok Howg
The checksum judgment was mistaken.
Judgment result
0:Correct 1:Wrong
This patch fixes the issue.
Signed-off-by: Toshiharu Okada <toshiharu-linux@dsn.okisemi.com>
---
drivers/net/pch_gbe/pch_gbe_main.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/net/pch_gbe/pch_gbe_main.c b/drivers/net/pch_gbe/pch_gbe_main.c
index babe663..6f10361 100644
--- a/drivers/net/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/pch_gbe/pch_gbe_main.c
@@ -1494,12 +1494,11 @@ pch_gbe_clean_rx(struct pch_gbe_adapter *adapter,
/* Write meta date of skb */
skb_put(skb, length);
skb->protocol = eth_type_trans(skb, netdev);
- if ((tcp_ip_status & PCH_GBE_RXD_ACC_STAT_TCPIPOK) ==
- PCH_GBE_RXD_ACC_STAT_TCPIPOK) {
- skb->ip_summed = CHECKSUM_UNNECESSARY;
- } else {
+ if (tcp_ip_status & PCH_GBE_RXD_ACC_STAT_TCPIPOK)
skb->ip_summed = CHECKSUM_NONE;
- }
+ else
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+
napi_gro_receive(&adapter->napi, skb);
(*work_done)++;
pr_debug("Receive skb->ip_summed: %d length: %d\n",
--
1.6.2.5
^ permalink raw reply related
* Re: [PATCH] net/bonding: adjust codingstyle for bond_3ad files.
From: Nicolas Kaiser @ 2011-05-06 13:01 UTC (permalink / raw)
To: Rafael Aquini
Cc: David Miller, Joe Perches, Jay Vosburgh, Andy Gospodarek,
shemminger, netdev, kernel-janitors
In-Reply-To: <20110506115037.GA3299@x61.tchesoft.com>
* Rafael Aquini <aquini@linux.com>:
> While I was studying what bond_3ad has under its hood, I realized its coding
> style did not follow all Documentation/CodingStyle recommendations. As a tiny
> collaboration I did some mods there, in an attempt to make that code stick as
> closely as possible with Kernel's coding style.
> Modifications:
> * switched all comments from C99-style to C89-style.
> * replaced MAC_ADDRESS_COMPARE macro for compare_ether_addr()
>
> Signed-off-by: Rafael Aquini <aquini@linux.com>
> ---
> drivers/net/bonding/bond_3ad.c | 836 +++++++++++++++++++++++-----------------
> drivers/net/bonding/bond_3ad.h | 195 +++++-----
> 2 files changed, 579 insertions(+), 452 deletions(-)
>
> diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
> index 31912f1..fdb07be 100644
> --- a/drivers/net/bonding/bond_3ad.c
> +++ b/drivers/net/bonding/bond_3ad.c
(..)
> @@ -1533,16 +1596,15 @@ static void ad_agg_selection_logic(struct aggregator *agg)
>
> if (best &&
> __get_agg_selection_mode(best->lag_ports) == BOND_AD_STABLE) {
> - /*
> - * For the STABLE policy, don't replace the old active
> - * aggregator if it's still active (it has an answering
> - * partner) or if both the best and active don't have an
> - * answering partner.
> +
> + /* For the STABLE policy, don't replace the old active
> + * aggregator if it's still active (it has an answering partner)
> + * or if both the best and active don't have answering partners
> */
> if (active && active->lag_ports &&
> active->lag_ports->is_enabled &&
> (__agg_has_partner(active) ||
> - (!__agg_has_partner(active) && !__agg_has_partner(best)))) {
> + (!__agg_has_partner(active) && !__agg_has_partner(best)))) {
> if (!(!active->actor_oper_aggregator_key &&
> best->actor_oper_aggregator_key)) {
> best = NULL;
The indentation of parentheses looks correct to me in the original version.
However, this expression can also be simplified like
if (active && active->lag_ports &&
active->lag_ports->is_enabled &&
- (__agg_has_partner(active) ||
- (!__agg_has_partner(active) && !__agg_has_partner(best)))) {
+ (__agg_has_partner(active) || !__agg_has_partner(best))) {
if (!(!active->actor_oper_aggregator_key &&
best->actor_oper_aggregator_key)) {
best = NULL;
Last October I submitted such a patch which also simplified the
double negation in the subsequent expression.
Best regards,
Nicolas Kaiser
^ permalink raw reply
* [PATCH] CDC NCM: Add mising short packet in cdc_ncm driver
From: Alexey Orishko @ 2011-05-06 13:01 UTC (permalink / raw)
To: netdev; +Cc: linux-usb, davem, gregkh, Alexey Orishko
Changes:
- while making NTB, driver shall check if device dwNtbOutMaxSize is higher than
host value and shall add a short packet if this is the case
- previous temporary patch for this issue is replaced by this one
Signed-off-by: Alexey Orishko <alexey.orishko@stericsson.com>
---
drivers/net/usb/cdc_ncm.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 1033ef6..4ab557d 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -54,13 +54,13 @@
#include <linux/usb/usbnet.h>
#include <linux/usb/cdc.h>
-#define DRIVER_VERSION "23-Apr-2011"
+#define DRIVER_VERSION "06-May-2011"
/* CDC NCM subclass 3.2.1 */
#define USB_CDC_NCM_NDP16_LENGTH_MIN 0x10
/* Maximum NTB length */
-#define CDC_NCM_NTB_MAX_SIZE_TX (16384 + 4) /* bytes, must be short terminated */
+#define CDC_NCM_NTB_MAX_SIZE_TX 16384 /* bytes */
#define CDC_NCM_NTB_MAX_SIZE_RX 16384 /* bytes */
/* Minimum value for MaxDatagramSize, ch. 6.2.9 */
@@ -722,7 +722,7 @@ cdc_ncm_fill_tx_frame(struct cdc_ncm_ctx *ctx, struct sk_buff *skb)
} else {
/* reset variables */
- skb_out = alloc_skb(ctx->tx_max, GFP_ATOMIC);
+ skb_out = alloc_skb((ctx->tx_max + 1), GFP_ATOMIC);
if (skb_out == NULL) {
if (skb != NULL) {
dev_kfree_skb_any(skb);
@@ -861,8 +861,11 @@ cdc_ncm_fill_tx_frame(struct cdc_ncm_ctx *ctx, struct sk_buff *skb)
/* store last offset */
last_offset = offset;
- if ((last_offset < ctx->tx_max) && ((last_offset %
- le16_to_cpu(ctx->out_ep->desc.wMaxPacketSize)) == 0)) {
+ if (((last_offset < ctx->tx_max) && ((last_offset %
+ le16_to_cpu(ctx->out_ep->desc.wMaxPacketSize)) == 0)) ||
+ (((last_offset == ctx->tx_max) && ((ctx->tx_max %
+ le16_to_cpu(ctx->out_ep->desc.wMaxPacketSize)) == 0)) &&
+ (ctx->tx_max < le32_to_cpu(ctx->ncm_parm.dwNtbOutMaxSize)))) {
/* force short packet */
*(((u8 *)skb_out->data) + last_offset) = 0;
last_offset++;
--
1.7.4.3
^ permalink raw reply related
* Re: [PATCH 0/2] wireless: Make and use const struct ieee80211_channel
From: John W. Linville @ 2011-05-06 13:19 UTC (permalink / raw)
To: Joe Perches
Cc: libertas-dev, linux-wireless, orinoco-users, orinoco-devel,
netdev, LKML
In-Reply-To: <1304634107.1788.171.camel@Joe-Laptop>
On Thu, May 05, 2011 at 03:21:47PM -0700, Joe Perches wrote:
> On Thu, 2011-05-05 at 14:49 -0400, John W. Linville wrote:
> > These patches generated a lot of warnings in net/mac80211. Did you
> > actually build them?
>
> Yes.
>
> Did you apply patch 1/2 first?
> It's a dependent patch.
That's the one that cause most of the warnings...
--
John W. Linville Someday the world will need a hero, and you
linville@tuxdriver.com might be all we have. Be ready.
^ permalink raw reply
* [PATCH] dccp: handle invalid feature options length
From: Dan Rosenberg @ 2011-05-06 13:27 UTC (permalink / raw)
To: gerrit, davem; +Cc: dccp, netdev, linux-kernel, security
A length of zero (after subtracting two for the type and len fields) for
the DCCPO_{CHANGE,CONFIRM}_{L,R} options will cause an underflow due to
the subtraction. The subsequent code may read past the end of the
options value buffer when parsing. I'm unsure of what the consequences
of this might be, but it's probably not good.
Signed-off-by: Dan Rosenberg <drosenberg@vsecurity.com>
Cc: stable@kernel.org
---
net/dccp/options.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/net/dccp/options.c b/net/dccp/options.c
index f06ffcf..4b2ab65 100644
--- a/net/dccp/options.c
+++ b/net/dccp/options.c
@@ -123,6 +123,8 @@ int dccp_parse_options(struct sock *sk, struct dccp_request_sock *dreq,
case DCCPO_CHANGE_L ... DCCPO_CONFIRM_R:
if (pkt_type == DCCP_PKT_DATA) /* RFC 4340, 6 */
break;
+ if (len == 0)
+ goto out_invalid_option;
rc = dccp_feat_parse_options(sk, dreq, mandatory, opt,
*value, value + 1, len - 1);
if (rc)
^ permalink raw reply related
* Re: [RFC v3 01/10] lsm: add security_socket_closed()
From: Samir Bellabes @ 2011-05-06 13:45 UTC (permalink / raw)
To: Tetsuo Handa; +Cc: linux-security-module, netdev
In-Reply-To: <201105040029.IGA98088.SHOVQFLOMJtOFF@I-love.SAKURA.ne.jp>
Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> writes:
> Samir Bellabes wrote:
>> Allow a module to update security informations when a socket is closed.
> Is security_inode_free() too late for doing it?
>
> static void ccs_inode_free_security(struct inode *inode)
> {
> if (inode->i_sb && inode->i_sb->s_magic == SOCKFS_MAGIC)
> ccs_update_socket_tag(inode, 0);
> }
this point won't be possible.
security_inode_free() is occuring too late :
static int sock_close(struct inode *inode, struct file *filp)
{
security_socket_close(SOCKET_I(inode));
... -> acces sock->sk infos in this hook
sock_release(SOCKET_I(inode));
{
sock->ops->release(sock);
{
int inet_release(struct socket *sock)
{
struct sock *sk = sock->sk;
if (sk) {
sock_rps_reset_flow(sk);
sock->sk = NULL;
sk->sk_prot->close(sk, timeout);
--> here sk infos are now removed
}
}
if (!sock->file) {
iput(SOCK_INODE(sock));
--> here we are removing the inode, so
security_inode_free is called now, but too late.
}
}
}
return 0;
}
^ permalink raw reply
* Re: [PATCH] dccp: handle invalid feature options length
From: Gerrit Renker @ 2011-05-06 13:53 UTC (permalink / raw)
To: Dan Rosenberg; +Cc: davem, dccp, netdev, linux-kernel, security
In-Reply-To: <1304688438.29544.16.camel@dan>
Quoting Dan Rosenberg:
| A length of zero (after subtracting two for the type and len fields) for
| the DCCPO_{CHANGE,CONFIRM}_{L,R} options will cause an underflow due to
| the subtraction. The subsequent code may read past the end of the
| options value buffer when parsing. I'm unsure of what the consequences
| of this might be, but it's probably not good.
|
Can you please check again: did you experience this condition, to me it
seems the patch is based on reading this code.
In this case, please consider the condition before the switch statement:
/* Check if this isn't a single byte option */
if (opt > DCCPO_MAX_RESERVED) {
if (opt_ptr == opt_end)
goto out_nonsensical_length;
len = *opt_ptr++;
if (len < 2)
goto out_nonsensical_length;
The described range (DCCPO_CHANGE_L = 32 ... DCCPO_CONFIRM_R = 35) is after DCCPO_MAX_RESERVED = 31,
so that the above test applies.
Hence for these option types the len is always at least 1, so that (len - 1) >= 0.
| --- a/net/dccp/options.c
| +++ b/net/dccp/options.c
| @@ -123,6 +123,8 @@ int dccp_parse_options(struct sock *sk, struct dccp_request_sock *dreq,
| case DCCPO_CHANGE_L ... DCCPO_CONFIRM_R:
| if (pkt_type == DCCP_PKT_DATA) /* RFC 4340, 6 */
| break;
| + if (len == 0)
| + goto out_invalid_option;
| rc = dccp_feat_parse_options(sk, dreq, mandatory, opt,
| *value, value + 1, len - 1);
| if (rc)
|
|
--
^ permalink raw reply
* Re: [PATCH] dccp: handle invalid feature options length
From: Dan Rosenberg @ 2011-05-06 14:43 UTC (permalink / raw)
To: Gerrit Renker; +Cc: davem, dccp, netdev, linux-kernel, security
In-Reply-To: <20110506135345.GA3434@gerrit.erg.abdn.ac.uk>
> Can you please check again: did you experience this condition, to me it
> seems the patch is based on reading this code.
>
I saw this while reading the code.
> In this case, please consider the condition before the switch statement:
>
> /* Check if this isn't a single byte option */
> if (opt > DCCPO_MAX_RESERVED) {
> if (opt_ptr == opt_end)
> goto out_nonsensical_length;
>
> len = *opt_ptr++;
> if (len < 2)
> goto out_nonsensical_length;
>
> The described range (DCCPO_CHANGE_L = 32 ... DCCPO_CONFIRM_R = 35) is after DCCPO_MAX_RESERVED = 31,
> so that the above test applies.
>
> Hence for these option types the len is always at least 1, so that (len - 1) >= 0.
>
You just missed the important part:
if (len < 2)
goto out_nonsensical_length;
/*
* Remove the type and len fields, leaving
* just the value size
*/
len -= 2;
If the len is 2, this check will pass, and the resulting len will be 0,
causing the underflow.
Regards,
Dan
> | --- a/net/dccp/options.c
> | +++ b/net/dccp/options.c
> | @@ -123,6 +123,8 @@ int dccp_parse_options(struct sock *sk, struct dccp_request_sock *dreq,
> | case DCCPO_CHANGE_L ... DCCPO_CONFIRM_R:
> | if (pkt_type == DCCP_PKT_DATA) /* RFC 4340, 6 */
> | break;
> | + if (len == 0)
> | + goto out_invalid_option;
> | rc = dccp_feat_parse_options(sk, dreq, mandatory, opt,
> | *value, value + 1, len - 1);
> | if (rc)
> |
> |
>
> --
^ permalink raw reply
* Re: [PATCH] net/bonding: adjust codingstyle for bond_3ad files.
From: Rafael Aquini @ 2011-05-06 14:56 UTC (permalink / raw)
To: Nicolas Kaiser
Cc: David Miller, Joe Perches, Jay Vosburgh, Andy Gospodarek,
shemminger, netdev, kernel-janitors
In-Reply-To: <20110506150114.25513c92@absol.kitzblitz>
Howdy Nicolas,
On Fri, May 06, 2011 at 03:01:14PM +0200, Nicolas Kaiser wrote:
> The indentation of parentheses looks correct to me in the original version.
> However, this expression can also be simplified like
>
> if (active && active->lag_ports &&
> active->lag_ports->is_enabled &&
> - (__agg_has_partner(active) ||
> - (!__agg_has_partner(active) && !__agg_has_partner(best)))) {
> + (__agg_has_partner(active) || !__agg_has_partner(best))) {
> if (!(!active->actor_oper_aggregator_key &&
> best->actor_oper_aggregator_key)) {
> best = NULL;
>
> Last October I submitted such a patch which also simplified the
> double negation in the subsequent expression.
Thanks for the feedback!
Send me this patch of yours, I'll try to merge our paths and resubmit adding
you as a signer as well
Cheers!
--
Rafael Aquini <aquini@linux.com>
^ permalink raw reply
* Re: [Bugme-new] [Bug 34322] New: No ECN marking in IPv6
From: Eric Dumazet @ 2011-05-06 15:04 UTC (permalink / raw)
To: Andrew Morton
Cc: netdev, bugzilla-daemon, bugme-daemon, sgunderson,
YOSHIFUJI Hideaki
In-Reply-To: <20110505144146.4bc1e744.akpm@linux-foundation.org>
Le jeudi 05 mai 2011 à 14:41 -0700, Andrew Morton a écrit :
> (switched to email. Please respond via emailed reply-to-all, not via the
> bugzilla web interface).
>
> On Tue, 3 May 2011 20:05:00 GMT
> bugzilla-daemon@bugzilla.kernel.org wrote:
>
> > https://bugzilla.kernel.org/show_bug.cgi?id=34322
> >
> > Summary: No ECN marking in IPv6
> > Product: Networking
> > Version: 2.5
> > Kernel Version: 2.6.38.4
> > Platform: All
> > OS/Version: Linux
> > Tree: Mainline
> > Status: NEW
> > Severity: normal
> > Priority: P1
> > Component: IPV6
> > AssignedTo: yoshfuji@linux-ipv6.org
> > ReportedBy: sgunderson@bigfoot.com
> > Regression: No
> >
> >
> > Hi,
> >
> > I'm completely unable to get ECN to work for IPv6. /proc/sys/net/ipv4/tcp_ecn
> > is set to 1 on both sides, and ECN works just fine for IPv4 TCP connections,
> > but when I connect over IPv6 tclass just stays at 0x0, and as far as I'd
> > understood, there should be two bits here set to 10 (like in the diffserv field
> > of IPv4), right?
> >
> > I do get ECN-echo bits in the TCP header, though (for the initial SYN and
> > SYN/ACK packets).
> >
>
> and
>
> > I looked at the code, and although I don't understand all of it, it
> > looks like e9df2e8fd8fbc95c57dbd1d33dada66c4627b44c (which also brought
> > ECN for IPv6 SCTP) might be the culprit. It seems like TCP_ECN_send()
> > calls INET_ECN_xmit(), which only sets the ECN bit in the IPv4 ToS
> > field (inet_sk(sk)->tos), but after the patch, what's checked is
> > inet6_sk(sk)->tclass, which is a completely different field.
> >
> > Is the analysis correct? Should the tclass be set as well?
>
> and
>
> > OK, as a quick hack, I did this:
> >
> > --- a/linux-2.6.38.5/include/net/inet_ecn.h 2011-04-14 22:03:56.000000000+0200
> > +++ b/linux-2.6.38.5/include/net/inet_ecn.h 2011-05-04 00:36:52.803377902+0200
> > @@ -38,7 +38,7 @@
> > return outer;
> > }
> >
> > -#define INET_ECN_xmit(sk) do { inet_sk(sk)->tos |= INET_ECN_ECT_0; } while (0)
> > +#define INET_ECN_xmit(sk) do { inet_sk(sk)->tos |= INET_ECN_ECT_0; if (inet6_sk(sk) != NULL) inet6_sk(sk)->tclass |= INET_ECN_ECT_0; } while (0)
> > #define INET_ECN_dontxmit(sk) \
> > do { inet_sk(sk)->tos &= ~INET_ECN_MASK; } while (0)
> >
> > and now my packets are properly marked with tclass 0x02 (ie.,
> > signalling ECN-capable transport, no congestion experienced yet).
> >
> > I guess this isn't the right way of doing it, but at least it confirms
> > that the lack of setting tclass is part of the problem.
>
Cc YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Hello Steinar
Analysis seems fine, but you also need to change INET_ECN_dontxmit() for
retransmitted packets.
Any chance you can refine your patch ?
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