Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: (26 commits)
  net: sh_eth alignment fix for sh7724 using NET_IP_ALIGN V2
  ixgbe: allow tx of pre-formatted vlan tagged packets
  ixgbe: Fix 82598 premature copper PHY link indicatation
  ixgbe: Fix tx_restart_queue/non_eop_desc statistics counters
  bcm63xx_enet: fix compilation failure after get_stats_count removal
  packet: dont call sleeping functions while holding rcu_read_lock()
  tcp: Revert per-route SACK/DSACK/TIMESTAMP changes.
  ipvs: zero usvc and udest
  netfilter: fix crashes in bridge netfilter caused by fragment jumps
  ipv6: reassembly: use seperate reassembly queues for conntrack and local delivery
  sky2: leave PCI config space writeable
  sky2: print Optima chip name
  x25: Update maintainer.
  ipvs: fix synchronization on connection close
  netfilter: xtables: document minimal required version
  drivers/net/bonding/: : use pr_fmt
  can: CAN_MCP251X should depend on HAS_DMA
  drivers/net/usb: Correct code taking the size of a pointer
  drivers/net/cpmac.c: Correct code taking the size of a pointer
  drivers/net/sfc: Correct code taking the size of a pointer
  ...
This commit is contained in:
Linus Torvalds 2009-12-16 10:33:18 -08:00
commit 59be2e04e5
52 changed files with 743 additions and 884 deletions

View File

@ -49,6 +49,8 @@ o oprofile 0.9 # oprofiled --version
o udev 081 # udevinfo -V o udev 081 # udevinfo -V
o grub 0.93 # grub --version o grub 0.93 # grub --version
o mcelog 0.6 o mcelog 0.6
o iptables 1.4.1 # iptables -V
Kernel compilation Kernel compilation
================== ==================

View File

@ -5991,9 +5991,9 @@ F: sound/soc/codecs/wm8350.*
F: sound/soc/codecs/wm8400.* F: sound/soc/codecs/wm8400.*
X.25 NETWORK LAYER X.25 NETWORK LAYER
M: Henner Eisen <eis@baty.hanse.de> M: Andrew Hendry <andrew.hendry@gmail.com>
L: linux-x25@vger.kernel.org L: linux-x25@vger.kernel.org
S: Maintained S: Odd Fixes
F: Documentation/networking/x25* F: Documentation/networking/x25*
F: include/net/x25* F: include/net/x25*
F: net/x25/ F: net/x25/

View File

@ -557,7 +557,7 @@ static int ia_cbr_setup (IADEV *dev, struct atm_vcc *vcc) {
memcpy((caddr_t)&cbrVC,(caddr_t)TstSchedTbl,sizeof(cbrVC)); memcpy((caddr_t)&cbrVC,(caddr_t)TstSchedTbl,sizeof(cbrVC));
} /* while */ } /* while */
// Move this VCI number into this location of the CBR Sched table. // Move this VCI number into this location of the CBR Sched table.
memcpy((caddr_t)TstSchedTbl, (caddr_t)&vcIndex,sizeof(TstSchedTbl)); memcpy((caddr_t)TstSchedTbl, (caddr_t)&vcIndex, sizeof(*TstSchedTbl));
dev->CbrRemEntries--; dev->CbrRemEntries--;
toBeAssigned--; toBeAssigned--;
} /* while */ } /* while */

View File

@ -1245,9 +1245,15 @@ static void bcm_enet_get_drvinfo(struct net_device *netdev,
drvinfo->n_stats = BCM_ENET_STATS_LEN; drvinfo->n_stats = BCM_ENET_STATS_LEN;
} }
static int bcm_enet_get_stats_count(struct net_device *netdev) static int bcm_enet_get_sset_count(struct net_device *netdev,
int string_set)
{ {
return BCM_ENET_STATS_LEN; switch (string_set) {
case ETH_SS_STATS:
return BCM_ENET_STATS_LEN;
default:
return -EINVAL;
}
} }
static void bcm_enet_get_strings(struct net_device *netdev, static void bcm_enet_get_strings(struct net_device *netdev,
@ -1473,7 +1479,7 @@ static int bcm_enet_set_pauseparam(struct net_device *dev,
static struct ethtool_ops bcm_enet_ethtool_ops = { static struct ethtool_ops bcm_enet_ethtool_ops = {
.get_strings = bcm_enet_get_strings, .get_strings = bcm_enet_get_strings,
.get_stats_count = bcm_enet_get_stats_count, .get_sset_count = bcm_enet_get_sset_count,
.get_ethtool_stats = bcm_enet_get_ethtool_stats, .get_ethtool_stats = bcm_enet_get_ethtool_stats,
.get_settings = bcm_enet_get_settings, .get_settings = bcm_enet_get_settings,
.set_settings = bcm_enet_set_settings, .set_settings = bcm_enet_set_settings,

View File

@ -20,6 +20,8 @@
* *
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/if_ether.h> #include <linux/if_ether.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
@ -352,7 +354,8 @@ static u16 __get_link_speed(struct port *port)
} }
} }
pr_debug("Port %d Received link speed %d update from adapter\n", port->actor_port_number, speed); pr_debug("Port %d Received link speed %d update from adapter\n",
port->actor_port_number, speed);
return speed; return speed;
} }
@ -378,12 +381,14 @@ static u8 __get_duplex(struct port *port)
switch (slave->duplex) { switch (slave->duplex) {
case DUPLEX_FULL: case DUPLEX_FULL:
retval=0x1; retval=0x1;
pr_debug("Port %d Received status full duplex update from adapter\n", port->actor_port_number); pr_debug("Port %d Received status full duplex update from adapter\n",
port->actor_port_number);
break; break;
case DUPLEX_HALF: case DUPLEX_HALF:
default: default:
retval=0x0; retval=0x0;
pr_debug("Port %d Received status NOT full duplex update from adapter\n", port->actor_port_number); pr_debug("Port %d Received status NOT full duplex update from adapter\n",
port->actor_port_number);
break; break;
} }
} }
@ -980,7 +985,9 @@ static void ad_mux_machine(struct port *port)
// check if the state machine was changed // check if the state machine was changed
if (port->sm_mux_state != last_state) { 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, port->sm_mux_state); pr_debug("Mux Machine: Port=%d, Last State=%d, Curr State=%d\n",
port->actor_port_number, last_state,
port->sm_mux_state);
switch (port->sm_mux_state) { switch (port->sm_mux_state) {
case AD_MUX_DETACHED: case AD_MUX_DETACHED:
__detach_bond_from_agg(port); __detach_bond_from_agg(port);
@ -1079,7 +1086,9 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
// 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)) { 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, port->sm_rx_state); pr_debug("Rx Machine: Port=%d, Last State=%d, Curr State=%d\n",
port->actor_port_number, last_state,
port->sm_rx_state);
switch (port->sm_rx_state) { switch (port->sm_rx_state) {
case AD_RX_INITIALIZE: case AD_RX_INITIALIZE:
if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_BITS)) { if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_BITS)) {
@ -1126,9 +1135,8 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
// detect loopback situation // detect loopback situation
if (!MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->actor_system))) { if (!MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->actor_system))) {
// INFO_RECEIVED_LOOPBACK_FRAMES // INFO_RECEIVED_LOOPBACK_FRAMES
pr_err(DRV_NAME ": %s: An illegal loopback occurred on " pr_err("%s: An illegal loopback occurred on adapter (%s).\n"
"adapter (%s). Check the configuration to verify that all " "Check the configuration to verify that all adapters are connected to 802.3ad compliant switch ports\n",
"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);
__release_rx_machine_lock(port); __release_rx_machine_lock(port);
return; return;
@ -1166,7 +1174,8 @@ static void ad_tx_machine(struct port *port)
__update_lacpdu_from_port(port); __update_lacpdu_from_port(port);
if (ad_lacpdu_send(port) >= 0) { if (ad_lacpdu_send(port) >= 0) {
pr_debug("Sent LACPDU on port %d\n", port->actor_port_number); pr_debug("Sent LACPDU on port %d\n",
port->actor_port_number);
/* mark ntt as false, so it will not be sent again until /* mark ntt as false, so it will not be sent again until
demanded */ demanded */
@ -1241,7 +1250,9 @@ static void ad_periodic_machine(struct port *port)
// check if the state machine was changed // check if the state machine was changed
if (port->sm_periodic_state != last_state) { 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); 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) { switch (port->sm_periodic_state) {
case AD_NO_PERIODIC: case AD_NO_PERIODIC:
port->sm_periodic_timer_counter = 0; // zero timer port->sm_periodic_timer_counter = 0; // zero timer
@ -1298,7 +1309,9 @@ static void ad_port_selection_logic(struct port *port)
port->next_port_in_aggregator=NULL; port->next_port_in_aggregator=NULL;
port->actor_port_aggregator_identifier=0; port->actor_port_aggregator_identifier=0;
pr_debug("Port %d left LAG %d\n", port->actor_port_number, temp_aggregator->aggregator_identifier); 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 // if the aggregator is empty, clear its parameters, and set it ready to be attached
if (!temp_aggregator->lag_ports) { if (!temp_aggregator->lag_ports) {
ad_clear_agg(temp_aggregator); ad_clear_agg(temp_aggregator);
@ -1307,9 +1320,7 @@ static void ad_port_selection_logic(struct port *port)
} }
} }
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(DRV_NAME ": %s: Warning: Port %d (on %s) " pr_warning("%s: Warning: Port %d (on %s) was related to aggregator %d but was not on its port list\n",
"was related to aggregator %d but was not "
"on its port list\n",
port->slave->dev->master->name, port->slave->dev->master->name,
port->actor_port_number, port->actor_port_number,
port->slave->dev->name, port->slave->dev->name,
@ -1343,7 +1354,9 @@ static void ad_port_selection_logic(struct port *port)
port->next_port_in_aggregator=aggregator->lag_ports; port->next_port_in_aggregator=aggregator->lag_ports;
port->aggregator->num_of_ports++; port->aggregator->num_of_ports++;
aggregator->lag_ports=port; aggregator->lag_ports=port;
pr_debug("Port %d joined LAG %d(existing LAG)\n", port->actor_port_number, port->aggregator->aggregator_identifier); pr_debug("Port %d joined LAG %d(existing LAG)\n",
port->actor_port_number,
port->aggregator->aggregator_identifier);
// mark this port as selected // mark this port as selected
port->sm_vars |= AD_PORT_SELECTED; port->sm_vars |= AD_PORT_SELECTED;
@ -1380,10 +1393,11 @@ static void ad_port_selection_logic(struct port *port)
// mark this port as selected // mark this port as selected
port->sm_vars |= AD_PORT_SELECTED; port->sm_vars |= AD_PORT_SELECTED;
pr_debug("Port %d joined LAG %d(new LAG)\n", port->actor_port_number, port->aggregator->aggregator_identifier); pr_debug("Port %d joined LAG %d(new LAG)\n",
port->actor_port_number,
port->aggregator->aggregator_identifier);
} else { } else {
pr_err(DRV_NAME ": %s: Port %d (on %s) did not find " pr_err("%s: Port %d (on %s) did not find a suitable aggregator\n",
"a suitable aggregator\n",
port->slave->dev->master->name, port->slave->dev->master->name,
port->actor_port_number, port->slave->dev->name); port->actor_port_number, port->slave->dev->name);
} }
@ -1460,8 +1474,7 @@ static struct aggregator *ad_agg_selection_test(struct aggregator *best,
break; break;
default: default:
pr_warning(DRV_NAME pr_warning("%s: Impossible agg select mode %d\n",
": %s: Impossible agg select mode %d\n",
curr->slave->dev->master->name, curr->slave->dev->master->name,
__get_agg_selection_mode(curr->lag_ports)); __get_agg_selection_mode(curr->lag_ports));
break; break;
@ -1546,40 +1559,38 @@ static void ad_agg_selection_logic(struct aggregator *agg)
// if there is new best aggregator, activate it // if there is new best aggregator, activate it
if (best) { if (best) {
pr_debug("best Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n", 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, best->aggregator_identifier, best->num_of_ports,
best->actor_oper_aggregator_key, best->actor_oper_aggregator_key,
best->partner_oper_aggregator_key, best->partner_oper_aggregator_key,
best->is_individual, best->is_active); best->is_individual, best->is_active);
pr_debug("best ports %p slave %p %s\n", pr_debug("best ports %p slave %p %s\n",
best->lag_ports, best->slave, best->lag_ports, best->slave,
best->slave ? best->slave->dev->name : "NULL"); best->slave ? best->slave->dev->name : "NULL");
for (agg = __get_first_agg(best->lag_ports); agg; for (agg = __get_first_agg(best->lag_ports); agg;
agg = __get_next_agg(agg)) { agg = __get_next_agg(agg)) {
pr_debug("Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n", pr_debug("Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n",
agg->aggregator_identifier, agg->num_of_ports, agg->aggregator_identifier, agg->num_of_ports,
agg->actor_oper_aggregator_key, agg->actor_oper_aggregator_key,
agg->partner_oper_aggregator_key, agg->partner_oper_aggregator_key,
agg->is_individual, agg->is_active); agg->is_individual, agg->is_active);
} }
// check if any partner replys // check if any partner replys
if (best->is_individual) { if (best->is_individual) {
pr_warning(DRV_NAME ": %s: Warning: No 802.3ad" pr_warning("%s: Warning: No 802.3ad response from the link partner for any adapters in the bond\n",
" response from the link partner for any" best->slave->dev->master->name);
" adapters in the bond\n",
best->slave->dev->master->name);
} }
best->is_active = 1; best->is_active = 1;
pr_debug("LAG %d chosen as the active LAG\n", pr_debug("LAG %d chosen as the active LAG\n",
best->aggregator_identifier); best->aggregator_identifier);
pr_debug("Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n", pr_debug("Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n",
best->aggregator_identifier, best->num_of_ports, best->aggregator_identifier, best->num_of_ports,
best->actor_oper_aggregator_key, best->actor_oper_aggregator_key,
best->partner_oper_aggregator_key, best->partner_oper_aggregator_key,
best->is_individual, best->is_active); 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) { if (active) {
@ -1633,7 +1644,8 @@ static void ad_clear_agg(struct aggregator *aggregator)
aggregator->lag_ports = NULL; aggregator->lag_ports = NULL;
aggregator->is_active = 0; aggregator->is_active = 0;
aggregator->num_of_ports = 0; aggregator->num_of_ports = 0;
pr_debug("LAG %d was cleared\n", aggregator->aggregator_identifier); pr_debug("LAG %d was cleared\n",
aggregator->aggregator_identifier);
} }
} }
@ -1728,7 +1740,9 @@ static void ad_initialize_port(struct port *port, int lacp_fast)
static void ad_enable_collecting_distributing(struct port *port) static void ad_enable_collecting_distributing(struct port *port)
{ {
if (port->aggregator->is_active) { if (port->aggregator->is_active) {
pr_debug("Enabling port %d(LAG %d)\n", port->actor_port_number, port->aggregator->aggregator_identifier); pr_debug("Enabling port %d(LAG %d)\n",
port->actor_port_number,
port->aggregator->aggregator_identifier);
__enable_port(port); __enable_port(port);
} }
} }
@ -1741,7 +1755,9 @@ static void ad_enable_collecting_distributing(struct port *port)
static void ad_disable_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 && MAC_ADDRESS_COMPARE(&(port->aggregator->partner_system), &(null_mac_addr))) {
pr_debug("Disabling port %d(LAG %d)\n", port->actor_port_number, port->aggregator->aggregator_identifier); pr_debug("Disabling port %d(LAG %d)\n",
port->actor_port_number,
port->aggregator->aggregator_identifier);
__disable_port(port); __disable_port(port);
} }
} }
@ -1779,7 +1795,8 @@ static void ad_marker_info_send(struct port *port)
// send the marker information // send the marker information
if (ad_marker_send(port, &marker) >= 0) { if (ad_marker_send(port, &marker) >= 0) {
pr_debug("Sent Marker Information on port %d\n", port->actor_port_number); pr_debug("Sent Marker Information on port %d\n",
port->actor_port_number);
} }
} }
#endif #endif
@ -1803,7 +1820,8 @@ static void ad_marker_info_received(struct bond_marker *marker_info,
// send the marker response // send the marker response
if (ad_marker_send(port, &marker) >= 0) { if (ad_marker_send(port, &marker) >= 0) {
pr_debug("Sent Marker Response on port %d\n", port->actor_port_number); pr_debug("Sent Marker Response on port %d\n",
port->actor_port_number);
} }
} }
@ -1889,8 +1907,7 @@ int bond_3ad_bind_slave(struct slave *slave)
struct aggregator *aggregator; struct aggregator *aggregator;
if (bond == NULL) { if (bond == NULL) {
pr_err(DRV_NAME ": %s: The slave %s is not attached to " pr_err("%s: The slave %s is not attached to its bond\n",
"its bond\n",
slave->dev->master->name, slave->dev->name); slave->dev->master->name, slave->dev->name);
return -1; return -1;
} }
@ -1966,13 +1983,13 @@ void bond_3ad_unbind_slave(struct slave *slave)
// if slave is null, the whole port is not initialized // if slave is null, the whole port is not initialized
if (!port->slave) { if (!port->slave) {
pr_warning(DRV_NAME ": Warning: %s: Trying to " pr_warning("Warning: %s: Trying to unbind an uninitialized port on %s\n",
"unbind an uninitialized port on %s\n",
slave->dev->master->name, slave->dev->name); slave->dev->master->name, slave->dev->name);
return; return;
} }
pr_debug("Unbinding Link Aggregation Group %d\n", aggregator->aggregator_identifier); pr_debug("Unbinding Link Aggregation Group %d\n",
aggregator->aggregator_identifier);
/* Tell the partner that this port is not suitable for aggregation */ /* Tell the partner that this port is not suitable for aggregation */
port->actor_oper_port_state &= ~AD_STATE_AGGREGATION; port->actor_oper_port_state &= ~AD_STATE_AGGREGATION;
@ -1996,10 +2013,12 @@ void bond_3ad_unbind_slave(struct slave *slave)
// if new aggregator found, copy the aggregator's parameters // if new aggregator found, copy the aggregator's parameters
// and connect the related lag_ports to the new aggregator // 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) && ((!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); 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(DRV_NAME ": %s: Removing an active aggregator\n", pr_info("%s: Removing an active aggregator\n",
aggregator->slave->dev->master->name); aggregator->slave->dev->master->name);
// select new active aggregator // select new active aggregator
select_new_active_agg = 1; select_new_active_agg = 1;
@ -2030,8 +2049,7 @@ void bond_3ad_unbind_slave(struct slave *slave)
ad_agg_selection_logic(__get_first_agg(port)); ad_agg_selection_logic(__get_first_agg(port));
} }
} else { } else {
pr_warning(DRV_NAME ": %s: Warning: unbinding aggregator, " pr_warning("%s: Warning: unbinding aggregator, and could not find a new aggregator for its ports\n",
"and could not find a new aggregator for its ports\n",
slave->dev->master->name); 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
@ -2039,7 +2057,7 @@ void bond_3ad_unbind_slave(struct slave *slave)
// clear the aggregator // clear the aggregator
ad_clear_agg(aggregator); ad_clear_agg(aggregator);
if (select_new_active_agg) { if (select_new_active_agg) {
pr_info(DRV_NAME ": %s: Removing an active aggregator\n", pr_info("%s: Removing an active aggregator\n",
slave->dev->master->name); slave->dev->master->name);
// select new active aggregator // select new active aggregator
ad_agg_selection_logic(__get_first_agg(port)); ad_agg_selection_logic(__get_first_agg(port));
@ -2066,7 +2084,7 @@ void bond_3ad_unbind_slave(struct slave *slave)
// clear the aggregator // clear the aggregator
ad_clear_agg(temp_aggregator); ad_clear_agg(temp_aggregator);
if (select_new_active_agg) { if (select_new_active_agg) {
pr_info(DRV_NAME ": %s: Removing an active aggregator\n", pr_info("%s: Removing an active aggregator\n",
slave->dev->master->name); slave->dev->master->name);
// select new active aggregator // select new active aggregator
ad_agg_selection_logic(__get_first_agg(port)); ad_agg_selection_logic(__get_first_agg(port));
@ -2115,8 +2133,8 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
// select the active aggregator for the bond // select the active aggregator for the bond
if ((port = __get_first_port(bond))) { if ((port = __get_first_port(bond))) {
if (!port->slave) { if (!port->slave) {
pr_warning(DRV_NAME ": %s: Warning: bond's first port is " pr_warning("%s: Warning: bond's first port is uninitialized\n",
"uninitialized\n", bond->dev->name); bond->dev->name);
goto re_arm; goto re_arm;
} }
@ -2129,8 +2147,8 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
// for each port run the state machines // for each port run the state machines
for (port = __get_first_port(bond); port; port = __get_next_port(port)) { for (port = __get_first_port(bond); port; port = __get_next_port(port)) {
if (!port->slave) { if (!port->slave) {
pr_warning(DRV_NAME ": %s: Warning: Found an uninitialized " pr_warning("%s: Warning: Found an uninitialized port\n",
"port\n", bond->dev->name); bond->dev->name);
goto re_arm; goto re_arm;
} }
@ -2171,15 +2189,15 @@ static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u
port = &(SLAVE_AD_INFO(slave).port); port = &(SLAVE_AD_INFO(slave).port);
if (!port->slave) { if (!port->slave) {
pr_warning(DRV_NAME ": %s: Warning: port of slave %s " pr_warning("%s: Warning: port of slave %s is uninitialized\n",
"is uninitialized\n",
slave->dev->name, slave->dev->master->name); slave->dev->name, slave->dev->master->name);
return; return;
} }
switch (lacpdu->subtype) { switch (lacpdu->subtype) {
case AD_TYPE_LACPDU: case AD_TYPE_LACPDU:
pr_debug("Received LACPDU on port %d\n", port->actor_port_number); pr_debug("Received LACPDU on port %d\n",
port->actor_port_number);
ad_rx_machine(lacpdu, port); ad_rx_machine(lacpdu, port);
break; break;
@ -2188,17 +2206,20 @@ static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u
switch (((struct bond_marker *)lacpdu)->tlv_type) { switch (((struct bond_marker *)lacpdu)->tlv_type) {
case AD_MARKER_INFORMATION_SUBTYPE: case AD_MARKER_INFORMATION_SUBTYPE:
pr_debug("Received Marker Information on port %d\n", port->actor_port_number); pr_debug("Received Marker Information on port %d\n",
port->actor_port_number);
ad_marker_info_received((struct bond_marker *)lacpdu, port); ad_marker_info_received((struct bond_marker *)lacpdu, port);
break; break;
case AD_MARKER_RESPONSE_SUBTYPE: case AD_MARKER_RESPONSE_SUBTYPE:
pr_debug("Received Marker Response on port %d\n", port->actor_port_number); pr_debug("Received Marker Response on port %d\n",
port->actor_port_number);
ad_marker_response_received((struct bond_marker *)lacpdu, port); ad_marker_response_received((struct bond_marker *)lacpdu, port);
break; break;
default: default:
pr_debug("Received an unknown Marker subtype on slot %d\n", port->actor_port_number); pr_debug("Received an unknown Marker subtype on slot %d\n",
port->actor_port_number);
} }
} }
} }
@ -2218,8 +2239,7 @@ void bond_3ad_adapter_speed_changed(struct slave *slave)
// if slave is null, the whole port is not initialized // if slave is null, the whole port is not initialized
if (!port->slave) { if (!port->slave) {
pr_warning(DRV_NAME ": Warning: %s: speed " pr_warning("Warning: %s: speed changed for uninitialized port on %s\n",
"changed for uninitialized port on %s\n",
slave->dev->master->name, slave->dev->name); slave->dev->master->name, slave->dev->name);
return; return;
} }
@ -2246,8 +2266,7 @@ void bond_3ad_adapter_duplex_changed(struct slave *slave)
// if slave is null, the whole port is not initialized // if slave is null, the whole port is not initialized
if (!port->slave) { if (!port->slave) {
pr_warning(DRV_NAME ": %s: Warning: duplex changed " pr_warning("%s: Warning: duplex changed for uninitialized port on %s\n",
"for uninitialized port on %s\n",
slave->dev->master->name, slave->dev->name); slave->dev->master->name, slave->dev->name);
return; return;
} }
@ -2275,8 +2294,7 @@ void bond_3ad_handle_link_change(struct slave *slave, char link)
// if slave is null, the whole port is not initialized // if slave is null, the whole port is not initialized
if (!port->slave) { if (!port->slave) {
pr_warning(DRV_NAME ": Warning: %s: link status changed for " pr_warning("Warning: %s: link status changed for uninitialized port on %s\n",
"uninitialized port on %s\n",
slave->dev->master->name, slave->dev->name); slave->dev->master->name, slave->dev->name);
return; return;
} }
@ -2381,8 +2399,8 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
} }
if (bond_3ad_get_active_agg_info(bond, &ad_info)) { if (bond_3ad_get_active_agg_info(bond, &ad_info)) {
pr_debug(DRV_NAME ": %s: Error: " pr_debug("%s: Error: bond_3ad_get_active_agg_info failed\n",
"bond_3ad_get_active_agg_info failed\n", dev->name); dev->name);
goto out; goto out;
} }
@ -2391,8 +2409,7 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
if (slaves_in_agg == 0) { if (slaves_in_agg == 0) {
/*the aggregator is empty*/ /*the aggregator is empty*/
pr_debug(DRV_NAME ": %s: Error: active aggregator is empty\n", pr_debug("%s: Error: active aggregator is empty\n", dev->name);
dev->name);
goto out; goto out;
} }
@ -2410,8 +2427,8 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
} }
if (slave_agg_no >= 0) { if (slave_agg_no >= 0) {
pr_err(DRV_NAME ": %s: Error: Couldn't find a slave to tx on " pr_err("%s: Error: Couldn't find a slave to tx on for aggregator ID %d\n",
"for aggregator ID %d\n", dev->name, agg_id); dev->name, agg_id);
goto out; goto out;
} }

View File

@ -20,6 +20,8 @@
* *
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
@ -201,8 +203,7 @@ static int tlb_initialize(struct bonding *bond)
new_hashtbl = kzalloc(size, GFP_KERNEL); new_hashtbl = kzalloc(size, GFP_KERNEL);
if (!new_hashtbl) { if (!new_hashtbl) {
pr_err(DRV_NAME pr_err("%s: Error: Failed to allocate TLB hash table\n",
": %s: Error: Failed to allocate TLB hash table\n",
bond->dev->name); bond->dev->name);
return -1; return -1;
} }
@ -514,8 +515,7 @@ static void rlb_update_client(struct rlb_client_info *client_info)
client_info->slave->dev->dev_addr, client_info->slave->dev->dev_addr,
client_info->mac_dst); client_info->mac_dst);
if (!skb) { if (!skb) {
pr_err(DRV_NAME pr_err("%s: Error: failed to create an ARP packet\n",
": %s: Error: failed to create an ARP packet\n",
client_info->slave->dev->master->name); client_info->slave->dev->master->name);
continue; continue;
} }
@ -525,8 +525,7 @@ static void rlb_update_client(struct rlb_client_info *client_info)
if (client_info->tag) { if (client_info->tag) {
skb = vlan_put_tag(skb, client_info->vlan_id); skb = vlan_put_tag(skb, client_info->vlan_id);
if (!skb) { if (!skb) {
pr_err(DRV_NAME pr_err("%s: Error: failed to insert VLAN tag\n",
": %s: Error: failed to insert VLAN tag\n",
client_info->slave->dev->master->name); client_info->slave->dev->master->name);
continue; continue;
} }
@ -609,9 +608,7 @@ static void rlb_req_update_subnet_clients(struct bonding *bond, __be32 src_ip)
client_info = &(bond_info->rx_hashtbl[hash_index]); client_info = &(bond_info->rx_hashtbl[hash_index]);
if (!client_info->slave) { if (!client_info->slave) {
pr_err(DRV_NAME pr_err("%s: Error: found a client with no channel in the client's hash table\n",
": %s: Error: found a client with no channel in "
"the client's hash table\n",
bond->dev->name); bond->dev->name);
continue; continue;
} }
@ -806,8 +803,7 @@ static int rlb_initialize(struct bonding *bond)
new_hashtbl = kmalloc(size, GFP_KERNEL); new_hashtbl = kmalloc(size, GFP_KERNEL);
if (!new_hashtbl) { if (!new_hashtbl) {
pr_err(DRV_NAME pr_err("%s: Error: Failed to allocate RLB hash table\n",
": %s: Error: Failed to allocate RLB hash table\n",
bond->dev->name); bond->dev->name);
return -1; return -1;
} }
@ -928,8 +924,7 @@ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[])
skb = vlan_put_tag(skb, vlan->vlan_id); skb = vlan_put_tag(skb, vlan->vlan_id);
if (!skb) { if (!skb) {
pr_err(DRV_NAME pr_err("%s: Error: failed to insert VLAN tag\n",
": %s: Error: failed to insert VLAN tag\n",
bond->dev->name); bond->dev->name);
continue; continue;
} }
@ -958,11 +953,8 @@ static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[], int hw)
memcpy(s_addr.sa_data, addr, dev->addr_len); memcpy(s_addr.sa_data, addr, dev->addr_len);
s_addr.sa_family = dev->type; s_addr.sa_family = dev->type;
if (dev_set_mac_address(dev, &s_addr)) { if (dev_set_mac_address(dev, &s_addr)) {
pr_err(DRV_NAME pr_err("%s: Error: dev_set_mac_address of dev %s failed!\n"
": %s: Error: dev_set_mac_address of dev %s failed! ALB " "ALB mode requires that the base driver support setting the hw address also when the network device's interface is open\n",
"mode requires that the base driver support setting "
"the hw address also when the network device's "
"interface is open\n",
dev->master->name, dev->name); dev->master->name, dev->name);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
@ -1169,18 +1161,12 @@ static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slav
alb_set_slave_mac_addr(slave, free_mac_slave->perm_hwaddr, alb_set_slave_mac_addr(slave, free_mac_slave->perm_hwaddr,
bond->alb_info.rlb_enabled); bond->alb_info.rlb_enabled);
pr_warning(DRV_NAME pr_warning("%s: Warning: the hw address of slave %s is in use by the bond; giving it the hw address of %s\n",
": %s: Warning: the hw address of slave %s is "
"in use by the bond; giving it the hw address "
"of %s\n",
bond->dev->name, slave->dev->name, bond->dev->name, slave->dev->name,
free_mac_slave->dev->name); free_mac_slave->dev->name);
} else if (has_bond_addr) { } else if (has_bond_addr) {
pr_err(DRV_NAME pr_err("%s: Error: the hw address of slave %s is in use by the bond; couldn't find a slave with a free hw address to give it (this should not have happened)\n",
": %s: Error: the hw address of slave %s is in use by the "
"bond; couldn't find a slave with a free hw address to "
"give it (this should not have happened)\n",
bond->dev->name, slave->dev->name); bond->dev->name, slave->dev->name);
return -EFAULT; return -EFAULT;
} }

View File

@ -20,6 +20,8 @@
* *
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/types.h> #include <linux/types.h>
#include <linux/if_vlan.h> #include <linux/if_vlan.h>
#include <net/ipv6.h> #include <net/ipv6.h>
@ -74,20 +76,20 @@ static void bond_na_send(struct net_device *slave_dev,
addrconf_addr_solict_mult(daddr, &mcaddr); addrconf_addr_solict_mult(daddr, &mcaddr);
pr_debug("ipv6 na on slave %s: dest %pI6, src %pI6\n", pr_debug("ipv6 na on slave %s: dest %pI6, src %pI6\n",
slave_dev->name, &mcaddr, daddr); slave_dev->name, &mcaddr, daddr);
skb = ndisc_build_skb(slave_dev, &mcaddr, daddr, &icmp6h, daddr, skb = ndisc_build_skb(slave_dev, &mcaddr, daddr, &icmp6h, daddr,
ND_OPT_TARGET_LL_ADDR); ND_OPT_TARGET_LL_ADDR);
if (!skb) { if (!skb) {
pr_err(DRV_NAME ": NA packet allocation failed\n"); pr_err("NA packet allocation failed\n");
return; return;
} }
if (vlan_id) { if (vlan_id) {
skb = vlan_put_tag(skb, vlan_id); skb = vlan_put_tag(skb, vlan_id);
if (!skb) { if (!skb) {
pr_err(DRV_NAME ": failed to insert VLAN tag\n"); pr_err("failed to insert VLAN tag\n");
return; return;
} }
} }
@ -109,8 +111,8 @@ void bond_send_unsolicited_na(struct bonding *bond)
struct inet6_dev *idev; struct inet6_dev *idev;
int is_router; int is_router;
pr_debug("bond_send_unsol_na: bond %s slave %s\n", bond->dev->name, pr_debug("%s: bond %s slave %s\n", bond->dev->name,
slave ? slave->dev->name : "NULL"); __func__, slave ? slave->dev->name : "NULL");
if (!slave || !bond->send_unsol_na || if (!slave || !bond->send_unsol_na ||
test_bit(__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state)) test_bit(__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state))

File diff suppressed because it is too large Load Diff

View File

@ -19,6 +19,9 @@
* file called LICENSE. * file called LICENSE.
* *
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/device.h> #include <linux/device.h>
@ -109,11 +112,10 @@ static ssize_t bonding_store_bonds(struct class *cls,
goto err_no_cmd; goto err_no_cmd;
if (command[0] == '+') { if (command[0] == '+') {
pr_info(DRV_NAME pr_info("%s is being created...\n", ifname);
": %s is being created...\n", ifname);
rv = bond_create(net, ifname); rv = bond_create(net, ifname);
if (rv) { if (rv) {
pr_info(DRV_NAME ": Bond creation failed.\n"); pr_info("Bond creation failed.\n");
res = rv; res = rv;
} }
} else if (command[0] == '-') { } else if (command[0] == '-') {
@ -122,12 +124,10 @@ static ssize_t bonding_store_bonds(struct class *cls,
rtnl_lock(); rtnl_lock();
bond_dev = bond_get_by_name(net, ifname); bond_dev = bond_get_by_name(net, ifname);
if (bond_dev) { if (bond_dev) {
pr_info(DRV_NAME ": %s is being deleted...\n", pr_info("%s is being deleted...\n", ifname);
ifname);
unregister_netdevice(bond_dev); unregister_netdevice(bond_dev);
} else { } else {
pr_err(DRV_NAME ": unable to delete non-existent %s\n", pr_err("unable to delete non-existent %s\n", ifname);
ifname);
res = -ENODEV; res = -ENODEV;
} }
rtnl_unlock(); rtnl_unlock();
@ -140,8 +140,7 @@ static ssize_t bonding_store_bonds(struct class *cls,
return res; return res;
err_no_cmd: err_no_cmd:
pr_err(DRV_NAME ": no command found in bonding_masters." pr_err("no command found in bonding_masters. Use +ifname or -ifname.\n");
" Use +ifname or -ifname.\n");
return -EPERM; return -EPERM;
} }
@ -225,8 +224,8 @@ static ssize_t bonding_store_slaves(struct device *d,
/* Quick sanity check -- is the bond interface up? */ /* Quick sanity check -- is the bond interface up? */
if (!(bond->dev->flags & IFF_UP)) { if (!(bond->dev->flags & IFF_UP)) {
pr_warning(DRV_NAME ": %s: doing slave updates when " pr_warning("%s: doing slave updates when interface is down.\n",
"interface is down.\n", bond->dev->name); bond->dev->name);
} }
/* Note: We can't hold bond->lock here, as bond_create grabs it. */ /* Note: We can't hold bond->lock here, as bond_create grabs it. */
@ -247,17 +246,14 @@ static ssize_t bonding_store_slaves(struct device *d,
dev = __dev_get_by_name(dev_net(bond->dev), ifname); dev = __dev_get_by_name(dev_net(bond->dev), ifname);
if (!dev) { if (!dev) {
pr_info(DRV_NAME pr_info("%s: Interface %s does not exist!\n",
": %s: Interface %s does not exist!\n", bond->dev->name, ifname);
bond->dev->name, ifname);
ret = -ENODEV; ret = -ENODEV;
goto out; goto out;
} }
if (dev->flags & IFF_UP) { if (dev->flags & IFF_UP) {
pr_err(DRV_NAME pr_err("%s: Error: Unable to enslave %s because it is already up.\n",
": %s: Error: Unable to enslave %s "
"because it is already up.\n",
bond->dev->name, dev->name); bond->dev->name, dev->name);
ret = -EPERM; ret = -EPERM;
goto out; goto out;
@ -266,8 +262,7 @@ static ssize_t bonding_store_slaves(struct device *d,
read_lock(&bond->lock); read_lock(&bond->lock);
bond_for_each_slave(bond, slave, i) bond_for_each_slave(bond, slave, i)
if (slave->dev == dev) { if (slave->dev == dev) {
pr_err(DRV_NAME pr_err("%s: Interface %s is already enslaved!\n",
": %s: Interface %s is already enslaved!\n",
bond->dev->name, ifname); bond->dev->name, ifname);
ret = -EPERM; ret = -EPERM;
read_unlock(&bond->lock); read_unlock(&bond->lock);
@ -275,8 +270,7 @@ static ssize_t bonding_store_slaves(struct device *d,
} }
read_unlock(&bond->lock); read_unlock(&bond->lock);
pr_info(DRV_NAME ": %s: Adding slave %s.\n", pr_info("%s: Adding slave %s.\n", bond->dev->name, ifname);
bond->dev->name, ifname);
/* If this is the first slave, then we need to set /* If this is the first slave, then we need to set
the master's hardware address to be the same as the the master's hardware address to be the same as the
@ -313,7 +307,7 @@ static ssize_t bonding_store_slaves(struct device *d,
break; break;
} }
if (dev) { if (dev) {
pr_info(DRV_NAME ": %s: Removing slave %s\n", pr_info("%s: Removing slave %s\n",
bond->dev->name, dev->name); bond->dev->name, dev->name);
res = bond_release(bond->dev, dev); res = bond_release(bond->dev, dev);
if (res) { if (res) {
@ -323,16 +317,16 @@ static ssize_t bonding_store_slaves(struct device *d,
/* set the slave MTU to the default */ /* set the slave MTU to the default */
dev_set_mtu(dev, original_mtu); dev_set_mtu(dev, original_mtu);
} else { } else {
pr_err(DRV_NAME ": unable to remove non-existent" pr_err("unable to remove non-existent slave %s for bond %s.\n",
" slave %s for bond %s.\n", ifname, bond->dev->name);
ifname, bond->dev->name);
ret = -ENODEV; ret = -ENODEV;
} }
goto out; goto out;
} }
err_no_cmd: err_no_cmd:
pr_err(DRV_NAME ": no command found in slaves file for bond %s. Use +ifname or -ifname.\n", bond->dev->name); pr_err("no command found in slaves file for bond %s. Use +ifname or -ifname.\n",
bond->dev->name);
ret = -EPERM; ret = -EPERM;
out: out:
@ -365,18 +359,16 @@ static ssize_t bonding_store_mode(struct device *d,
struct bonding *bond = to_bond(d); struct bonding *bond = to_bond(d);
if (bond->dev->flags & IFF_UP) { if (bond->dev->flags & IFF_UP) {
pr_err(DRV_NAME ": unable to update mode of %s" pr_err("unable to update mode of %s because interface is up.\n",
" because interface is up.\n", bond->dev->name); bond->dev->name);
ret = -EPERM; ret = -EPERM;
goto out; goto out;
} }
new_value = bond_parse_parm(buf, bond_mode_tbl); new_value = bond_parse_parm(buf, bond_mode_tbl);
if (new_value < 0) { if (new_value < 0) {
pr_err(DRV_NAME pr_err("%s: Ignoring invalid mode value %.*s.\n",
": %s: Ignoring invalid mode value %.*s.\n", bond->dev->name, (int)strlen(buf) - 1, buf);
bond->dev->name,
(int)strlen(buf) - 1, buf);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} else { } else {
@ -388,8 +380,8 @@ static ssize_t bonding_store_mode(struct device *d,
bond->params.mode = new_value; bond->params.mode = new_value;
bond_set_mode_ops(bond, bond->params.mode); bond_set_mode_ops(bond, bond->params.mode);
pr_info(DRV_NAME ": %s: setting mode to %s (%d).\n", pr_info("%s: setting mode to %s (%d).\n",
bond->dev->name, bond_mode_tbl[new_value].modename, bond->dev->name, bond_mode_tbl[new_value].modename,
new_value); new_value);
} }
out: out:
@ -421,8 +413,7 @@ static ssize_t bonding_store_xmit_hash(struct device *d,
struct bonding *bond = to_bond(d); struct bonding *bond = to_bond(d);
if (bond->dev->flags & IFF_UP) { if (bond->dev->flags & IFF_UP) {
pr_err(DRV_NAME pr_err("%s: Interface is up. Unable to update xmit policy.\n",
"%s: Interface is up. Unable to update xmit policy.\n",
bond->dev->name); bond->dev->name);
ret = -EPERM; ret = -EPERM;
goto out; goto out;
@ -430,8 +421,7 @@ static ssize_t bonding_store_xmit_hash(struct device *d,
new_value = bond_parse_parm(buf, xmit_hashtype_tbl); new_value = bond_parse_parm(buf, xmit_hashtype_tbl);
if (new_value < 0) { if (new_value < 0) {
pr_err(DRV_NAME pr_err("%s: Ignoring invalid xmit hash policy value %.*s.\n",
": %s: Ignoring invalid xmit hash policy value %.*s.\n",
bond->dev->name, bond->dev->name,
(int)strlen(buf) - 1, buf); (int)strlen(buf) - 1, buf);
ret = -EINVAL; ret = -EINVAL;
@ -439,7 +429,7 @@ static ssize_t bonding_store_xmit_hash(struct device *d,
} else { } else {
bond->params.xmit_policy = new_value; bond->params.xmit_policy = new_value;
bond_set_mode_ops(bond, bond->params.mode); bond_set_mode_ops(bond, bond->params.mode);
pr_info(DRV_NAME ": %s: setting xmit hash policy to %s (%d).\n", pr_info("%s: setting xmit hash policy to %s (%d).\n",
bond->dev->name, bond->dev->name,
xmit_hashtype_tbl[new_value].modename, new_value); xmit_hashtype_tbl[new_value].modename, new_value);
} }
@ -472,20 +462,18 @@ static ssize_t bonding_store_arp_validate(struct device *d,
new_value = bond_parse_parm(buf, arp_validate_tbl); new_value = bond_parse_parm(buf, arp_validate_tbl);
if (new_value < 0) { if (new_value < 0) {
pr_err(DRV_NAME pr_err("%s: Ignoring invalid arp_validate value %s\n",
": %s: Ignoring invalid arp_validate value %s\n",
bond->dev->name, buf); bond->dev->name, buf);
return -EINVAL; return -EINVAL;
} }
if (new_value && (bond->params.mode != BOND_MODE_ACTIVEBACKUP)) { if (new_value && (bond->params.mode != BOND_MODE_ACTIVEBACKUP)) {
pr_err(DRV_NAME pr_err("%s: arp_validate only supported in active-backup mode.\n",
": %s: arp_validate only supported in active-backup mode.\n",
bond->dev->name); bond->dev->name);
return -EINVAL; return -EINVAL;
} }
pr_info(DRV_NAME ": %s: setting arp_validate to %s (%d).\n", pr_info("%s: setting arp_validate to %s (%d).\n",
bond->dev->name, arp_validate_tbl[new_value].modename, bond->dev->name, arp_validate_tbl[new_value].modename,
new_value); new_value);
if (!bond->params.arp_validate && new_value) if (!bond->params.arp_validate && new_value)
bond_register_arp(bond); bond_register_arp(bond);
@ -523,24 +511,22 @@ static ssize_t bonding_store_fail_over_mac(struct device *d,
struct bonding *bond = to_bond(d); struct bonding *bond = to_bond(d);
if (bond->slave_cnt != 0) { if (bond->slave_cnt != 0) {
pr_err(DRV_NAME pr_err("%s: Can't alter fail_over_mac with slaves in bond.\n",
": %s: Can't alter fail_over_mac with slaves in bond.\n",
bond->dev->name); bond->dev->name);
return -EPERM; return -EPERM;
} }
new_value = bond_parse_parm(buf, fail_over_mac_tbl); new_value = bond_parse_parm(buf, fail_over_mac_tbl);
if (new_value < 0) { if (new_value < 0) {
pr_err(DRV_NAME pr_err("%s: Ignoring invalid fail_over_mac value %s.\n",
": %s: Ignoring invalid fail_over_mac value %s.\n",
bond->dev->name, buf); bond->dev->name, buf);
return -EINVAL; return -EINVAL;
} }
bond->params.fail_over_mac = new_value; bond->params.fail_over_mac = new_value;
pr_info(DRV_NAME ": %s: Setting fail_over_mac to %s (%d).\n", pr_info("%s: Setting fail_over_mac to %s (%d).\n",
bond->dev->name, fail_over_mac_tbl[new_value].modename, bond->dev->name, fail_over_mac_tbl[new_value].modename,
new_value); new_value);
return count; return count;
} }
@ -571,31 +557,26 @@ static ssize_t bonding_store_arp_interval(struct device *d,
struct bonding *bond = to_bond(d); struct bonding *bond = to_bond(d);
if (sscanf(buf, "%d", &new_value) != 1) { if (sscanf(buf, "%d", &new_value) != 1) {
pr_err(DRV_NAME pr_err("%s: no arp_interval value specified.\n",
": %s: no arp_interval value specified.\n",
bond->dev->name); bond->dev->name);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
if (new_value < 0) { if (new_value < 0) {
pr_err(DRV_NAME pr_err("%s: Invalid arp_interval value %d not in range 1-%d; rejected.\n",
": %s: Invalid arp_interval value %d not in range 1-%d; rejected.\n",
bond->dev->name, new_value, INT_MAX); bond->dev->name, new_value, INT_MAX);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
pr_info(DRV_NAME pr_info("%s: Setting ARP monitoring interval to %d.\n",
": %s: Setting ARP monitoring interval to %d.\n", bond->dev->name, new_value);
bond->dev->name, new_value);
bond->params.arp_interval = new_value; bond->params.arp_interval = new_value;
if (bond->params.arp_interval) if (bond->params.arp_interval)
bond->dev->priv_flags |= IFF_MASTER_ARPMON; bond->dev->priv_flags |= IFF_MASTER_ARPMON;
if (bond->params.miimon) { if (bond->params.miimon) {
pr_info(DRV_NAME pr_info("%s: ARP monitoring cannot be used with MII monitoring. %s Disabling MII monitoring.\n",
": %s: ARP monitoring cannot be used with MII monitoring. " bond->dev->name, bond->dev->name);
"%s Disabling MII monitoring.\n",
bond->dev->name, bond->dev->name);
bond->params.miimon = 0; bond->params.miimon = 0;
if (delayed_work_pending(&bond->mii_work)) { if (delayed_work_pending(&bond->mii_work)) {
cancel_delayed_work(&bond->mii_work); cancel_delayed_work(&bond->mii_work);
@ -603,10 +584,8 @@ static ssize_t bonding_store_arp_interval(struct device *d,
} }
} }
if (!bond->params.arp_targets[0]) { if (!bond->params.arp_targets[0]) {
pr_info(DRV_NAME pr_info("%s: ARP monitoring has been set up, but no ARP targets have been specified.\n",
": %s: ARP monitoring has been set up, " bond->dev->name);
"but no ARP targets have been specified.\n",
bond->dev->name);
} }
if (bond->dev->flags & IFF_UP) { if (bond->dev->flags & IFF_UP) {
/* If the interface is up, we may need to fire off /* If the interface is up, we may need to fire off
@ -666,8 +645,7 @@ static ssize_t bonding_store_arp_targets(struct device *d,
/* look for adds */ /* look for adds */
if (buf[0] == '+') { if (buf[0] == '+') {
if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) { if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) {
pr_err(DRV_NAME pr_err("%s: invalid ARP target %pI4 specified for addition\n",
": %s: invalid ARP target %pI4 specified for addition\n",
bond->dev->name, &newtarget); bond->dev->name, &newtarget);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
@ -675,23 +653,20 @@ static ssize_t bonding_store_arp_targets(struct device *d,
/* look for an empty slot to put the target in, and check for dupes */ /* look for an empty slot to put the target in, and check for dupes */
for (i = 0; (i < BOND_MAX_ARP_TARGETS) && !done; i++) { for (i = 0; (i < BOND_MAX_ARP_TARGETS) && !done; i++) {
if (targets[i] == newtarget) { /* duplicate */ if (targets[i] == newtarget) { /* duplicate */
pr_err(DRV_NAME pr_err("%s: ARP target %pI4 is already present\n",
": %s: ARP target %pI4 is already present\n",
bond->dev->name, &newtarget); bond->dev->name, &newtarget);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
if (targets[i] == 0) { if (targets[i] == 0) {
pr_info(DRV_NAME pr_info("%s: adding ARP target %pI4.\n",
": %s: adding ARP target %pI4.\n", bond->dev->name, &newtarget);
bond->dev->name, &newtarget);
done = 1; done = 1;
targets[i] = newtarget; targets[i] = newtarget;
} }
} }
if (!done) { if (!done) {
pr_err(DRV_NAME pr_err("%s: ARP target table is full!\n",
": %s: ARP target table is full!\n",
bond->dev->name); bond->dev->name);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
@ -699,8 +674,7 @@ static ssize_t bonding_store_arp_targets(struct device *d,
} else if (buf[0] == '-') { } else if (buf[0] == '-') {
if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) { if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) {
pr_err(DRV_NAME pr_err("%s: invalid ARP target %pI4 specified for removal\n",
": %s: invalid ARP target %pI4 specified for removal\n",
bond->dev->name, &newtarget); bond->dev->name, &newtarget);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
@ -709,9 +683,8 @@ static ssize_t bonding_store_arp_targets(struct device *d,
for (i = 0; (i < BOND_MAX_ARP_TARGETS) && !done; i++) { for (i = 0; (i < BOND_MAX_ARP_TARGETS) && !done; i++) {
if (targets[i] == newtarget) { if (targets[i] == newtarget) {
int j; int j;
pr_info(DRV_NAME pr_info("%s: removing ARP target %pI4.\n",
": %s: removing ARP target %pI4.\n", bond->dev->name, &newtarget);
bond->dev->name, &newtarget);
for (j = i; (j < (BOND_MAX_ARP_TARGETS-1)) && targets[j+1]; j++) for (j = i; (j < (BOND_MAX_ARP_TARGETS-1)) && targets[j+1]; j++)
targets[j] = targets[j+1]; targets[j] = targets[j+1];
@ -720,16 +693,14 @@ static ssize_t bonding_store_arp_targets(struct device *d,
} }
} }
if (!done) { if (!done) {
pr_info(DRV_NAME pr_info("%s: unable to remove nonexistent ARP target %pI4.\n",
": %s: unable to remove nonexistent ARP target %pI4.\n", bond->dev->name, &newtarget);
bond->dev->name, &newtarget);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
} else { } else {
pr_err(DRV_NAME ": no command found in arp_ip_targets file" pr_err("no command found in arp_ip_targets file for bond %s. Use +<addr> or -<addr>.\n",
" for bond %s. Use +<addr> or -<addr>.\n", bond->dev->name);
bond->dev->name);
ret = -EPERM; ret = -EPERM;
goto out; goto out;
} }
@ -761,41 +732,34 @@ static ssize_t bonding_store_downdelay(struct device *d,
struct bonding *bond = to_bond(d); struct bonding *bond = to_bond(d);
if (!(bond->params.miimon)) { if (!(bond->params.miimon)) {
pr_err(DRV_NAME pr_err("%s: Unable to set down delay as MII monitoring is disabled\n",
": %s: Unable to set down delay as MII monitoring is disabled\n",
bond->dev->name); bond->dev->name);
ret = -EPERM; ret = -EPERM;
goto out; goto out;
} }
if (sscanf(buf, "%d", &new_value) != 1) { if (sscanf(buf, "%d", &new_value) != 1) {
pr_err(DRV_NAME pr_err("%s: no down delay value specified.\n", bond->dev->name);
": %s: no down delay value specified.\n",
bond->dev->name);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
if (new_value < 0) { if (new_value < 0) {
pr_err(DRV_NAME pr_err("%s: Invalid down delay value %d not in range %d-%d; rejected.\n",
": %s: Invalid down delay value %d not in range %d-%d; rejected.\n",
bond->dev->name, new_value, 1, INT_MAX); bond->dev->name, new_value, 1, INT_MAX);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} else { } else {
if ((new_value % bond->params.miimon) != 0) { if ((new_value % bond->params.miimon) != 0) {
pr_warning(DRV_NAME pr_warning("%s: Warning: down delay (%d) is not a multiple of miimon (%d), delay rounded to %d ms\n",
": %s: Warning: down delay (%d) is not a "
"multiple of miimon (%d), delay rounded "
"to %d ms\n",
bond->dev->name, new_value, bond->dev->name, new_value,
bond->params.miimon, bond->params.miimon,
(new_value / bond->params.miimon) * (new_value / bond->params.miimon) *
bond->params.miimon); bond->params.miimon);
} }
bond->params.downdelay = new_value / bond->params.miimon; bond->params.downdelay = new_value / bond->params.miimon;
pr_info(DRV_NAME ": %s: Setting down delay to %d.\n", pr_info("%s: Setting down delay to %d.\n",
bond->dev->name, bond->dev->name,
bond->params.downdelay * bond->params.miimon); bond->params.downdelay * bond->params.miimon);
} }
@ -823,41 +787,35 @@ static ssize_t bonding_store_updelay(struct device *d,
struct bonding *bond = to_bond(d); struct bonding *bond = to_bond(d);
if (!(bond->params.miimon)) { if (!(bond->params.miimon)) {
pr_err(DRV_NAME pr_err("%s: Unable to set up delay as MII monitoring is disabled\n",
": %s: Unable to set up delay as MII monitoring is disabled\n",
bond->dev->name); bond->dev->name);
ret = -EPERM; ret = -EPERM;
goto out; goto out;
} }
if (sscanf(buf, "%d", &new_value) != 1) { if (sscanf(buf, "%d", &new_value) != 1) {
pr_err(DRV_NAME pr_err("%s: no up delay value specified.\n",
": %s: no up delay value specified.\n",
bond->dev->name); bond->dev->name);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
if (new_value < 0) { if (new_value < 0) {
pr_err(DRV_NAME pr_err("%s: Invalid down delay value %d not in range %d-%d; rejected.\n",
": %s: Invalid down delay value %d not in range %d-%d; rejected.\n",
bond->dev->name, new_value, 1, INT_MAX); bond->dev->name, new_value, 1, INT_MAX);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} else { } else {
if ((new_value % bond->params.miimon) != 0) { if ((new_value % bond->params.miimon) != 0) {
pr_warning(DRV_NAME pr_warning("%s: Warning: up delay (%d) is not a multiple of miimon (%d), updelay rounded to %d ms\n",
": %s: Warning: up delay (%d) is not a "
"multiple of miimon (%d), updelay rounded "
"to %d ms\n",
bond->dev->name, new_value, bond->dev->name, new_value,
bond->params.miimon, bond->params.miimon,
(new_value / bond->params.miimon) * (new_value / bond->params.miimon) *
bond->params.miimon); bond->params.miimon);
} }
bond->params.updelay = new_value / bond->params.miimon; bond->params.updelay = new_value / bond->params.miimon;
pr_info(DRV_NAME ": %s: Setting up delay to %d.\n", pr_info("%s: Setting up delay to %d.\n",
bond->dev->name, bond->params.updelay * bond->params.miimon); bond->dev->name,
bond->params.updelay * bond->params.miimon);
} }
out: out:
@ -889,16 +847,14 @@ static ssize_t bonding_store_lacp(struct device *d,
struct bonding *bond = to_bond(d); struct bonding *bond = to_bond(d);
if (bond->dev->flags & IFF_UP) { if (bond->dev->flags & IFF_UP) {
pr_err(DRV_NAME pr_err("%s: Unable to update LACP rate because interface is up.\n",
": %s: Unable to update LACP rate because interface is up.\n",
bond->dev->name); bond->dev->name);
ret = -EPERM; ret = -EPERM;
goto out; goto out;
} }
if (bond->params.mode != BOND_MODE_8023AD) { if (bond->params.mode != BOND_MODE_8023AD) {
pr_err(DRV_NAME pr_err("%s: Unable to update LACP rate because bond is not in 802.3ad mode.\n",
": %s: Unable to update LACP rate because bond is not in 802.3ad mode.\n",
bond->dev->name); bond->dev->name);
ret = -EPERM; ret = -EPERM;
goto out; goto out;
@ -908,12 +864,11 @@ static ssize_t bonding_store_lacp(struct device *d,
if ((new_value == 1) || (new_value == 0)) { if ((new_value == 1) || (new_value == 0)) {
bond->params.lacp_fast = new_value; bond->params.lacp_fast = new_value;
pr_info(DRV_NAME ": %s: Setting LACP rate to %s (%d).\n", pr_info("%s: Setting LACP rate to %s (%d).\n",
bond->dev->name, bond_lacp_tbl[new_value].modename, bond->dev->name, bond_lacp_tbl[new_value].modename,
new_value); new_value);
} else { } else {
pr_err(DRV_NAME pr_err("%s: Ignoring invalid LACP rate value %.*s.\n",
": %s: Ignoring invalid LACP rate value %.*s.\n",
bond->dev->name, (int)strlen(buf) - 1, buf); bond->dev->name, (int)strlen(buf) - 1, buf);
ret = -EINVAL; ret = -EINVAL;
} }
@ -943,9 +898,8 @@ static ssize_t bonding_store_ad_select(struct device *d,
struct bonding *bond = to_bond(d); struct bonding *bond = to_bond(d);
if (bond->dev->flags & IFF_UP) { if (bond->dev->flags & IFF_UP) {
pr_err(DRV_NAME pr_err("%s: Unable to update ad_select because interface is up.\n",
": %s: Unable to update ad_select because interface " bond->dev->name);
"is up.\n", bond->dev->name);
ret = -EPERM; ret = -EPERM;
goto out; goto out;
} }
@ -954,13 +908,11 @@ static ssize_t bonding_store_ad_select(struct device *d,
if (new_value != -1) { if (new_value != -1) {
bond->params.ad_select = new_value; bond->params.ad_select = new_value;
pr_info(DRV_NAME pr_info("%s: Setting ad_select to %s (%d).\n",
": %s: Setting ad_select to %s (%d).\n", bond->dev->name, ad_select_tbl[new_value].modename,
bond->dev->name, ad_select_tbl[new_value].modename, new_value);
new_value);
} else { } else {
pr_err(DRV_NAME pr_err("%s: Ignoring invalid ad_select value %.*s.\n",
": %s: Ignoring invalid ad_select value %.*s.\n",
bond->dev->name, (int)strlen(buf) - 1, buf); bond->dev->name, (int)strlen(buf) - 1, buf);
ret = -EINVAL; ret = -EINVAL;
} }
@ -990,15 +942,13 @@ static ssize_t bonding_store_n_grat_arp(struct device *d,
struct bonding *bond = to_bond(d); struct bonding *bond = to_bond(d);
if (sscanf(buf, "%d", &new_value) != 1) { if (sscanf(buf, "%d", &new_value) != 1) {
pr_err(DRV_NAME pr_err("%s: no num_grat_arp value specified.\n",
": %s: no num_grat_arp value specified.\n",
bond->dev->name); bond->dev->name);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
if (new_value < 0 || new_value > 255) { if (new_value < 0 || new_value > 255) {
pr_err(DRV_NAME pr_err("%s: Invalid num_grat_arp value %d not in range 0-255; rejected.\n",
": %s: Invalid num_grat_arp value %d not in range 0-255; rejected.\n",
bond->dev->name, new_value); bond->dev->name, new_value);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
@ -1031,16 +981,14 @@ static ssize_t bonding_store_n_unsol_na(struct device *d,
struct bonding *bond = to_bond(d); struct bonding *bond = to_bond(d);
if (sscanf(buf, "%d", &new_value) != 1) { if (sscanf(buf, "%d", &new_value) != 1) {
pr_err(DRV_NAME pr_err("%s: no num_unsol_na value specified.\n",
": %s: no num_unsol_na value specified.\n",
bond->dev->name); bond->dev->name);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
if (new_value < 0 || new_value > 255) { if (new_value < 0 || new_value > 255) {
pr_err(DRV_NAME pr_err("%s: Invalid num_unsol_na value %d not in range 0-255; rejected.\n",
": %s: Invalid num_unsol_na value %d not in range 0-255; rejected.\n",
bond->dev->name, new_value); bond->dev->name, new_value);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
@ -1075,40 +1023,31 @@ static ssize_t bonding_store_miimon(struct device *d,
struct bonding *bond = to_bond(d); struct bonding *bond = to_bond(d);
if (sscanf(buf, "%d", &new_value) != 1) { if (sscanf(buf, "%d", &new_value) != 1) {
pr_err(DRV_NAME pr_err("%s: no miimon value specified.\n",
": %s: no miimon value specified.\n",
bond->dev->name); bond->dev->name);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
if (new_value < 0) { if (new_value < 0) {
pr_err(DRV_NAME pr_err("%s: Invalid miimon value %d not in range %d-%d; rejected.\n",
": %s: Invalid miimon value %d not in range %d-%d; rejected.\n",
bond->dev->name, new_value, 1, INT_MAX); bond->dev->name, new_value, 1, INT_MAX);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} else { } else {
pr_info(DRV_NAME pr_info("%s: Setting MII monitoring interval to %d.\n",
": %s: Setting MII monitoring interval to %d.\n", bond->dev->name, new_value);
bond->dev->name, new_value);
bond->params.miimon = new_value; bond->params.miimon = new_value;
if (bond->params.updelay) if (bond->params.updelay)
pr_info(DRV_NAME pr_info("%s: Note: Updating updelay (to %d) since it is a multiple of the miimon value.\n",
": %s: Note: Updating updelay (to %d) " bond->dev->name,
"since it is a multiple of the miimon value.\n", bond->params.updelay * bond->params.miimon);
bond->dev->name,
bond->params.updelay * bond->params.miimon);
if (bond->params.downdelay) if (bond->params.downdelay)
pr_info(DRV_NAME pr_info("%s: Note: Updating downdelay (to %d) since it is a multiple of the miimon value.\n",
": %s: Note: Updating downdelay (to %d) " bond->dev->name,
"since it is a multiple of the miimon value.\n", bond->params.downdelay * bond->params.miimon);
bond->dev->name,
bond->params.downdelay * bond->params.miimon);
if (bond->params.arp_interval) { if (bond->params.arp_interval) {
pr_info(DRV_NAME pr_info("%s: MII monitoring cannot be used with ARP monitoring. Disabling ARP monitoring...\n",
": %s: MII monitoring cannot be used with " bond->dev->name);
"ARP monitoring. Disabling ARP monitoring...\n",
bond->dev->name);
bond->params.arp_interval = 0; bond->params.arp_interval = 0;
bond->dev->priv_flags &= ~IFF_MASTER_ARPMON; bond->dev->priv_flags &= ~IFF_MASTER_ARPMON;
if (bond->params.arp_validate) { if (bond->params.arp_validate) {
@ -1176,17 +1115,15 @@ static ssize_t bonding_store_primary(struct device *d,
write_lock_bh(&bond->curr_slave_lock); write_lock_bh(&bond->curr_slave_lock);
if (!USES_PRIMARY(bond->params.mode)) { if (!USES_PRIMARY(bond->params.mode)) {
pr_info(DRV_NAME pr_info("%s: Unable to set primary slave; %s is in mode %d\n",
": %s: Unable to set primary slave; %s is in mode %d\n", bond->dev->name, bond->dev->name, bond->params.mode);
bond->dev->name, bond->dev->name, bond->params.mode);
} else { } else {
bond_for_each_slave(bond, slave, i) { bond_for_each_slave(bond, slave, i) {
if (strnicmp if (strnicmp
(slave->dev->name, buf, (slave->dev->name, buf,
strlen(slave->dev->name)) == 0) { strlen(slave->dev->name)) == 0) {
pr_info(DRV_NAME pr_info("%s: Setting %s as primary slave.\n",
": %s: Setting %s as primary slave.\n", bond->dev->name, slave->dev->name);
bond->dev->name, slave->dev->name);
bond->primary_slave = slave; bond->primary_slave = slave;
strcpy(bond->params.primary, slave->dev->name); strcpy(bond->params.primary, slave->dev->name);
bond_select_active_slave(bond); bond_select_active_slave(bond);
@ -1197,15 +1134,13 @@ static ssize_t bonding_store_primary(struct device *d,
/* if we got here, then we didn't match the name of any slave */ /* if we got here, then we didn't match the name of any slave */
if (strlen(buf) == 0 || buf[0] == '\n') { if (strlen(buf) == 0 || buf[0] == '\n') {
pr_info(DRV_NAME pr_info("%s: Setting primary slave to None.\n",
": %s: Setting primary slave to None.\n", bond->dev->name);
bond->dev->name);
bond->primary_slave = NULL; bond->primary_slave = NULL;
bond_select_active_slave(bond); bond_select_active_slave(bond);
} else { } else {
pr_info(DRV_NAME pr_info("%s: Unable to set %.*s as primary slave as it is not a slave.\n",
": %s: Unable to set %.*s as primary slave as it is not a slave.\n", bond->dev->name, (int)strlen(buf) - 1, buf);
bond->dev->name, (int)strlen(buf) - 1, buf);
} }
} }
out: out:
@ -1244,8 +1179,7 @@ static ssize_t bonding_store_primary_reselect(struct device *d,
new_value = bond_parse_parm(buf, pri_reselect_tbl); new_value = bond_parse_parm(buf, pri_reselect_tbl);
if (new_value < 0) { if (new_value < 0) {
pr_err(DRV_NAME pr_err("%s: Ignoring invalid primary_reselect value %.*s.\n",
": %s: Ignoring invalid primary_reselect value %.*s.\n",
bond->dev->name, bond->dev->name,
(int) strlen(buf) - 1, buf); (int) strlen(buf) - 1, buf);
ret = -EINVAL; ret = -EINVAL;
@ -1253,7 +1187,7 @@ static ssize_t bonding_store_primary_reselect(struct device *d,
} }
bond->params.primary_reselect = new_value; bond->params.primary_reselect = new_value;
pr_info(DRV_NAME ": %s: setting primary_reselect to %s (%d).\n", pr_info("%s: setting primary_reselect to %s (%d).\n",
bond->dev->name, pri_reselect_tbl[new_value].modename, bond->dev->name, pri_reselect_tbl[new_value].modename,
new_value); new_value);
@ -1291,20 +1225,18 @@ static ssize_t bonding_store_carrier(struct device *d,
if (sscanf(buf, "%d", &new_value) != 1) { if (sscanf(buf, "%d", &new_value) != 1) {
pr_err(DRV_NAME pr_err("%s: no use_carrier value specified.\n",
": %s: no use_carrier value specified.\n",
bond->dev->name); bond->dev->name);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
if ((new_value == 0) || (new_value == 1)) { if ((new_value == 0) || (new_value == 1)) {
bond->params.use_carrier = new_value; bond->params.use_carrier = new_value;
pr_info(DRV_NAME ": %s: Setting use_carrier to %d.\n", pr_info("%s: Setting use_carrier to %d.\n",
bond->dev->name, new_value); bond->dev->name, new_value);
} else { } else {
pr_info(DRV_NAME pr_info("%s: Ignoring invalid use_carrier value %d.\n",
": %s: Ignoring invalid use_carrier value %d.\n", bond->dev->name, new_value);
bond->dev->name, new_value);
} }
out: out:
return count; return count;
@ -1349,8 +1281,7 @@ static ssize_t bonding_store_active_slave(struct device *d,
write_lock_bh(&bond->curr_slave_lock); write_lock_bh(&bond->curr_slave_lock);
if (!USES_PRIMARY(bond->params.mode)) if (!USES_PRIMARY(bond->params.mode))
pr_info(DRV_NAME ": %s: Unable to change active slave;" pr_info("%s: Unable to change active slave; %s is in mode %d\n",
" %s is in mode %d\n",
bond->dev->name, bond->dev->name, bond->params.mode); bond->dev->name, bond->dev->name, bond->params.mode);
else { else {
bond_for_each_slave(bond, slave, i) { bond_for_each_slave(bond, slave, i) {
@ -1361,9 +1292,9 @@ static ssize_t bonding_store_active_slave(struct device *d,
new_active = slave; new_active = slave;
if (new_active == old_active) { if (new_active == old_active) {
/* do nothing */ /* do nothing */
pr_info(DRV_NAME pr_info("%s: %s is already the current active slave.\n",
": %s: %s is already the current active slave.\n", bond->dev->name,
bond->dev->name, slave->dev->name); slave->dev->name);
goto out; goto out;
} }
else { else {
@ -1371,16 +1302,15 @@ static ssize_t bonding_store_active_slave(struct device *d,
(old_active) && (old_active) &&
(new_active->link == BOND_LINK_UP) && (new_active->link == BOND_LINK_UP) &&
IS_UP(new_active->dev)) { IS_UP(new_active->dev)) {
pr_info(DRV_NAME pr_info("%s: Setting %s as active slave.\n",
": %s: Setting %s as active slave.\n", bond->dev->name,
bond->dev->name, slave->dev->name); slave->dev->name);
bond_change_active_slave(bond, new_active); bond_change_active_slave(bond, new_active);
} }
else { else {
pr_info(DRV_NAME pr_info("%s: Could not set %s as active slave; either %s is down or the link is down.\n",
": %s: Could not set %s as active slave; " bond->dev->name,
"either %s is down or the link is down.\n", slave->dev->name,
bond->dev->name, slave->dev->name,
slave->dev->name); slave->dev->name);
} }
goto out; goto out;
@ -1391,14 +1321,12 @@ static ssize_t bonding_store_active_slave(struct device *d,
/* if we got here, then we didn't match the name of any slave */ /* if we got here, then we didn't match the name of any slave */
if (strlen(buf) == 0 || buf[0] == '\n') { if (strlen(buf) == 0 || buf[0] == '\n') {
pr_info(DRV_NAME pr_info("%s: Setting active slave to None.\n",
": %s: Setting active slave to None.\n",
bond->dev->name); bond->dev->name);
bond->primary_slave = NULL; bond->primary_slave = NULL;
bond_select_active_slave(bond); bond_select_active_slave(bond);
} else { } else {
pr_info(DRV_NAME ": %s: Unable to set %.*s" pr_info("%s: Unable to set %.*s as active slave as it is not a slave.\n",
" as active slave as it is not a slave.\n",
bond->dev->name, (int)strlen(buf) - 1, buf); bond->dev->name, (int)strlen(buf) - 1, buf);
} }
} }
@ -1600,8 +1528,7 @@ int bond_create_sysfs(void)
/* Is someone being kinky and naming a device bonding_master? */ /* Is someone being kinky and naming a device bonding_master? */
if (__dev_get_by_name(&init_net, if (__dev_get_by_name(&init_net,
class_attr_bonding_masters.attr.name)) class_attr_bonding_masters.attr.name))
pr_err("network device named %s already " pr_err("network device named %s already exists in sysfs",
"exists in sysfs",
class_attr_bonding_masters.attr.name); class_attr_bonding_masters.attr.name);
ret = 0; ret = 0;
} }

View File

@ -50,7 +50,7 @@ config CAN_TI_HECC
config CAN_MCP251X config CAN_MCP251X
tristate "Microchip MCP251x SPI CAN controllers" tristate "Microchip MCP251x SPI CAN controllers"
depends on CAN_DEV && SPI depends on CAN_DEV && SPI && HAS_DMA
---help--- ---help---
Driver for the Microchip MCP251x SPI CAN controllers. Driver for the Microchip MCP251x SPI CAN controllers.

View File

@ -474,7 +474,7 @@ static void at91_read_mb(struct net_device *dev, unsigned int mb,
reg_msr = at91_read(priv, AT91_MSR(mb)); reg_msr = at91_read(priv, AT91_MSR(mb));
if (reg_msr & AT91_MSR_MRTR) if (reg_msr & AT91_MSR_MRTR)
cf->can_id |= CAN_RTR_FLAG; cf->can_id |= CAN_RTR_FLAG;
cf->can_dlc = min_t(__u8, (reg_msr >> 16) & 0xf, 8); cf->can_dlc = get_can_dlc((reg_msr >> 16) & 0xf);
*(u32 *)(cf->data + 0) = at91_read(priv, AT91_MDL(mb)); *(u32 *)(cf->data + 0) = at91_read(priv, AT91_MDL(mb));
*(u32 *)(cf->data + 4) = at91_read(priv, AT91_MDH(mb)); *(u32 *)(cf->data + 4) = at91_read(priv, AT91_MDH(mb));

View File

@ -392,7 +392,7 @@ static void bfin_can_rx(struct net_device *dev, u16 isrc)
cf->can_id |= CAN_RTR_FLAG; cf->can_id |= CAN_RTR_FLAG;
/* get data length code */ /* get data length code */
cf->can_dlc = bfin_read16(&reg->chl[obj].dlc); cf->can_dlc = get_can_dlc(bfin_read16(&reg->chl[obj].dlc) & 0xF);
/* get payload */ /* get payload */
for (i = 0; i < 8; i += 2) { for (i = 0; i < 8; i += 2) {

View File

@ -403,9 +403,8 @@ static void mcp251x_hw_rx_frame(struct spi_device *spi, u8 *buf,
for (i = 1; i < RXBDAT_OFF; i++) for (i = 1; i < RXBDAT_OFF; i++)
buf[i] = mcp251x_read_reg(spi, RXBCTRL(buf_idx) + i); buf[i] = mcp251x_read_reg(spi, RXBCTRL(buf_idx) + i);
len = buf[RXBDLC_OFF] & RXBDLC_LEN_MASK;
if (len > 8) len = get_can_dlc(buf[RXBDLC_OFF] & RXBDLC_LEN_MASK);
len = 8;
for (; i < (RXBDAT_OFF + len); i++) for (; i < (RXBDAT_OFF + len); i++)
buf[i] = mcp251x_read_reg(spi, RXBCTRL(buf_idx) + i); buf[i] = mcp251x_read_reg(spi, RXBCTRL(buf_idx) + i);
} else { } else {
@ -455,13 +454,7 @@ static void mcp251x_hw_rx(struct spi_device *spi, int buf_idx)
(buf[RXBSIDL_OFF] >> RXBSIDL_SHIFT); (buf[RXBSIDL_OFF] >> RXBSIDL_SHIFT);
} }
/* Data length */ /* Data length */
frame->can_dlc = buf[RXBDLC_OFF] & RXBDLC_LEN_MASK; frame->can_dlc = get_can_dlc(buf[RXBDLC_OFF] & RXBDLC_LEN_MASK);
if (frame->can_dlc > 8) {
dev_warn(&spi->dev, "invalid frame recevied\n");
priv->net->stats.rx_errors++;
dev_kfree_skb(skb);
return;
}
memcpy(frame->data, buf + RXBDAT_OFF, frame->can_dlc); memcpy(frame->data, buf + RXBDAT_OFF, frame->can_dlc);
priv->net->stats.rx_packets++; priv->net->stats.rx_packets++;

View File

@ -297,7 +297,8 @@ static void mscan_get_rx_frame(struct net_device *dev, struct can_frame *frame)
frame->can_id |= can_id >> 1; frame->can_id |= can_id >> 1;
if (can_id & 1) if (can_id & 1)
frame->can_id |= CAN_RTR_FLAG; frame->can_id |= CAN_RTR_FLAG;
frame->can_dlc = in_8(&regs->rx.dlr) & 0xf;
frame->can_dlc = get_can_dlc(in_8(&regs->rx.dlr) & 0xf);
if (!(frame->can_id & CAN_RTR_FLAG)) { if (!(frame->can_id & CAN_RTR_FLAG)) {
void __iomem *data = &regs->rx.dsr1_0; void __iomem *data = &regs->rx.dsr1_0;

View File

@ -293,15 +293,14 @@ static void sja1000_rx(struct net_device *dev)
uint8_t fi; uint8_t fi;
uint8_t dreg; uint8_t dreg;
canid_t id; canid_t id;
uint8_t dlc;
int i; int i;
/* create zero'ed CAN frame buffer */
skb = alloc_can_skb(dev, &cf); skb = alloc_can_skb(dev, &cf);
if (skb == NULL) if (skb == NULL)
return; return;
fi = priv->read_reg(priv, REG_FI); fi = priv->read_reg(priv, REG_FI);
dlc = fi & 0x0F;
if (fi & FI_FF) { if (fi & FI_FF) {
/* extended frame format (EFF) */ /* extended frame format (EFF) */
@ -318,16 +317,15 @@ static void sja1000_rx(struct net_device *dev)
| (priv->read_reg(priv, REG_ID2) >> 5); | (priv->read_reg(priv, REG_ID2) >> 5);
} }
if (fi & FI_RTR) if (fi & FI_RTR) {
id |= CAN_RTR_FLAG; id |= CAN_RTR_FLAG;
} else {
cf->can_dlc = get_can_dlc(fi & 0x0F);
for (i = 0; i < cf->can_dlc; i++)
cf->data[i] = priv->read_reg(priv, dreg++);
}
cf->can_id = id; cf->can_id = id;
cf->can_dlc = dlc;
for (i = 0; i < dlc; i++)
cf->data[i] = priv->read_reg(priv, dreg++);
while (i < 8)
cf->data[i++] = 0;
/* release receive buffer */ /* release receive buffer */
priv->write_reg(priv, REG_CMR, CMD_RRB); priv->write_reg(priv, REG_CMR, CMD_RRB);
@ -335,7 +333,7 @@ static void sja1000_rx(struct net_device *dev)
netif_rx(skb); netif_rx(skb);
stats->rx_packets++; stats->rx_packets++;
stats->rx_bytes += dlc; stats->rx_bytes += cf->can_dlc;
} }
static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status) static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status)

View File

@ -552,7 +552,7 @@ static int ti_hecc_rx_pkt(struct ti_hecc_priv *priv, int mbxno)
data = hecc_read_mbx(priv, mbxno, HECC_CANMCF); data = hecc_read_mbx(priv, mbxno, HECC_CANMCF);
if (data & HECC_CANMCF_RTR) if (data & HECC_CANMCF_RTR)
cf->can_id |= CAN_RTR_FLAG; cf->can_id |= CAN_RTR_FLAG;
cf->can_dlc = data & 0xF; cf->can_dlc = get_can_dlc(data & 0xF);
data = hecc_read_mbx(priv, mbxno, HECC_CANMDL); data = hecc_read_mbx(priv, mbxno, HECC_CANMDL);
*(u32 *)(cf->data) = cpu_to_be32(data); *(u32 *)(cf->data) = cpu_to_be32(data);
if (cf->can_dlc > 4) { if (cf->can_dlc > 4) {

View File

@ -316,7 +316,7 @@ static void ems_usb_rx_can_msg(struct ems_usb *dev, struct ems_cpc_msg *msg)
return; return;
cf->can_id = le32_to_cpu(msg->msg.can_msg.id); cf->can_id = le32_to_cpu(msg->msg.can_msg.id);
cf->can_dlc = min_t(u8, msg->msg.can_msg.length, 8); cf->can_dlc = get_can_dlc(msg->msg.can_msg.length & 0xF);
if (msg->type == CPC_MSG_TYPE_EXT_CAN_FRAME || if (msg->type == CPC_MSG_TYPE_EXT_CAN_FRAME ||
msg->type == CPC_MSG_TYPE_EXT_RTR_FRAME) msg->type == CPC_MSG_TYPE_EXT_RTR_FRAME)

View File

@ -1163,7 +1163,7 @@ static int __devinit cpmac_probe(struct platform_device *pdev)
priv->dev = dev; priv->dev = dev;
priv->ring_size = 64; priv->ring_size = 64;
priv->msg_enable = netif_msg_init(debug_level, 0xff); priv->msg_enable = netif_msg_init(debug_level, 0xff);
memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr)); memcpy(dev->dev_addr, pdata->dev_addr, sizeof(pdata->dev_addr));
snprintf(priv->phy_name, MII_BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id); snprintf(priv->phy_name, MII_BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id);

View File

@ -509,6 +509,40 @@ static s32 ixgbe_start_mac_link_82598(struct ixgbe_hw *hw,
return status; return status;
} }
/**
* ixgbe_validate_link_ready - Function looks for phy link
* @hw: pointer to hardware structure
*
* Function indicates success when phy link is available. If phy is not ready
* within 5 seconds of MAC indicating link, the function returns error.
**/
static s32 ixgbe_validate_link_ready(struct ixgbe_hw *hw)
{
u32 timeout;
u16 an_reg;
if (hw->device_id != IXGBE_DEV_ID_82598AT2)
return 0;
for (timeout = 0;
timeout < IXGBE_VALIDATE_LINK_READY_TIMEOUT; timeout++) {
hw->phy.ops.read_reg(hw, MDIO_STAT1, MDIO_MMD_AN, &an_reg);
if ((an_reg & MDIO_AN_STAT1_COMPLETE) &&
(an_reg & MDIO_STAT1_LSTATUS))
break;
msleep(100);
}
if (timeout == IXGBE_VALIDATE_LINK_READY_TIMEOUT) {
hw_dbg(hw, "Link was indicated but link is down\n");
return IXGBE_ERR_LINK_SETUP;
}
return 0;
}
/** /**
* ixgbe_check_mac_link_82598 - Get link/speed status * ixgbe_check_mac_link_82598 - Get link/speed status
* @hw: pointer to hardware structure * @hw: pointer to hardware structure
@ -589,6 +623,10 @@ static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw,
else else
*speed = IXGBE_LINK_SPEED_1GB_FULL; *speed = IXGBE_LINK_SPEED_1GB_FULL;
if ((hw->device_id == IXGBE_DEV_ID_82598AT2) && (*link_up == true) &&
(ixgbe_validate_link_ready(hw) != 0))
*link_up = false;
/* if link is down, zero out the current_mode */ /* if link is down, zero out the current_mode */
if (*link_up == false) { if (*link_up == false) {
hw->fc.current_mode = ixgbe_fc_none; hw->fc.current_mode = ixgbe_fc_none;

View File

@ -4511,6 +4511,7 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter)
struct ixgbe_hw *hw = &adapter->hw; struct ixgbe_hw *hw = &adapter->hw;
u64 total_mpc = 0; u64 total_mpc = 0;
u32 i, missed_rx = 0, mpc, bprc, lxon, lxoff, xon_off_tot; u32 i, missed_rx = 0, mpc, bprc, lxon, lxoff, xon_off_tot;
u64 non_eop_descs = 0, restart_queue = 0;
if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) { if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) {
u64 rsc_count = 0; u64 rsc_count = 0;
@ -4528,10 +4529,12 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter)
/* gather some stats to the adapter struct that are per queue */ /* gather some stats to the adapter struct that are per queue */
for (i = 0; i < adapter->num_tx_queues; i++) for (i = 0; i < adapter->num_tx_queues; i++)
adapter->restart_queue += adapter->tx_ring[i].restart_queue; restart_queue += adapter->tx_ring[i].restart_queue;
adapter->restart_queue = restart_queue;
for (i = 0; i < adapter->num_rx_queues; i++) for (i = 0; i < adapter->num_rx_queues; i++)
adapter->non_eop_descs += adapter->tx_ring[i].non_eop_descs; non_eop_descs += adapter->rx_ring[i].non_eop_descs;
adapter->non_eop_descs = non_eop_descs;
adapter->stats.crcerrs += IXGBE_READ_REG(hw, IXGBE_CRCERRS); adapter->stats.crcerrs += IXGBE_READ_REG(hw, IXGBE_CRCERRS);
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
@ -5003,7 +5006,18 @@ static bool ixgbe_tx_csum(struct ixgbe_adapter *adapter,
IXGBE_ADVTXD_DTYP_CTXT); IXGBE_ADVTXD_DTYP_CTXT);
if (skb->ip_summed == CHECKSUM_PARTIAL) { if (skb->ip_summed == CHECKSUM_PARTIAL) {
switch (skb->protocol) { __be16 protocol;
if (skb->protocol == cpu_to_be16(ETH_P_8021Q)) {
const struct vlan_ethhdr *vhdr =
(const struct vlan_ethhdr *)skb->data;
protocol = vhdr->h_vlan_encapsulated_proto;
} else {
protocol = skb->protocol;
}
switch (protocol) {
case cpu_to_be16(ETH_P_IP): case cpu_to_be16(ETH_P_IP):
type_tucmd_mlhl |= IXGBE_ADVTXD_TUCMD_IPV4; type_tucmd_mlhl |= IXGBE_ADVTXD_TUCMD_IPV4;
if (ip_hdr(skb)->protocol == IPPROTO_TCP) if (ip_hdr(skb)->protocol == IPPROTO_TCP)

View File

@ -841,6 +841,8 @@
#define IXGBE_MPVC 0x04318 #define IXGBE_MPVC 0x04318
#define IXGBE_SGMIIC 0x04314 #define IXGBE_SGMIIC 0x04314
#define IXGBE_VALIDATE_LINK_READY_TIMEOUT 50
/* Omer CORECTL */ /* Omer CORECTL */
#define IXGBE_CORECTL 0x014F00 #define IXGBE_CORECTL 0x014F00
/* BARCTRL */ /* BARCTRL */

View File

@ -53,7 +53,7 @@ static int mlx4_SENSE_PORT(struct mlx4_dev *dev, int port,
if (out_param > 2) { if (out_param > 2) {
mlx4_err(dev, "Sense returned illegal value: 0x%llx\n", out_param); mlx4_err(dev, "Sense returned illegal value: 0x%llx\n", out_param);
return EINVAL; return -EINVAL;
} }
*type = out_param; *type = out_param;

View File

@ -912,7 +912,11 @@ static void media_check(unsigned long arg)
if ((inw(ioaddr + EL3_STATUS) & IntLatch) && (inb(ioaddr + Timer) == 0xff)) { if ((inw(ioaddr + EL3_STATUS) & IntLatch) && (inb(ioaddr + Timer) == 0xff)) {
if (!lp->fast_poll) if (!lp->fast_poll)
printk(KERN_INFO "%s: interrupt(s) dropped!\n", dev->name); printk(KERN_INFO "%s: interrupt(s) dropped!\n", dev->name);
local_irq_save(flags);
el3_interrupt(dev->irq, dev); el3_interrupt(dev->irq, dev);
local_irq_restore(flags);
lp->fast_poll = HZ; lp->fast_poll = HZ;
} }
if (lp->fast_poll) { if (lp->fast_poll) {

View File

@ -711,7 +711,11 @@ static void media_check(unsigned long arg)
(inb(ioaddr + EL3_TIMER) == 0xff)) { (inb(ioaddr + EL3_TIMER) == 0xff)) {
if (!lp->fast_poll) if (!lp->fast_poll)
printk(KERN_WARNING "%s: interrupt(s) dropped!\n", dev->name); printk(KERN_WARNING "%s: interrupt(s) dropped!\n", dev->name);
local_irq_save(flags);
el3_interrupt(dev->irq, dev); el3_interrupt(dev->irq, dev);
local_irq_restore(flags);
lp->fast_poll = HZ; lp->fast_poll = HZ;
} }
if (lp->fast_poll) { if (lp->fast_poll) {

View File

@ -47,7 +47,7 @@ static const unsigned char payload_source[ETH_ALEN] = {
0x00, 0x0f, 0x53, 0x1b, 0x1b, 0x1b, 0x00, 0x0f, 0x53, 0x1b, 0x1b, 0x1b,
}; };
static const char *payload_msg = static const char payload_msg[] =
"Hello world! This is an Efx loopback test in progress!"; "Hello world! This is an Efx loopback test in progress!";
/** /**

View File

@ -84,6 +84,8 @@ static struct sh_eth_cpu_data sh_eth_my_cpu_data = {
.mpr = 1, .mpr = 1,
.tpauser = 1, .tpauser = 1,
.hw_swap = 1, .hw_swap = 1,
.rpadir = 1,
.rpadir_value = 0x00020000, /* NET_IP_ALIGN assumed to be 2 */
}; };
#elif defined(CONFIG_CPU_SUBTYPE_SH7763) #elif defined(CONFIG_CPU_SUBTYPE_SH7763)
@ -175,7 +177,6 @@ static struct sh_eth_cpu_data sh_eth_my_cpu_data = {
.tpauser = 1, .tpauser = 1,
.bculr = 1, .bculr = 1,
.hw_swap = 1, .hw_swap = 1,
.rpadir = 1,
.no_trimd = 1, .no_trimd = 1,
.no_ade = 1, .no_ade = 1,
}; };
@ -501,6 +502,8 @@ static int sh_eth_ring_init(struct net_device *ndev)
*/ */
mdp->rx_buf_sz = (ndev->mtu <= 1492 ? PKT_BUF_SZ : mdp->rx_buf_sz = (ndev->mtu <= 1492 ? PKT_BUF_SZ :
(((ndev->mtu + 26 + 7) & ~7) + 2 + 16)); (((ndev->mtu + 26 + 7) & ~7) + 2 + 16));
if (mdp->cd->rpadir)
mdp->rx_buf_sz += NET_IP_ALIGN;
/* Allocate RX and TX skb rings */ /* Allocate RX and TX skb rings */
mdp->rx_skbuff = kmalloc(sizeof(*mdp->rx_skbuff) * RX_RING_SIZE, mdp->rx_skbuff = kmalloc(sizeof(*mdp->rx_skbuff) * RX_RING_SIZE,
@ -715,6 +718,8 @@ static int sh_eth_rx(struct net_device *ndev)
pkt_len + 2); pkt_len + 2);
skb = mdp->rx_skbuff[entry]; skb = mdp->rx_skbuff[entry];
mdp->rx_skbuff[entry] = NULL; mdp->rx_skbuff[entry] = NULL;
if (mdp->cd->rpadir)
skb_reserve(skb, NET_IP_ALIGN);
skb_put(skb, pkt_len); skb_put(skb, pkt_len);
skb->protocol = eth_type_trans(skb, ndev); skb->protocol = eth_type_trans(skb, ndev);
netif_rx(skb); netif_rx(skb);

View File

@ -644,7 +644,6 @@ static void sky2_phy_power_up(struct sky2_hw *hw, unsigned port)
{ {
u32 reg1; u32 reg1;
sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
reg1 = sky2_pci_read32(hw, PCI_DEV_REG1); reg1 = sky2_pci_read32(hw, PCI_DEV_REG1);
reg1 &= ~phy_power[port]; reg1 &= ~phy_power[port];
@ -652,7 +651,6 @@ static void sky2_phy_power_up(struct sky2_hw *hw, unsigned port)
reg1 |= coma_mode[port]; reg1 |= coma_mode[port];
sky2_pci_write32(hw, PCI_DEV_REG1, reg1); sky2_pci_write32(hw, PCI_DEV_REG1, reg1);
sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
sky2_pci_read32(hw, PCI_DEV_REG1); sky2_pci_read32(hw, PCI_DEV_REG1);
if (hw->chip_id == CHIP_ID_YUKON_FE) if (hw->chip_id == CHIP_ID_YUKON_FE)
@ -709,11 +707,9 @@ static void sky2_phy_power_down(struct sky2_hw *hw, unsigned port)
gm_phy_write(hw, port, PHY_MARV_CTRL, PHY_CT_PDOWN); gm_phy_write(hw, port, PHY_MARV_CTRL, PHY_CT_PDOWN);
} }
sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
reg1 = sky2_pci_read32(hw, PCI_DEV_REG1); reg1 = sky2_pci_read32(hw, PCI_DEV_REG1);
reg1 |= phy_power[port]; /* set PHY to PowerDown/COMA Mode */ reg1 |= phy_power[port]; /* set PHY to PowerDown/COMA Mode */
sky2_pci_write32(hw, PCI_DEV_REG1, reg1); sky2_pci_write32(hw, PCI_DEV_REG1, reg1);
sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
} }
/* Force a renegotiation */ /* Force a renegotiation */
@ -2152,9 +2148,7 @@ static void sky2_qlink_intr(struct sky2_hw *hw)
/* reset PHY Link Detect */ /* reset PHY Link Detect */
phy = sky2_pci_read16(hw, PSM_CONFIG_REG4); phy = sky2_pci_read16(hw, PSM_CONFIG_REG4);
sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
sky2_pci_write16(hw, PSM_CONFIG_REG4, phy | 1); sky2_pci_write16(hw, PSM_CONFIG_REG4, phy | 1);
sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
sky2_link_up(sky2); sky2_link_up(sky2);
} }
@ -2645,7 +2639,6 @@ static void sky2_hw_intr(struct sky2_hw *hw)
if (status & (Y2_IS_MST_ERR | Y2_IS_IRQ_STAT)) { if (status & (Y2_IS_MST_ERR | Y2_IS_IRQ_STAT)) {
u16 pci_err; u16 pci_err;
sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
pci_err = sky2_pci_read16(hw, PCI_STATUS); pci_err = sky2_pci_read16(hw, PCI_STATUS);
if (net_ratelimit()) if (net_ratelimit())
dev_err(&pdev->dev, "PCI hardware error (0x%x)\n", dev_err(&pdev->dev, "PCI hardware error (0x%x)\n",
@ -2653,14 +2646,12 @@ static void sky2_hw_intr(struct sky2_hw *hw)
sky2_pci_write16(hw, PCI_STATUS, sky2_pci_write16(hw, PCI_STATUS,
pci_err | PCI_STATUS_ERROR_BITS); pci_err | PCI_STATUS_ERROR_BITS);
sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
} }
if (status & Y2_IS_PCI_EXP) { if (status & Y2_IS_PCI_EXP) {
/* PCI-Express uncorrectable Error occurred */ /* PCI-Express uncorrectable Error occurred */
u32 err; u32 err;
sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
err = sky2_read32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS); err = sky2_read32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS);
sky2_write32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS, sky2_write32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS,
0xfffffffful); 0xfffffffful);
@ -2668,7 +2659,6 @@ static void sky2_hw_intr(struct sky2_hw *hw)
dev_err(&pdev->dev, "PCI Express error (0x%x)\n", err); dev_err(&pdev->dev, "PCI Express error (0x%x)\n", err);
sky2_read32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS); sky2_read32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS);
sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
} }
if (status & Y2_HWE_L1_MASK) if (status & Y2_HWE_L1_MASK)
@ -3047,7 +3037,6 @@ static void sky2_reset(struct sky2_hw *hw)
} }
sky2_power_on(hw); sky2_power_on(hw);
sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
for (i = 0; i < hw->ports; i++) { for (i = 0; i < hw->ports; i++) {
sky2_write8(hw, SK_REG(i, GMAC_LINK_CTRL), GMLC_RST_SET); sky2_write8(hw, SK_REG(i, GMAC_LINK_CTRL), GMLC_RST_SET);
@ -3084,7 +3073,6 @@ static void sky2_reset(struct sky2_hw *hw)
reg <<= PSM_CONFIG_REG4_TIMER_PHY_LINK_DETECT_BASE; reg <<= PSM_CONFIG_REG4_TIMER_PHY_LINK_DETECT_BASE;
/* reset PHY Link Detect */ /* reset PHY Link Detect */
sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
sky2_pci_write16(hw, PSM_CONFIG_REG4, sky2_pci_write16(hw, PSM_CONFIG_REG4,
reg | PSM_CONFIG_REG4_RST_PHY_LINK_DETECT); reg | PSM_CONFIG_REG4_RST_PHY_LINK_DETECT);
sky2_pci_write16(hw, PSM_CONFIG_REG4, reg); sky2_pci_write16(hw, PSM_CONFIG_REG4, reg);
@ -3102,7 +3090,6 @@ static void sky2_reset(struct sky2_hw *hw)
/* restore the PCIe Link Control register */ /* restore the PCIe Link Control register */
sky2_pci_write16(hw, cap + PCI_EXP_LNKCTL, reg); sky2_pci_write16(hw, cap + PCI_EXP_LNKCTL, reg);
} }
sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
/* re-enable PEX PM in PEX PHY debug reg. 8 (clear bit 12) */ /* re-enable PEX PM in PEX PHY debug reg. 8 (clear bit 12) */
sky2_write32(hw, Y2_PEX_PHY_DATA, PEX_DB_ACCESS | (0x08UL << 16)); sky2_write32(hw, Y2_PEX_PHY_DATA, PEX_DB_ACCESS | (0x08UL << 16));
@ -4530,7 +4517,7 @@ static const char *sky2_name(u8 chipid, char *buf, int sz)
"Optima", /* 0xbc */ "Optima", /* 0xbc */
}; };
if (chipid >= CHIP_ID_YUKON_XL && chipid < CHIP_ID_YUKON_OPT) if (chipid >= CHIP_ID_YUKON_XL && chipid <= CHIP_ID_YUKON_OPT)
strncpy(buf, name[chipid - CHIP_ID_YUKON_XL], sz); strncpy(buf, name[chipid - CHIP_ID_YUKON_XL], sz);
else else
snprintf(buf, sz, "(chip %#x)", chipid); snprintf(buf, sz, "(chip %#x)", chipid);

View File

@ -324,7 +324,7 @@ static int rtl8150_set_mac_address(struct net_device *netdev, void *p)
dbg("%02X:", netdev->dev_addr[i]); dbg("%02X:", netdev->dev_addr[i]);
dbg("%02X\n", netdev->dev_addr[i]); dbg("%02X\n", netdev->dev_addr[i]);
/* Set the IDR registers. */ /* Set the IDR registers. */
set_registers(dev, IDR, sizeof(netdev->dev_addr), netdev->dev_addr); set_registers(dev, IDR, netdev->addr_len, netdev->dev_addr);
#ifdef EEPROM_WRITE #ifdef EEPROM_WRITE
{ {
u8 cr; u8 cr;

View File

@ -51,6 +51,15 @@ struct can_priv {
struct sk_buff **echo_skb; struct sk_buff **echo_skb;
}; };
/*
* get_can_dlc(value) - helper macro to cast a given data length code (dlc)
* to __u8 and ensure the dlc value to be max. 8 bytes.
*
* To be used in the CAN netdriver receive path to ensure conformance with
* ISO 11898-1 Chapter 8.4.2.3 (DLC field)
*/
#define get_can_dlc(i) (min_t(__u8, (i), 8))
struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max); struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max);
void free_candev(struct net_device *dev); void free_candev(struct net_device *dev);

View File

@ -368,11 +368,9 @@ enum {
#define RTAX_MAX (__RTAX_MAX - 1) #define RTAX_MAX (__RTAX_MAX - 1)
#define RTAX_FEATURE_ECN 0x00000001 #define RTAX_FEATURE_ECN 0x00000001
#define RTAX_FEATURE_NO_SACK 0x00000002 #define RTAX_FEATURE_SACK 0x00000002
#define RTAX_FEATURE_NO_TSTAMP 0x00000004 #define RTAX_FEATURE_TIMESTAMP 0x00000004
#define RTAX_FEATURE_ALLFRAG 0x00000008 #define RTAX_FEATURE_ALLFRAG 0x00000008
#define RTAX_FEATURE_NO_WSCALE 0x00000010
#define RTAX_FEATURE_NO_DSACK 0x00000020
struct rta_session { struct rta_session {
__u8 proto; __u8 proto;

View File

@ -113,7 +113,7 @@ dst_metric(const struct dst_entry *dst, int metric)
static inline u32 static inline u32
dst_feature(const struct dst_entry *dst, u32 feature) dst_feature(const struct dst_entry *dst, u32 feature)
{ {
return (dst ? dst_metric(dst, RTAX_FEATURES) & feature : 0); return dst_metric(dst, RTAX_FEATURES) & feature;
} }
static inline u32 dst_mtu(const struct dst_entry *dst) static inline u32 dst_mtu(const struct dst_entry *dst)

View File

@ -337,6 +337,7 @@ enum ip_defrag_users {
IP_DEFRAG_CALL_RA_CHAIN, IP_DEFRAG_CALL_RA_CHAIN,
IP_DEFRAG_CONNTRACK_IN, IP_DEFRAG_CONNTRACK_IN,
IP_DEFRAG_CONNTRACK_OUT, IP_DEFRAG_CONNTRACK_OUT,
IP_DEFRAG_CONNTRACK_BRIDGE_IN,
IP_DEFRAG_VS_IN, IP_DEFRAG_VS_IN,
IP_DEFRAG_VS_OUT, IP_DEFRAG_VS_OUT,
IP_DEFRAG_VS_FWD IP_DEFRAG_VS_FWD

View File

@ -350,8 +350,16 @@ static inline int ipv6_prefix_equal(const struct in6_addr *a1,
struct inet_frag_queue; struct inet_frag_queue;
enum ip6_defrag_users {
IP6_DEFRAG_LOCAL_DELIVER,
IP6_DEFRAG_CONNTRACK_IN,
IP6_DEFRAG_CONNTRACK_OUT,
IP6_DEFRAG_CONNTRACK_BRIDGE_IN,
};
struct ip6_create_arg { struct ip6_create_arg {
__be32 id; __be32 id;
u32 user;
struct in6_addr *src; struct in6_addr *src;
struct in6_addr *dst; struct in6_addr *dst;
}; };

View File

@ -9,7 +9,7 @@ extern struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6;
extern int nf_ct_frag6_init(void); extern int nf_ct_frag6_init(void);
extern void nf_ct_frag6_cleanup(void); extern void nf_ct_frag6_cleanup(void);
extern struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb); extern struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb, u32 user);
extern void nf_ct_frag6_output(unsigned int hooknum, struct sk_buff *skb, extern void nf_ct_frag6_output(unsigned int hooknum, struct sk_buff *skb,
struct net_device *in, struct net_device *in,
struct net_device *out, struct net_device *out,

View File

@ -408,8 +408,7 @@ extern int tcp_recvmsg(struct kiocb *iocb, struct sock *sk,
extern void tcp_parse_options(struct sk_buff *skb, extern void tcp_parse_options(struct sk_buff *skb,
struct tcp_options_received *opt_rx, struct tcp_options_received *opt_rx,
u8 **hvpp, u8 **hvpp,
int estab, int estab);
struct dst_entry *dst);
extern u8 *tcp_parse_md5sig_option(struct tcphdr *th); extern u8 *tcp_parse_md5sig_option(struct tcphdr *th);

View File

@ -5035,6 +5035,11 @@ int register_netdevice(struct net_device *dev)
rollback_registered(dev); rollback_registered(dev);
dev->reg_state = NETREG_UNREGISTERED; dev->reg_state = NETREG_UNREGISTERED;
} }
/*
* Prevent userspace races by waiting until the network
* device is fully setup before sending notifications.
*/
rtmsg_ifinfo(RTM_NEWLINK, dev, ~0U);
out: out:
return ret; return ret;
@ -5597,6 +5602,12 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
/* Notify protocols, that a new device appeared. */ /* Notify protocols, that a new device appeared. */
call_netdevice_notifiers(NETDEV_REGISTER, dev); call_netdevice_notifiers(NETDEV_REGISTER, dev);
/*
* Prevent userspace races by waiting until the network
* device is fully setup before sending notifications.
*/
rtmsg_ifinfo(RTM_NEWLINK, dev, ~0U);
synchronize_net(); synchronize_net();
err = 0; err = 0;
out: out:

View File

@ -1364,15 +1364,15 @@ static int rtnetlink_event(struct notifier_block *this, unsigned long event, voi
case NETDEV_UNREGISTER: case NETDEV_UNREGISTER:
rtmsg_ifinfo(RTM_DELLINK, dev, ~0U); rtmsg_ifinfo(RTM_DELLINK, dev, ~0U);
break; break;
case NETDEV_REGISTER:
rtmsg_ifinfo(RTM_NEWLINK, dev, ~0U);
break;
case NETDEV_UP: case NETDEV_UP:
case NETDEV_DOWN: case NETDEV_DOWN:
rtmsg_ifinfo(RTM_NEWLINK, dev, IFF_UP|IFF_RUNNING); rtmsg_ifinfo(RTM_NEWLINK, dev, IFF_UP|IFF_RUNNING);
break; break;
case NETDEV_POST_INIT:
case NETDEV_REGISTER:
case NETDEV_CHANGE: case NETDEV_CHANGE:
case NETDEV_GOING_DOWN: case NETDEV_GOING_DOWN:
case NETDEV_UNREGISTER_BATCH:
break; break;
default: default:
rtmsg_ifinfo(RTM_NEWLINK, dev, 0); rtmsg_ifinfo(RTM_NEWLINK, dev, 0);

View File

@ -14,6 +14,7 @@
#include <net/route.h> #include <net/route.h>
#include <net/ip.h> #include <net/ip.h>
#include <linux/netfilter_bridge.h>
#include <linux/netfilter_ipv4.h> #include <linux/netfilter_ipv4.h>
#include <net/netfilter/ipv4/nf_defrag_ipv4.h> #include <net/netfilter/ipv4/nf_defrag_ipv4.h>
@ -34,6 +35,20 @@ static int nf_ct_ipv4_gather_frags(struct sk_buff *skb, u_int32_t user)
return err; return err;
} }
static enum ip_defrag_users nf_ct_defrag_user(unsigned int hooknum,
struct sk_buff *skb)
{
#ifdef CONFIG_BRIDGE_NETFILTER
if (skb->nf_bridge &&
skb->nf_bridge->mask & BRNF_NF_BRIDGE_PREROUTING)
return IP_DEFRAG_CONNTRACK_BRIDGE_IN;
#endif
if (hooknum == NF_INET_PRE_ROUTING)
return IP_DEFRAG_CONNTRACK_IN;
else
return IP_DEFRAG_CONNTRACK_OUT;
}
static unsigned int ipv4_conntrack_defrag(unsigned int hooknum, static unsigned int ipv4_conntrack_defrag(unsigned int hooknum,
struct sk_buff *skb, struct sk_buff *skb,
const struct net_device *in, const struct net_device *in,
@ -50,10 +65,8 @@ static unsigned int ipv4_conntrack_defrag(unsigned int hooknum,
#endif #endif
/* Gather fragments. */ /* Gather fragments. */
if (ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)) { if (ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)) {
if (nf_ct_ipv4_gather_frags(skb, enum ip_defrag_users user = nf_ct_defrag_user(hooknum, skb);
hooknum == NF_INET_PRE_ROUTING ? if (nf_ct_ipv4_gather_frags(skb, user))
IP_DEFRAG_CONNTRACK_IN :
IP_DEFRAG_CONNTRACK_OUT))
return NF_STOLEN; return NF_STOLEN;
} }
return NF_ACCEPT; return NF_ACCEPT;

View File

@ -277,6 +277,13 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESRECV); NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESRECV);
/* check for timestamp cookie support */
memset(&tcp_opt, 0, sizeof(tcp_opt));
tcp_parse_options(skb, &tcp_opt, &hash_location, 0);
if (tcp_opt.saw_tstamp)
cookie_check_timestamp(&tcp_opt);
ret = NULL; ret = NULL;
req = inet_reqsk_alloc(&tcp_request_sock_ops); /* for safety */ req = inet_reqsk_alloc(&tcp_request_sock_ops); /* for safety */
if (!req) if (!req)
@ -292,6 +299,12 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
ireq->loc_addr = ip_hdr(skb)->daddr; ireq->loc_addr = ip_hdr(skb)->daddr;
ireq->rmt_addr = ip_hdr(skb)->saddr; ireq->rmt_addr = ip_hdr(skb)->saddr;
ireq->ecn_ok = 0; ireq->ecn_ok = 0;
ireq->snd_wscale = tcp_opt.snd_wscale;
ireq->rcv_wscale = tcp_opt.rcv_wscale;
ireq->sack_ok = tcp_opt.sack_ok;
ireq->wscale_ok = tcp_opt.wscale_ok;
ireq->tstamp_ok = tcp_opt.saw_tstamp;
req->ts_recent = tcp_opt.saw_tstamp ? tcp_opt.rcv_tsval : 0;
/* We throwed the options of the initial SYN away, so we hope /* We throwed the options of the initial SYN away, so we hope
* the ACK carries the same options again (see RFC1122 4.2.3.8) * the ACK carries the same options again (see RFC1122 4.2.3.8)
@ -340,20 +353,6 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
} }
} }
/* check for timestamp cookie support */
memset(&tcp_opt, 0, sizeof(tcp_opt));
tcp_parse_options(skb, &tcp_opt, &hash_location, 0, &rt->u.dst);
if (tcp_opt.saw_tstamp)
cookie_check_timestamp(&tcp_opt);
ireq->snd_wscale = tcp_opt.snd_wscale;
ireq->rcv_wscale = tcp_opt.rcv_wscale;
ireq->sack_ok = tcp_opt.sack_ok;
ireq->wscale_ok = tcp_opt.wscale_ok;
ireq->tstamp_ok = tcp_opt.saw_tstamp;
req->ts_recent = tcp_opt.saw_tstamp ? tcp_opt.rcv_tsval : 0;
/* Try to redo what tcp_v4_send_synack did. */ /* Try to redo what tcp_v4_send_synack did. */
req->window_clamp = tp->window_clamp ? :dst_metric(&rt->u.dst, RTAX_WINDOW); req->window_clamp = tp->window_clamp ? :dst_metric(&rt->u.dst, RTAX_WINDOW);

View File

@ -3727,7 +3727,7 @@ old_ack:
* the fast version below fails. * the fast version below fails.
*/ */
void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx, void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
u8 **hvpp, int estab, struct dst_entry *dst) u8 **hvpp, int estab)
{ {
unsigned char *ptr; unsigned char *ptr;
struct tcphdr *th = tcp_hdr(skb); struct tcphdr *th = tcp_hdr(skb);
@ -3766,8 +3766,7 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
break; break;
case TCPOPT_WINDOW: case TCPOPT_WINDOW:
if (opsize == TCPOLEN_WINDOW && th->syn && if (opsize == TCPOLEN_WINDOW && th->syn &&
!estab && sysctl_tcp_window_scaling && !estab && sysctl_tcp_window_scaling) {
!dst_feature(dst, RTAX_FEATURE_NO_WSCALE)) {
__u8 snd_wscale = *(__u8 *)ptr; __u8 snd_wscale = *(__u8 *)ptr;
opt_rx->wscale_ok = 1; opt_rx->wscale_ok = 1;
if (snd_wscale > 14) { if (snd_wscale > 14) {
@ -3783,8 +3782,7 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
case TCPOPT_TIMESTAMP: case TCPOPT_TIMESTAMP:
if ((opsize == TCPOLEN_TIMESTAMP) && if ((opsize == TCPOLEN_TIMESTAMP) &&
((estab && opt_rx->tstamp_ok) || ((estab && opt_rx->tstamp_ok) ||
(!estab && sysctl_tcp_timestamps && (!estab && sysctl_tcp_timestamps))) {
!dst_feature(dst, RTAX_FEATURE_NO_TSTAMP)))) {
opt_rx->saw_tstamp = 1; opt_rx->saw_tstamp = 1;
opt_rx->rcv_tsval = get_unaligned_be32(ptr); opt_rx->rcv_tsval = get_unaligned_be32(ptr);
opt_rx->rcv_tsecr = get_unaligned_be32(ptr + 4); opt_rx->rcv_tsecr = get_unaligned_be32(ptr + 4);
@ -3792,8 +3790,7 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
break; break;
case TCPOPT_SACK_PERM: case TCPOPT_SACK_PERM:
if (opsize == TCPOLEN_SACK_PERM && th->syn && if (opsize == TCPOLEN_SACK_PERM && th->syn &&
!estab && sysctl_tcp_sack && !estab && sysctl_tcp_sack) {
!dst_feature(dst, RTAX_FEATURE_NO_SACK)) {
opt_rx->sack_ok = 1; opt_rx->sack_ok = 1;
tcp_sack_reset(opt_rx); tcp_sack_reset(opt_rx);
} }
@ -3878,7 +3875,7 @@ static int tcp_fast_parse_options(struct sk_buff *skb, struct tcphdr *th,
if (tcp_parse_aligned_timestamp(tp, th)) if (tcp_parse_aligned_timestamp(tp, th))
return 1; return 1;
} }
tcp_parse_options(skb, &tp->rx_opt, hvpp, 1, NULL); tcp_parse_options(skb, &tp->rx_opt, hvpp, 1);
return 1; return 1;
} }
@ -4133,10 +4130,8 @@ static inline int tcp_sack_extend(struct tcp_sack_block *sp, u32 seq,
static void tcp_dsack_set(struct sock *sk, u32 seq, u32 end_seq) static void tcp_dsack_set(struct sock *sk, u32 seq, u32 end_seq)
{ {
struct tcp_sock *tp = tcp_sk(sk); struct tcp_sock *tp = tcp_sk(sk);
struct dst_entry *dst = __sk_dst_get(sk);
if (tcp_is_sack(tp) && sysctl_tcp_dsack && if (tcp_is_sack(tp) && sysctl_tcp_dsack) {
!dst_feature(dst, RTAX_FEATURE_NO_DSACK)) {
int mib_idx; int mib_idx;
if (before(seq, tp->rcv_nxt)) if (before(seq, tp->rcv_nxt))
@ -4165,15 +4160,13 @@ static void tcp_dsack_extend(struct sock *sk, u32 seq, u32 end_seq)
static void tcp_send_dupack(struct sock *sk, struct sk_buff *skb) static void tcp_send_dupack(struct sock *sk, struct sk_buff *skb)
{ {
struct tcp_sock *tp = tcp_sk(sk); struct tcp_sock *tp = tcp_sk(sk);
struct dst_entry *dst = __sk_dst_get(sk);
if (TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq && if (TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq &&
before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) { before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) {
NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_DELAYEDACKLOST); NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_DELAYEDACKLOST);
tcp_enter_quickack_mode(sk); tcp_enter_quickack_mode(sk);
if (tcp_is_sack(tp) && sysctl_tcp_dsack && if (tcp_is_sack(tp) && sysctl_tcp_dsack) {
!dst_feature(dst, RTAX_FEATURE_NO_DSACK)) {
u32 end_seq = TCP_SKB_CB(skb)->end_seq; u32 end_seq = TCP_SKB_CB(skb)->end_seq;
if (after(TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt)) if (after(TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt))
@ -5428,11 +5421,10 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,
u8 *hash_location; u8 *hash_location;
struct inet_connection_sock *icsk = inet_csk(sk); struct inet_connection_sock *icsk = inet_csk(sk);
struct tcp_sock *tp = tcp_sk(sk); struct tcp_sock *tp = tcp_sk(sk);
struct dst_entry *dst = __sk_dst_get(sk);
struct tcp_cookie_values *cvp = tp->cookie_values; struct tcp_cookie_values *cvp = tp->cookie_values;
int saved_clamp = tp->rx_opt.mss_clamp; int saved_clamp = tp->rx_opt.mss_clamp;
tcp_parse_options(skb, &tp->rx_opt, &hash_location, 0, dst); tcp_parse_options(skb, &tp->rx_opt, &hash_location, 0);
if (th->ack) { if (th->ack) {
/* rfc793: /* rfc793:

View File

@ -1262,20 +1262,10 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
tcp_rsk(req)->af_specific = &tcp_request_sock_ipv4_ops; tcp_rsk(req)->af_specific = &tcp_request_sock_ipv4_ops;
#endif #endif
ireq = inet_rsk(req);
ireq->loc_addr = daddr;
ireq->rmt_addr = saddr;
ireq->no_srccheck = inet_sk(sk)->transparent;
ireq->opt = tcp_v4_save_options(sk, skb);
dst = inet_csk_route_req(sk, req);
if(!dst)
goto drop_and_free;
tcp_clear_options(&tmp_opt); tcp_clear_options(&tmp_opt);
tmp_opt.mss_clamp = TCP_MSS_DEFAULT; tmp_opt.mss_clamp = TCP_MSS_DEFAULT;
tmp_opt.user_mss = tp->rx_opt.user_mss; tmp_opt.user_mss = tp->rx_opt.user_mss;
tcp_parse_options(skb, &tmp_opt, &hash_location, 0, dst); tcp_parse_options(skb, &tmp_opt, &hash_location, 0);
if (tmp_opt.cookie_plus > 0 && if (tmp_opt.cookie_plus > 0 &&
tmp_opt.saw_tstamp && tmp_opt.saw_tstamp &&
@ -1319,8 +1309,14 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
tmp_opt.tstamp_ok = tmp_opt.saw_tstamp; tmp_opt.tstamp_ok = tmp_opt.saw_tstamp;
tcp_openreq_init(req, &tmp_opt, skb); tcp_openreq_init(req, &tmp_opt, skb);
ireq = inet_rsk(req);
ireq->loc_addr = daddr;
ireq->rmt_addr = saddr;
ireq->no_srccheck = inet_sk(sk)->transparent;
ireq->opt = tcp_v4_save_options(sk, skb);
if (security_inet_conn_request(sk, skb, req)) if (security_inet_conn_request(sk, skb, req))
goto drop_and_release; goto drop_and_free;
if (!want_cookie) if (!want_cookie)
TCP_ECN_create_request(req, tcp_hdr(skb)); TCP_ECN_create_request(req, tcp_hdr(skb));
@ -1345,6 +1341,7 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
*/ */
if (tmp_opt.saw_tstamp && if (tmp_opt.saw_tstamp &&
tcp_death_row.sysctl_tw_recycle && tcp_death_row.sysctl_tw_recycle &&
(dst = inet_csk_route_req(sk, req)) != NULL &&
(peer = rt_get_peer((struct rtable *)dst)) != NULL && (peer = rt_get_peer((struct rtable *)dst)) != NULL &&
peer->v4daddr == saddr) { peer->v4daddr == saddr) {
if ((u32)get_seconds() - peer->tcp_ts_stamp < TCP_PAWS_MSL && if ((u32)get_seconds() - peer->tcp_ts_stamp < TCP_PAWS_MSL &&

View File

@ -95,9 +95,9 @@ tcp_timewait_state_process(struct inet_timewait_sock *tw, struct sk_buff *skb,
struct tcp_timewait_sock *tcptw = tcp_twsk((struct sock *)tw); struct tcp_timewait_sock *tcptw = tcp_twsk((struct sock *)tw);
int paws_reject = 0; int paws_reject = 0;
tmp_opt.saw_tstamp = 0;
if (th->doff > (sizeof(*th) >> 2) && tcptw->tw_ts_recent_stamp) { if (th->doff > (sizeof(*th) >> 2) && tcptw->tw_ts_recent_stamp) {
tmp_opt.tstamp_ok = 1; tcp_parse_options(skb, &tmp_opt, &hash_location, 0);
tcp_parse_options(skb, &tmp_opt, &hash_location, 1, NULL);
if (tmp_opt.saw_tstamp) { if (tmp_opt.saw_tstamp) {
tmp_opt.ts_recent = tcptw->tw_ts_recent; tmp_opt.ts_recent = tcptw->tw_ts_recent;
@ -526,9 +526,9 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,
__be32 flg = tcp_flag_word(th) & (TCP_FLAG_RST|TCP_FLAG_SYN|TCP_FLAG_ACK); __be32 flg = tcp_flag_word(th) & (TCP_FLAG_RST|TCP_FLAG_SYN|TCP_FLAG_ACK);
int paws_reject = 0; int paws_reject = 0;
if ((th->doff > (sizeof(*th) >> 2)) && (req->ts_recent)) { tmp_opt.saw_tstamp = 0;
tmp_opt.tstamp_ok = 1; if (th->doff > (sizeof(struct tcphdr)>>2)) {
tcp_parse_options(skb, &tmp_opt, &hash_location, 1, NULL); tcp_parse_options(skb, &tmp_opt, &hash_location, 0);
if (tmp_opt.saw_tstamp) { if (tmp_opt.saw_tstamp) {
tmp_opt.ts_recent = req->ts_recent; tmp_opt.ts_recent = req->ts_recent;

View File

@ -553,7 +553,6 @@ static unsigned tcp_syn_options(struct sock *sk, struct sk_buff *skb,
struct tcp_md5sig_key **md5) { struct tcp_md5sig_key **md5) {
struct tcp_sock *tp = tcp_sk(sk); struct tcp_sock *tp = tcp_sk(sk);
struct tcp_cookie_values *cvp = tp->cookie_values; struct tcp_cookie_values *cvp = tp->cookie_values;
struct dst_entry *dst = __sk_dst_get(sk);
unsigned remaining = MAX_TCP_OPTION_SPACE; unsigned remaining = MAX_TCP_OPTION_SPACE;
u8 cookie_size = (!tp->rx_opt.cookie_out_never && cvp != NULL) ? u8 cookie_size = (!tp->rx_opt.cookie_out_never && cvp != NULL) ?
tcp_cookie_size_check(cvp->cookie_desired) : tcp_cookie_size_check(cvp->cookie_desired) :
@ -581,22 +580,18 @@ static unsigned tcp_syn_options(struct sock *sk, struct sk_buff *skb,
opts->mss = tcp_advertise_mss(sk); opts->mss = tcp_advertise_mss(sk);
remaining -= TCPOLEN_MSS_ALIGNED; remaining -= TCPOLEN_MSS_ALIGNED;
if (likely(sysctl_tcp_timestamps && if (likely(sysctl_tcp_timestamps && *md5 == NULL)) {
!dst_feature(dst, RTAX_FEATURE_NO_TSTAMP) &&
*md5 == NULL)) {
opts->options |= OPTION_TS; opts->options |= OPTION_TS;
opts->tsval = TCP_SKB_CB(skb)->when; opts->tsval = TCP_SKB_CB(skb)->when;
opts->tsecr = tp->rx_opt.ts_recent; opts->tsecr = tp->rx_opt.ts_recent;
remaining -= TCPOLEN_TSTAMP_ALIGNED; remaining -= TCPOLEN_TSTAMP_ALIGNED;
} }
if (likely(sysctl_tcp_window_scaling && if (likely(sysctl_tcp_window_scaling)) {
!dst_feature(dst, RTAX_FEATURE_NO_WSCALE))) {
opts->ws = tp->rx_opt.rcv_wscale; opts->ws = tp->rx_opt.rcv_wscale;
opts->options |= OPTION_WSCALE; opts->options |= OPTION_WSCALE;
remaining -= TCPOLEN_WSCALE_ALIGNED; remaining -= TCPOLEN_WSCALE_ALIGNED;
} }
if (likely(sysctl_tcp_sack && if (likely(sysctl_tcp_sack)) {
!dst_feature(dst, RTAX_FEATURE_NO_SACK))) {
opts->options |= OPTION_SACK_ADVERTISE; opts->options |= OPTION_SACK_ADVERTISE;
if (unlikely(!(OPTION_TS & opts->options))) if (unlikely(!(OPTION_TS & opts->options)))
remaining -= TCPOLEN_SACKPERM_ALIGNED; remaining -= TCPOLEN_SACKPERM_ALIGNED;
@ -2527,9 +2522,7 @@ static void tcp_connect_init(struct sock *sk)
* See tcp_input.c:tcp_rcv_state_process case TCP_SYN_SENT. * See tcp_input.c:tcp_rcv_state_process case TCP_SYN_SENT.
*/ */
tp->tcp_header_len = sizeof(struct tcphdr) + tp->tcp_header_len = sizeof(struct tcphdr) +
(sysctl_tcp_timestamps && (sysctl_tcp_timestamps ? TCPOLEN_TSTAMP_ALIGNED : 0);
(!dst_feature(dst, RTAX_FEATURE_NO_TSTAMP) ?
TCPOLEN_TSTAMP_ALIGNED : 0));
#ifdef CONFIG_TCP_MD5SIG #ifdef CONFIG_TCP_MD5SIG
if (tp->af_specific->md5_lookup(sk, sk) != NULL) if (tp->af_specific->md5_lookup(sk, sk) != NULL)
@ -2555,8 +2548,7 @@ static void tcp_connect_init(struct sock *sk)
tp->advmss - (tp->rx_opt.ts_recent_stamp ? tp->tcp_header_len - sizeof(struct tcphdr) : 0), tp->advmss - (tp->rx_opt.ts_recent_stamp ? tp->tcp_header_len - sizeof(struct tcphdr) : 0),
&tp->rcv_wnd, &tp->rcv_wnd,
&tp->window_clamp, &tp->window_clamp,
(sysctl_tcp_window_scaling && sysctl_tcp_window_scaling,
!dst_feature(dst, RTAX_FEATURE_NO_WSCALE)),
&rcv_wscale); &rcv_wscale);
tp->rx_opt.rcv_wscale = rcv_wscale; tp->rx_opt.rcv_wscale = rcv_wscale;

View File

@ -216,9 +216,8 @@ int udp_lib_get_port(struct sock *sk, unsigned short snum,
* force rand to be an odd multiple of UDP_HTABLE_SIZE * force rand to be an odd multiple of UDP_HTABLE_SIZE
*/ */
rand = (rand | 1) * (udptable->mask + 1); rand = (rand | 1) * (udptable->mask + 1);
for (last = first + udptable->mask + 1; last = first + udptable->mask + 1;
first != last; do {
first++) {
hslot = udp_hashslot(udptable, net, first); hslot = udp_hashslot(udptable, net, first);
bitmap_zero(bitmap, PORTS_PER_CHAIN); bitmap_zero(bitmap, PORTS_PER_CHAIN);
spin_lock_bh(&hslot->lock); spin_lock_bh(&hslot->lock);
@ -238,7 +237,7 @@ int udp_lib_get_port(struct sock *sk, unsigned short snum,
snum += rand; snum += rand;
} while (snum != first); } while (snum != first);
spin_unlock_bh(&hslot->lock); spin_unlock_bh(&hslot->lock);
} } while (++first != last);
goto fail; goto fail;
} else { } else {
hslot = udp_hashslot(udptable, net, snum); hslot = udp_hashslot(udptable, net, snum);

View File

@ -20,6 +20,7 @@
#include <net/ipv6.h> #include <net/ipv6.h>
#include <net/inet_frag.h> #include <net/inet_frag.h>
#include <linux/netfilter_bridge.h>
#include <linux/netfilter_ipv6.h> #include <linux/netfilter_ipv6.h>
#include <net/netfilter/nf_conntrack.h> #include <net/netfilter/nf_conntrack.h>
#include <net/netfilter/nf_conntrack_helper.h> #include <net/netfilter/nf_conntrack_helper.h>
@ -187,6 +188,21 @@ out:
return nf_conntrack_confirm(skb); return nf_conntrack_confirm(skb);
} }
static enum ip6_defrag_users nf_ct6_defrag_user(unsigned int hooknum,
struct sk_buff *skb)
{
#ifdef CONFIG_BRIDGE_NETFILTER
if (skb->nf_bridge &&
skb->nf_bridge->mask & BRNF_NF_BRIDGE_PREROUTING)
return IP6_DEFRAG_CONNTRACK_BRIDGE_IN;
#endif
if (hooknum == NF_INET_PRE_ROUTING)
return IP6_DEFRAG_CONNTRACK_IN;
else
return IP6_DEFRAG_CONNTRACK_OUT;
}
static unsigned int ipv6_defrag(unsigned int hooknum, static unsigned int ipv6_defrag(unsigned int hooknum,
struct sk_buff *skb, struct sk_buff *skb,
const struct net_device *in, const struct net_device *in,
@ -199,8 +215,7 @@ static unsigned int ipv6_defrag(unsigned int hooknum,
if (skb->nfct) if (skb->nfct)
return NF_ACCEPT; return NF_ACCEPT;
reasm = nf_ct_frag6_gather(skb); reasm = nf_ct_frag6_gather(skb, nf_ct6_defrag_user(hooknum, skb));
/* queued */ /* queued */
if (reasm == NULL) if (reasm == NULL)
return NF_STOLEN; return NF_STOLEN;

View File

@ -168,13 +168,14 @@ out:
/* Creation primitives. */ /* Creation primitives. */
static __inline__ struct nf_ct_frag6_queue * static __inline__ struct nf_ct_frag6_queue *
fq_find(__be32 id, struct in6_addr *src, struct in6_addr *dst) fq_find(__be32 id, u32 user, struct in6_addr *src, struct in6_addr *dst)
{ {
struct inet_frag_queue *q; struct inet_frag_queue *q;
struct ip6_create_arg arg; struct ip6_create_arg arg;
unsigned int hash; unsigned int hash;
arg.id = id; arg.id = id;
arg.user = user;
arg.src = src; arg.src = src;
arg.dst = dst; arg.dst = dst;
@ -559,7 +560,7 @@ find_prev_fhdr(struct sk_buff *skb, u8 *prevhdrp, int *prevhoff, int *fhoff)
return 0; return 0;
} }
struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb) struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb, u32 user)
{ {
struct sk_buff *clone; struct sk_buff *clone;
struct net_device *dev = skb->dev; struct net_device *dev = skb->dev;
@ -605,7 +606,7 @@ struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb)
if (atomic_read(&nf_init_frags.mem) > nf_init_frags.high_thresh) if (atomic_read(&nf_init_frags.mem) > nf_init_frags.high_thresh)
nf_ct_frag6_evictor(); nf_ct_frag6_evictor();
fq = fq_find(fhdr->identification, &hdr->saddr, &hdr->daddr); fq = fq_find(fhdr->identification, user, &hdr->saddr, &hdr->daddr);
if (fq == NULL) { if (fq == NULL) {
pr_debug("Can't find and can't create new queue\n"); pr_debug("Can't find and can't create new queue\n");
goto ret_orig; goto ret_orig;

View File

@ -72,6 +72,7 @@ struct frag_queue
struct inet_frag_queue q; struct inet_frag_queue q;
__be32 id; /* fragment id */ __be32 id; /* fragment id */
u32 user;
struct in6_addr saddr; struct in6_addr saddr;
struct in6_addr daddr; struct in6_addr daddr;
@ -141,7 +142,7 @@ int ip6_frag_match(struct inet_frag_queue *q, void *a)
struct ip6_create_arg *arg = a; struct ip6_create_arg *arg = a;
fq = container_of(q, struct frag_queue, q); fq = container_of(q, struct frag_queue, q);
return (fq->id == arg->id && return (fq->id == arg->id && fq->user == arg->user &&
ipv6_addr_equal(&fq->saddr, arg->src) && ipv6_addr_equal(&fq->saddr, arg->src) &&
ipv6_addr_equal(&fq->daddr, arg->dst)); ipv6_addr_equal(&fq->daddr, arg->dst));
} }
@ -163,6 +164,7 @@ void ip6_frag_init(struct inet_frag_queue *q, void *a)
struct ip6_create_arg *arg = a; struct ip6_create_arg *arg = a;
fq->id = arg->id; fq->id = arg->id;
fq->user = arg->user;
ipv6_addr_copy(&fq->saddr, arg->src); ipv6_addr_copy(&fq->saddr, arg->src);
ipv6_addr_copy(&fq->daddr, arg->dst); ipv6_addr_copy(&fq->daddr, arg->dst);
} }
@ -243,6 +245,7 @@ fq_find(struct net *net, __be32 id, struct in6_addr *src, struct in6_addr *dst,
unsigned int hash; unsigned int hash;
arg.id = id; arg.id = id;
arg.user = IP6_DEFRAG_LOCAL_DELIVER;
arg.src = src; arg.src = src;
arg.dst = dst; arg.dst = dst;

View File

@ -185,6 +185,13 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESRECV); NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESRECV);
/* check for timestamp cookie support */
memset(&tcp_opt, 0, sizeof(tcp_opt));
tcp_parse_options(skb, &tcp_opt, &hash_location, 0);
if (tcp_opt.saw_tstamp)
cookie_check_timestamp(&tcp_opt);
ret = NULL; ret = NULL;
req = inet6_reqsk_alloc(&tcp6_request_sock_ops); req = inet6_reqsk_alloc(&tcp6_request_sock_ops);
if (!req) if (!req)
@ -218,6 +225,12 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
req->expires = 0UL; req->expires = 0UL;
req->retrans = 0; req->retrans = 0;
ireq->ecn_ok = 0; ireq->ecn_ok = 0;
ireq->snd_wscale = tcp_opt.snd_wscale;
ireq->rcv_wscale = tcp_opt.rcv_wscale;
ireq->sack_ok = tcp_opt.sack_ok;
ireq->wscale_ok = tcp_opt.wscale_ok;
ireq->tstamp_ok = tcp_opt.saw_tstamp;
req->ts_recent = tcp_opt.saw_tstamp ? tcp_opt.rcv_tsval : 0;
treq->rcv_isn = ntohl(th->seq) - 1; treq->rcv_isn = ntohl(th->seq) - 1;
treq->snt_isn = cookie; treq->snt_isn = cookie;
@ -253,21 +266,6 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
goto out_free; goto out_free;
} }
/* check for timestamp cookie support */
memset(&tcp_opt, 0, sizeof(tcp_opt));
tcp_parse_options(skb, &tcp_opt, &hash_location, 0, dst);
if (tcp_opt.saw_tstamp)
cookie_check_timestamp(&tcp_opt);
req->ts_recent = tcp_opt.saw_tstamp ? tcp_opt.rcv_tsval : 0;
ireq->snd_wscale = tcp_opt.snd_wscale;
ireq->rcv_wscale = tcp_opt.rcv_wscale;
ireq->sack_ok = tcp_opt.sack_ok;
ireq->wscale_ok = tcp_opt.wscale_ok;
ireq->tstamp_ok = tcp_opt.saw_tstamp;
req->window_clamp = tp->window_clamp ? :dst_metric(dst, RTAX_WINDOW); req->window_clamp = tp->window_clamp ? :dst_metric(dst, RTAX_WINDOW);
tcp_select_initial_window(tcp_full_space(sk), req->mss, tcp_select_initial_window(tcp_full_space(sk), req->mss,
&req->rcv_wnd, &req->window_clamp, &req->rcv_wnd, &req->window_clamp,

View File

@ -1169,7 +1169,6 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
struct inet6_request_sock *treq; struct inet6_request_sock *treq;
struct ipv6_pinfo *np = inet6_sk(sk); struct ipv6_pinfo *np = inet6_sk(sk);
struct tcp_sock *tp = tcp_sk(sk); struct tcp_sock *tp = tcp_sk(sk);
struct dst_entry *dst = __sk_dst_get(sk);
__u32 isn = TCP_SKB_CB(skb)->when; __u32 isn = TCP_SKB_CB(skb)->when;
#ifdef CONFIG_SYN_COOKIES #ifdef CONFIG_SYN_COOKIES
int want_cookie = 0; int want_cookie = 0;
@ -1208,7 +1207,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
tcp_clear_options(&tmp_opt); tcp_clear_options(&tmp_opt);
tmp_opt.mss_clamp = IPV6_MIN_MTU - sizeof(struct tcphdr) - sizeof(struct ipv6hdr); tmp_opt.mss_clamp = IPV6_MIN_MTU - sizeof(struct tcphdr) - sizeof(struct ipv6hdr);
tmp_opt.user_mss = tp->rx_opt.user_mss; tmp_opt.user_mss = tp->rx_opt.user_mss;
tcp_parse_options(skb, &tmp_opt, &hash_location, 0, dst); tcp_parse_options(skb, &tmp_opt, &hash_location, 0);
if (tmp_opt.cookie_plus > 0 && if (tmp_opt.cookie_plus > 0 &&
tmp_opt.saw_tstamp && tmp_opt.saw_tstamp &&

View File

@ -1366,6 +1366,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb,
== sysctl_ip_vs_sync_threshold[0])) || == sysctl_ip_vs_sync_threshold[0])) ||
((cp->protocol == IPPROTO_TCP) && (cp->old_state != cp->state) && ((cp->protocol == IPPROTO_TCP) && (cp->old_state != cp->state) &&
((cp->state == IP_VS_TCP_S_FIN_WAIT) || ((cp->state == IP_VS_TCP_S_FIN_WAIT) ||
(cp->state == IP_VS_TCP_S_CLOSE) ||
(cp->state == IP_VS_TCP_S_CLOSE_WAIT) || (cp->state == IP_VS_TCP_S_CLOSE_WAIT) ||
(cp->state == IP_VS_TCP_S_TIME_WAIT))))) (cp->state == IP_VS_TCP_S_TIME_WAIT)))))
ip_vs_sync_conn(cp); ip_vs_sync_conn(cp);

View File

@ -2714,6 +2714,8 @@ static int ip_vs_genl_parse_service(struct ip_vs_service_user_kern *usvc,
if (!(nla_af && (nla_fwmark || (nla_port && nla_protocol && nla_addr)))) if (!(nla_af && (nla_fwmark || (nla_port && nla_protocol && nla_addr))))
return -EINVAL; return -EINVAL;
memset(usvc, 0, sizeof(*usvc));
usvc->af = nla_get_u16(nla_af); usvc->af = nla_get_u16(nla_af);
#ifdef CONFIG_IP_VS_IPV6 #ifdef CONFIG_IP_VS_IPV6
if (usvc->af != AF_INET && usvc->af != AF_INET6) if (usvc->af != AF_INET && usvc->af != AF_INET6)
@ -2901,6 +2903,8 @@ static int ip_vs_genl_parse_dest(struct ip_vs_dest_user_kern *udest,
if (!(nla_addr && nla_port)) if (!(nla_addr && nla_port))
return -EINVAL; return -EINVAL;
memset(udest, 0, sizeof(*udest));
nla_memcpy(&udest->addr, nla_addr, sizeof(udest->addr)); nla_memcpy(&udest->addr, nla_addr, sizeof(udest->addr));
udest->port = nla_get_u16(nla_port); udest->port = nla_get_u16(nla_port);

View File

@ -415,7 +415,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct sockaddr_pkt *saddr = (struct sockaddr_pkt *)msg->msg_name; struct sockaddr_pkt *saddr = (struct sockaddr_pkt *)msg->msg_name;
struct sk_buff *skb; struct sk_buff *skb = NULL;
struct net_device *dev; struct net_device *dev;
__be16 proto = 0; __be16 proto = 0;
int err; int err;
@ -437,6 +437,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
*/ */
saddr->spkt_device[13] = 0; saddr->spkt_device[13] = 0;
retry:
rcu_read_lock(); rcu_read_lock();
dev = dev_get_by_name_rcu(sock_net(sk), saddr->spkt_device); dev = dev_get_by_name_rcu(sock_net(sk), saddr->spkt_device);
err = -ENODEV; err = -ENODEV;
@ -456,58 +457,48 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
if (len > dev->mtu + dev->hard_header_len) if (len > dev->mtu + dev->hard_header_len)
goto out_unlock; goto out_unlock;
err = -ENOBUFS; if (!skb) {
skb = sock_wmalloc(sk, len + LL_RESERVED_SPACE(dev), 0, GFP_KERNEL); size_t reserved = LL_RESERVED_SPACE(dev);
unsigned int hhlen = dev->header_ops ? dev->hard_header_len : 0;
/* rcu_read_unlock();
* If the write buffer is full, then tough. At this level the user skb = sock_wmalloc(sk, len + reserved, 0, GFP_KERNEL);
* gets to deal with the problem - do your own algorithmic backoffs. if (skb == NULL)
* That's far more flexible. return -ENOBUFS;
*/ /* FIXME: Save some space for broken drivers that write a hard
* header at transmission time by themselves. PPP is the notable
* one here. This should really be fixed at the driver level.
*/
skb_reserve(skb, reserved);
skb_reset_network_header(skb);
if (skb == NULL) /* Try to align data part correctly */
goto out_unlock; if (hhlen) {
skb->data -= hhlen;
/* skb->tail -= hhlen;
* Fill it in if (len < hhlen)
*/ skb_reset_network_header(skb);
}
/* FIXME: Save some space for broken drivers that write a err = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len);
* hard header at transmission time by themselves. PPP is the if (err)
* notable one here. This should really be fixed at the driver level. goto out_free;
*/ goto retry;
skb_reserve(skb, LL_RESERVED_SPACE(dev));
skb_reset_network_header(skb);
/* Try to align data part correctly */
if (dev->header_ops) {
skb->data -= dev->hard_header_len;
skb->tail -= dev->hard_header_len;
if (len < dev->hard_header_len)
skb_reset_network_header(skb);
} }
/* Returns -EFAULT on error */
err = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len);
skb->protocol = proto; skb->protocol = proto;
skb->dev = dev; skb->dev = dev;
skb->priority = sk->sk_priority; skb->priority = sk->sk_priority;
skb->mark = sk->sk_mark; skb->mark = sk->sk_mark;
if (err)
goto out_free;
/*
* Now send it
*/
dev_queue_xmit(skb); dev_queue_xmit(skb);
rcu_read_unlock(); rcu_read_unlock();
return len; return len;
out_free:
kfree_skb(skb);
out_unlock: out_unlock:
rcu_read_unlock(); rcu_read_unlock();
out_free:
kfree_skb(skb);
return err; return err;
} }