aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
Diffstat (limited to 'net/core')
-rw-r--r--net/core/dev.c599
-rw-r--r--net/core/dev_addr_lists.c6
-rw-r--r--net/core/drop_monitor.c2
-rw-r--r--net/core/dst.c43
-rw-r--r--net/core/ethtool.c624
-rw-r--r--net/core/fib_rules.c6
-rw-r--r--net/core/filter.c8
-rw-r--r--net/core/flow.c14
-rw-r--r--net/core/link_watch.c2
-rw-r--r--net/core/neighbour.c13
-rw-r--r--net/core/net-sysfs.c17
-rw-r--r--net/core/netpoll.c13
-rw-r--r--net/core/pktgen.c240
-rw-r--r--net/core/rtnetlink.c90
-rw-r--r--net/core/scm.c2
-rw-r--r--net/core/skbuff.c10
-rw-r--r--net/core/sock.c10
17 files changed, 1101 insertions, 598 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 8ae6631abcc2..856b6ee9a1d5 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -132,6 +132,7 @@
132#include <trace/events/skb.h> 132#include <trace/events/skb.h>
133#include <linux/pci.h> 133#include <linux/pci.h>
134#include <linux/inetdevice.h> 134#include <linux/inetdevice.h>
135#include <linux/cpu_rmap.h>
135 136
136#include "net-sysfs.h" 137#include "net-sysfs.h"
137 138
@@ -1114,13 +1115,21 @@ EXPORT_SYMBOL(netdev_bonding_change);
1114void dev_load(struct net *net, const char *name) 1115void dev_load(struct net *net, const char *name)
1115{ 1116{
1116 struct net_device *dev; 1117 struct net_device *dev;
1118 int no_module;
1117 1119
1118 rcu_read_lock(); 1120 rcu_read_lock();
1119 dev = dev_get_by_name_rcu(net, name); 1121 dev = dev_get_by_name_rcu(net, name);
1120 rcu_read_unlock(); 1122 rcu_read_unlock();
1121 1123
1122 if (!dev && capable(CAP_NET_ADMIN)) 1124 no_module = !dev;
1123 request_module("%s", name); 1125 if (no_module && capable(CAP_NET_ADMIN))
1126 no_module = request_module("netdev-%s", name);
1127 if (no_module && capable(CAP_SYS_MODULE)) {
1128 if (!request_module("%s", name))
1129 pr_err("Loading kernel module for a network device "
1130"with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s "
1131"instead\n", name);
1132 }
1124} 1133}
1125EXPORT_SYMBOL(dev_load); 1134EXPORT_SYMBOL(dev_load);
1126 1135
@@ -1131,9 +1140,6 @@ static int __dev_open(struct net_device *dev)
1131 1140
1132 ASSERT_RTNL(); 1141 ASSERT_RTNL();
1133 1142
1134 /*
1135 * Is it even present?
1136 */
1137 if (!netif_device_present(dev)) 1143 if (!netif_device_present(dev))
1138 return -ENODEV; 1144 return -ENODEV;
1139 1145
@@ -1142,9 +1148,6 @@ static int __dev_open(struct net_device *dev)
1142 if (ret) 1148 if (ret)
1143 return ret; 1149 return ret;
1144 1150
1145 /*
1146 * Call device private open method
1147 */
1148 set_bit(__LINK_STATE_START, &dev->state); 1151 set_bit(__LINK_STATE_START, &dev->state);
1149 1152
1150 if (ops->ndo_validate_addr) 1153 if (ops->ndo_validate_addr)
@@ -1153,31 +1156,12 @@ static int __dev_open(struct net_device *dev)
1153 if (!ret && ops->ndo_open) 1156 if (!ret && ops->ndo_open)
1154 ret = ops->ndo_open(dev); 1157 ret = ops->ndo_open(dev);
1155 1158
1156 /*
1157 * If it went open OK then:
1158 */
1159
1160 if (ret) 1159 if (ret)
1161 clear_bit(__LINK_STATE_START, &dev->state); 1160 clear_bit(__LINK_STATE_START, &dev->state);
1162 else { 1161 else {
1163 /*
1164 * Set the flags.
1165 */
1166 dev->flags |= IFF_UP; 1162 dev->flags |= IFF_UP;
1167
1168 /*
1169 * Enable NET_DMA
1170 */
1171 net_dmaengine_get(); 1163 net_dmaengine_get();
1172
1173 /*
1174 * Initialize multicasting status
1175 */
1176 dev_set_rx_mode(dev); 1164 dev_set_rx_mode(dev);
1177
1178 /*
1179 * Wakeup transmit queue engine
1180 */
1181 dev_activate(dev); 1165 dev_activate(dev);
1182 } 1166 }
1183 1167
@@ -1200,22 +1184,13 @@ int dev_open(struct net_device *dev)
1200{ 1184{
1201 int ret; 1185 int ret;
1202 1186
1203 /*
1204 * Is it already up?
1205 */
1206 if (dev->flags & IFF_UP) 1187 if (dev->flags & IFF_UP)
1207 return 0; 1188 return 0;
1208 1189
1209 /*
1210 * Open device
1211 */
1212 ret = __dev_open(dev); 1190 ret = __dev_open(dev);
1213 if (ret < 0) 1191 if (ret < 0)
1214 return ret; 1192 return ret;
1215 1193
1216 /*
1217 * ... and announce new interface.
1218 */
1219 rtmsg_ifinfo(RTM_NEWLINK, dev, IFF_UP|IFF_RUNNING); 1194 rtmsg_ifinfo(RTM_NEWLINK, dev, IFF_UP|IFF_RUNNING);
1220 call_netdevice_notifiers(NETDEV_UP, dev); 1195 call_netdevice_notifiers(NETDEV_UP, dev);
1221 1196
@@ -1231,10 +1206,6 @@ static int __dev_close_many(struct list_head *head)
1231 might_sleep(); 1206 might_sleep();
1232 1207
1233 list_for_each_entry(dev, head, unreg_list) { 1208 list_for_each_entry(dev, head, unreg_list) {
1234 /*
1235 * Tell people we are going down, so that they can
1236 * prepare to death, when device is still operating.
1237 */
1238 call_netdevice_notifiers(NETDEV_GOING_DOWN, dev); 1209 call_netdevice_notifiers(NETDEV_GOING_DOWN, dev);
1239 1210
1240 clear_bit(__LINK_STATE_START, &dev->state); 1211 clear_bit(__LINK_STATE_START, &dev->state);
@@ -1263,15 +1234,7 @@ static int __dev_close_many(struct list_head *head)
1263 if (ops->ndo_stop) 1234 if (ops->ndo_stop)
1264 ops->ndo_stop(dev); 1235 ops->ndo_stop(dev);
1265 1236
1266 /*
1267 * Device is now down.
1268 */
1269
1270 dev->flags &= ~IFF_UP; 1237 dev->flags &= ~IFF_UP;
1271
1272 /*
1273 * Shutdown NET_DMA
1274 */
1275 net_dmaengine_put(); 1238 net_dmaengine_put();
1276 } 1239 }
1277 1240
@@ -1289,7 +1252,7 @@ static int __dev_close(struct net_device *dev)
1289 return retval; 1252 return retval;
1290} 1253}
1291 1254
1292int dev_close_many(struct list_head *head) 1255static int dev_close_many(struct list_head *head)
1293{ 1256{
1294 struct net_device *dev, *tmp; 1257 struct net_device *dev, *tmp;
1295 LIST_HEAD(tmp_list); 1258 LIST_HEAD(tmp_list);
@@ -1300,9 +1263,6 @@ int dev_close_many(struct list_head *head)
1300 1263
1301 __dev_close_many(head); 1264 __dev_close_many(head);
1302 1265
1303 /*
1304 * Tell people we are down
1305 */
1306 list_for_each_entry(dev, head, unreg_list) { 1266 list_for_each_entry(dev, head, unreg_list) {
1307 rtmsg_ifinfo(RTM_NEWLINK, dev, IFF_UP|IFF_RUNNING); 1267 rtmsg_ifinfo(RTM_NEWLINK, dev, IFF_UP|IFF_RUNNING);
1308 call_netdevice_notifiers(NETDEV_DOWN, dev); 1268 call_netdevice_notifiers(NETDEV_DOWN, dev);
@@ -1344,14 +1304,17 @@ EXPORT_SYMBOL(dev_close);
1344 */ 1304 */
1345void dev_disable_lro(struct net_device *dev) 1305void dev_disable_lro(struct net_device *dev)
1346{ 1306{
1347 if (dev->ethtool_ops && dev->ethtool_ops->get_flags && 1307 u32 flags;
1348 dev->ethtool_ops->set_flags) { 1308
1349 u32 flags = dev->ethtool_ops->get_flags(dev); 1309 if (dev->ethtool_ops && dev->ethtool_ops->get_flags)
1350 if (flags & ETH_FLAG_LRO) { 1310 flags = dev->ethtool_ops->get_flags(dev);
1351 flags &= ~ETH_FLAG_LRO; 1311 else
1352 dev->ethtool_ops->set_flags(dev, flags); 1312 flags = ethtool_op_get_flags(dev);
1353 } 1313
1354 } 1314 if (!(flags & ETH_FLAG_LRO))
1315 return;
1316
1317 __ethtool_set_flags(dev, flags & ~ETH_FLAG_LRO);
1355 WARN_ON(dev->features & NETIF_F_LRO); 1318 WARN_ON(dev->features & NETIF_F_LRO);
1356} 1319}
1357EXPORT_SYMBOL(dev_disable_lro); 1320EXPORT_SYMBOL(dev_disable_lro);
@@ -1359,11 +1322,6 @@ EXPORT_SYMBOL(dev_disable_lro);
1359 1322
1360static int dev_boot_phase = 1; 1323static int dev_boot_phase = 1;
1361 1324
1362/*
1363 * Device change register/unregister. These are not inline or static
1364 * as we export them to the world.
1365 */
1366
1367/** 1325/**
1368 * register_netdevice_notifier - register a network notifier block 1326 * register_netdevice_notifier - register a network notifier block
1369 * @nb: notifier 1327 * @nb: notifier
@@ -1465,6 +1423,7 @@ int call_netdevice_notifiers(unsigned long val, struct net_device *dev)
1465 ASSERT_RTNL(); 1423 ASSERT_RTNL();
1466 return raw_notifier_call_chain(&netdev_chain, val, dev); 1424 return raw_notifier_call_chain(&netdev_chain, val, dev);
1467} 1425}
1426EXPORT_SYMBOL(call_netdevice_notifiers);
1468 1427
1469/* When > 0 there are consumers of rx skb time stamps */ 1428/* When > 0 there are consumers of rx skb time stamps */
1470static atomic_t netstamp_needed = ATOMIC_INIT(0); 1429static atomic_t netstamp_needed = ATOMIC_INIT(0);
@@ -1495,6 +1454,27 @@ static inline void net_timestamp_check(struct sk_buff *skb)
1495 __net_timestamp(skb); 1454 __net_timestamp(skb);
1496} 1455}
1497 1456
1457static inline bool is_skb_forwardable(struct net_device *dev,
1458 struct sk_buff *skb)
1459{
1460 unsigned int len;
1461
1462 if (!(dev->flags & IFF_UP))
1463 return false;
1464
1465 len = dev->mtu + dev->hard_header_len + VLAN_HLEN;
1466 if (skb->len <= len)
1467 return true;
1468
1469 /* if TSO is enabled, we don't care about the length as the packet
1470 * could be forwarded without being segmented before
1471 */
1472 if (skb_is_gso(skb))
1473 return true;
1474
1475 return false;
1476}
1477
1498/** 1478/**
1499 * dev_forward_skb - loopback an skb to another netif 1479 * dev_forward_skb - loopback an skb to another netif
1500 * 1480 *
@@ -1518,8 +1498,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
1518 skb_orphan(skb); 1498 skb_orphan(skb);
1519 nf_reset(skb); 1499 nf_reset(skb);
1520 1500
1521 if (unlikely(!(dev->flags & IFF_UP) || 1501 if (unlikely(!is_skb_forwardable(dev, skb))) {
1522 (skb->len > (dev->mtu + dev->hard_header_len + VLAN_HLEN)))) {
1523 atomic_long_inc(&dev->rx_dropped); 1502 atomic_long_inc(&dev->rx_dropped);
1524 kfree_skb(skb); 1503 kfree_skb(skb);
1525 return NET_RX_DROP; 1504 return NET_RX_DROP;
@@ -1597,6 +1576,48 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
1597 rcu_read_unlock(); 1576 rcu_read_unlock();
1598} 1577}
1599 1578
1579/* netif_setup_tc - Handle tc mappings on real_num_tx_queues change
1580 * @dev: Network device
1581 * @txq: number of queues available
1582 *
1583 * If real_num_tx_queues is changed the tc mappings may no longer be
1584 * valid. To resolve this verify the tc mapping remains valid and if
1585 * not NULL the mapping. With no priorities mapping to this
1586 * offset/count pair it will no longer be used. In the worst case TC0
1587 * is invalid nothing can be done so disable priority mappings. If is
1588 * expected that drivers will fix this mapping if they can before
1589 * calling netif_set_real_num_tx_queues.
1590 */
1591static void netif_setup_tc(struct net_device *dev, unsigned int txq)
1592{
1593 int i;
1594 struct netdev_tc_txq *tc = &dev->tc_to_txq[0];
1595
1596 /* If TC0 is invalidated disable TC mapping */
1597 if (tc->offset + tc->count > txq) {
1598 pr_warning("Number of in use tx queues changed "
1599 "invalidating tc mappings. Priority "
1600 "traffic classification disabled!\n");
1601 dev->num_tc = 0;
1602 return;
1603 }
1604
1605 /* Invalidated prio to tc mappings set to TC0 */
1606 for (i = 1; i < TC_BITMASK + 1; i++) {
1607 int q = netdev_get_prio_tc_map(dev, i);
1608
1609 tc = &dev->tc_to_txq[q];
1610 if (tc->offset + tc->count > txq) {
1611 pr_warning("Number of in use tx queues "
1612 "changed. Priority %i to tc "
1613 "mapping %i is no longer valid "
1614 "setting map to 0\n",
1615 i, q);
1616 netdev_set_prio_tc_map(dev, i, 0);
1617 }
1618 }
1619}
1620
1600/* 1621/*
1601 * Routine to help set real_num_tx_queues. To avoid skbs mapped to queues 1622 * Routine to help set real_num_tx_queues. To avoid skbs mapped to queues
1602 * greater then real_num_tx_queues stale skbs on the qdisc must be flushed. 1623 * greater then real_num_tx_queues stale skbs on the qdisc must be flushed.
@@ -1608,7 +1629,8 @@ int netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq)
1608 if (txq < 1 || txq > dev->num_tx_queues) 1629 if (txq < 1 || txq > dev->num_tx_queues)
1609 return -EINVAL; 1630 return -EINVAL;
1610 1631
1611 if (dev->reg_state == NETREG_REGISTERED) { 1632 if (dev->reg_state == NETREG_REGISTERED ||
1633 dev->reg_state == NETREG_UNREGISTERING) {
1612 ASSERT_RTNL(); 1634 ASSERT_RTNL();
1613 1635
1614 rc = netdev_queue_update_kobjects(dev, dev->real_num_tx_queues, 1636 rc = netdev_queue_update_kobjects(dev, dev->real_num_tx_queues,
@@ -1616,6 +1638,9 @@ int netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq)
1616 if (rc) 1638 if (rc)
1617 return rc; 1639 return rc;
1618 1640
1641 if (dev->num_tc)
1642 netif_setup_tc(dev, txq);
1643
1619 if (txq < dev->real_num_tx_queues) 1644 if (txq < dev->real_num_tx_queues)
1620 qdisc_reset_all_tx_gt(dev, txq); 1645 qdisc_reset_all_tx_gt(dev, txq);
1621 } 1646 }
@@ -1815,7 +1840,7 @@ EXPORT_SYMBOL(skb_checksum_help);
1815 * It may return NULL if the skb requires no segmentation. This is 1840 * It may return NULL if the skb requires no segmentation. This is
1816 * only possible when GSO is used for verifying header integrity. 1841 * only possible when GSO is used for verifying header integrity.
1817 */ 1842 */
1818struct sk_buff *skb_gso_segment(struct sk_buff *skb, int features) 1843struct sk_buff *skb_gso_segment(struct sk_buff *skb, u32 features)
1819{ 1844{
1820 struct sk_buff *segs = ERR_PTR(-EPROTONOSUPPORT); 1845 struct sk_buff *segs = ERR_PTR(-EPROTONOSUPPORT);
1821 struct packet_type *ptype; 1846 struct packet_type *ptype;
@@ -2003,7 +2028,7 @@ static bool can_checksum_protocol(unsigned long features, __be16 protocol)
2003 protocol == htons(ETH_P_FCOE))); 2028 protocol == htons(ETH_P_FCOE)));
2004} 2029}
2005 2030
2006static int harmonize_features(struct sk_buff *skb, __be16 protocol, int features) 2031static u32 harmonize_features(struct sk_buff *skb, __be16 protocol, u32 features)
2007{ 2032{
2008 if (!can_checksum_protocol(features, protocol)) { 2033 if (!can_checksum_protocol(features, protocol)) {
2009 features &= ~NETIF_F_ALL_CSUM; 2034 features &= ~NETIF_F_ALL_CSUM;
@@ -2015,10 +2040,10 @@ static int harmonize_features(struct sk_buff *skb, __be16 protocol, int features
2015 return features; 2040 return features;
2016} 2041}
2017 2042
2018int netif_skb_features(struct sk_buff *skb) 2043u32 netif_skb_features(struct sk_buff *skb)
2019{ 2044{
2020 __be16 protocol = skb->protocol; 2045 __be16 protocol = skb->protocol;
2021 int features = skb->dev->features; 2046 u32 features = skb->dev->features;
2022 2047
2023 if (protocol == htons(ETH_P_8021Q)) { 2048 if (protocol == htons(ETH_P_8021Q)) {
2024 struct vlan_ethhdr *veh = (struct vlan_ethhdr *)skb->data; 2049 struct vlan_ethhdr *veh = (struct vlan_ethhdr *)skb->data;
@@ -2063,10 +2088,10 @@ int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
2063 int rc = NETDEV_TX_OK; 2088 int rc = NETDEV_TX_OK;
2064 2089
2065 if (likely(!skb->next)) { 2090 if (likely(!skb->next)) {
2066 int features; 2091 u32 features;
2067 2092
2068 /* 2093 /*
2069 * If device doesnt need skb->dst, release it right now while 2094 * If device doesn't need skb->dst, release it right now while
2070 * its hot in this cpu cache 2095 * its hot in this cpu cache
2071 */ 2096 */
2072 if (dev->priv_flags & IFF_XMIT_DST_RELEASE) 2097 if (dev->priv_flags & IFF_XMIT_DST_RELEASE)
@@ -2126,7 +2151,7 @@ gso:
2126 nskb->next = NULL; 2151 nskb->next = NULL;
2127 2152
2128 /* 2153 /*
2129 * If device doesnt need nskb->dst, release it right now while 2154 * If device doesn't need nskb->dst, release it right now while
2130 * its hot in this cpu cache 2155 * its hot in this cpu cache
2131 */ 2156 */
2132 if (dev->priv_flags & IFF_XMIT_DST_RELEASE) 2157 if (dev->priv_flags & IFF_XMIT_DST_RELEASE)
@@ -2165,6 +2190,8 @@ u16 __skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb,
2165 unsigned int num_tx_queues) 2190 unsigned int num_tx_queues)
2166{ 2191{
2167 u32 hash; 2192 u32 hash;
2193 u16 qoffset = 0;
2194 u16 qcount = num_tx_queues;
2168 2195
2169 if (skb_rx_queue_recorded(skb)) { 2196 if (skb_rx_queue_recorded(skb)) {
2170 hash = skb_get_rx_queue(skb); 2197 hash = skb_get_rx_queue(skb);
@@ -2173,13 +2200,19 @@ u16 __skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb,
2173 return hash; 2200 return hash;
2174 } 2201 }
2175 2202
2203 if (dev->num_tc) {
2204 u8 tc = netdev_get_prio_tc_map(dev, skb->priority);
2205 qoffset = dev->tc_to_txq[tc].offset;
2206 qcount = dev->tc_to_txq[tc].count;
2207 }
2208
2176 if (skb->sk && skb->sk->sk_hash) 2209 if (skb->sk && skb->sk->sk_hash)
2177 hash = skb->sk->sk_hash; 2210 hash = skb->sk->sk_hash;
2178 else 2211 else
2179 hash = (__force u16) skb->protocol ^ skb->rxhash; 2212 hash = (__force u16) skb->protocol ^ skb->rxhash;
2180 hash = jhash_1word(hash, hashrnd); 2213 hash = jhash_1word(hash, hashrnd);
2181 2214
2182 return (u16) (((u64) hash * num_tx_queues) >> 32); 2215 return (u16) (((u64) hash * qcount) >> 32) + qoffset;
2183} 2216}
2184EXPORT_SYMBOL(__skb_tx_hash); 2217EXPORT_SYMBOL(__skb_tx_hash);
2185 2218
@@ -2276,15 +2309,18 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,
2276 struct netdev_queue *txq) 2309 struct netdev_queue *txq)
2277{ 2310{
2278 spinlock_t *root_lock = qdisc_lock(q); 2311 spinlock_t *root_lock = qdisc_lock(q);
2279 bool contended = qdisc_is_running(q); 2312 bool contended;
2280 int rc; 2313 int rc;
2281 2314
2315 qdisc_skb_cb(skb)->pkt_len = skb->len;
2316 qdisc_calculate_pkt_len(skb, q);
2282 /* 2317 /*
2283 * Heuristic to force contended enqueues to serialize on a 2318 * Heuristic to force contended enqueues to serialize on a
2284 * separate lock before trying to get qdisc main lock. 2319 * separate lock before trying to get qdisc main lock.
2285 * This permits __QDISC_STATE_RUNNING owner to get the lock more often 2320 * This permits __QDISC_STATE_RUNNING owner to get the lock more often
2286 * and dequeue packets faster. 2321 * and dequeue packets faster.
2287 */ 2322 */
2323 contended = qdisc_is_running(q);
2288 if (unlikely(contended)) 2324 if (unlikely(contended))
2289 spin_lock(&q->busylock); 2325 spin_lock(&q->busylock);
2290 2326
@@ -2302,7 +2338,6 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,
2302 if (!(dev->priv_flags & IFF_XMIT_DST_RELEASE)) 2338 if (!(dev->priv_flags & IFF_XMIT_DST_RELEASE))
2303 skb_dst_force(skb); 2339 skb_dst_force(skb);
2304 2340
2305 qdisc_skb_cb(skb)->pkt_len = skb->len;
2306 qdisc_bstats_update(q, skb); 2341 qdisc_bstats_update(q, skb);
2307 2342
2308 if (sch_direct_xmit(skb, q, dev, txq, root_lock)) { 2343 if (sch_direct_xmit(skb, q, dev, txq, root_lock)) {
@@ -2317,7 +2352,7 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,
2317 rc = NET_XMIT_SUCCESS; 2352 rc = NET_XMIT_SUCCESS;
2318 } else { 2353 } else {
2319 skb_dst_force(skb); 2354 skb_dst_force(skb);
2320 rc = qdisc_enqueue_root(skb, q); 2355 rc = q->enqueue(skb, q) & NET_XMIT_MASK;
2321 if (qdisc_run_begin(q)) { 2356 if (qdisc_run_begin(q)) {
2322 if (unlikely(contended)) { 2357 if (unlikely(contended)) {
2323 spin_unlock(&q->busylock); 2358 spin_unlock(&q->busylock);
@@ -2536,6 +2571,54 @@ EXPORT_SYMBOL(__skb_get_rxhash);
2536struct rps_sock_flow_table __rcu *rps_sock_flow_table __read_mostly; 2571struct rps_sock_flow_table __rcu *rps_sock_flow_table __read_mostly;
2537EXPORT_SYMBOL(rps_sock_flow_table); 2572EXPORT_SYMBOL(rps_sock_flow_table);
2538 2573
2574static struct rps_dev_flow *
2575set_rps_cpu(struct net_device *dev, struct sk_buff *skb,
2576 struct rps_dev_flow *rflow, u16 next_cpu)
2577{
2578 u16 tcpu;
2579
2580 tcpu = rflow->cpu = next_cpu;
2581 if (tcpu != RPS_NO_CPU) {
2582#ifdef CONFIG_RFS_ACCEL
2583 struct netdev_rx_queue *rxqueue;
2584 struct rps_dev_flow_table *flow_table;
2585 struct rps_dev_flow *old_rflow;
2586 u32 flow_id;
2587 u16 rxq_index;
2588 int rc;
2589
2590 /* Should we steer this flow to a different hardware queue? */
2591 if (!skb_rx_queue_recorded(skb) || !dev->rx_cpu_rmap ||
2592 !(dev->features & NETIF_F_NTUPLE))
2593 goto out;
2594 rxq_index = cpu_rmap_lookup_index(dev->rx_cpu_rmap, next_cpu);
2595 if (rxq_index == skb_get_rx_queue(skb))
2596 goto out;
2597
2598 rxqueue = dev->_rx + rxq_index;
2599 flow_table = rcu_dereference(rxqueue->rps_flow_table);
2600 if (!flow_table)
2601 goto out;
2602 flow_id = skb->rxhash & flow_table->mask;
2603 rc = dev->netdev_ops->ndo_rx_flow_steer(dev, skb,
2604 rxq_index, flow_id);
2605 if (rc < 0)
2606 goto out;
2607 old_rflow = rflow;
2608 rflow = &flow_table->flows[flow_id];
2609 rflow->cpu = next_cpu;
2610 rflow->filter = rc;
2611 if (old_rflow->filter == rflow->filter)
2612 old_rflow->filter = RPS_NO_FILTER;
2613 out:
2614#endif
2615 rflow->last_qtail =
2616 per_cpu(softnet_data, tcpu).input_queue_head;
2617 }
2618
2619 return rflow;
2620}
2621
2539/* 2622/*
2540 * get_rps_cpu is called from netif_receive_skb and returns the target 2623 * get_rps_cpu is called from netif_receive_skb and returns the target
2541 * CPU from the RPS map of the receiving queue for a given skb. 2624 * CPU from the RPS map of the receiving queue for a given skb.
@@ -2607,12 +2690,9 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
2607 if (unlikely(tcpu != next_cpu) && 2690 if (unlikely(tcpu != next_cpu) &&
2608 (tcpu == RPS_NO_CPU || !cpu_online(tcpu) || 2691 (tcpu == RPS_NO_CPU || !cpu_online(tcpu) ||
2609 ((int)(per_cpu(softnet_data, tcpu).input_queue_head - 2692 ((int)(per_cpu(softnet_data, tcpu).input_queue_head -
2610 rflow->last_qtail)) >= 0)) { 2693 rflow->last_qtail)) >= 0))
2611 tcpu = rflow->cpu = next_cpu; 2694 rflow = set_rps_cpu(dev, skb, rflow, next_cpu);
2612 if (tcpu != RPS_NO_CPU) 2695
2613 rflow->last_qtail = per_cpu(softnet_data,
2614 tcpu).input_queue_head;
2615 }
2616 if (tcpu != RPS_NO_CPU && cpu_online(tcpu)) { 2696 if (tcpu != RPS_NO_CPU && cpu_online(tcpu)) {
2617 *rflowp = rflow; 2697 *rflowp = rflow;
2618 cpu = tcpu; 2698 cpu = tcpu;
@@ -2633,6 +2713,46 @@ done:
2633 return cpu; 2713 return cpu;
2634} 2714}
2635 2715
2716#ifdef CONFIG_RFS_ACCEL
2717
2718/**
2719 * rps_may_expire_flow - check whether an RFS hardware filter may be removed
2720 * @dev: Device on which the filter was set
2721 * @rxq_index: RX queue index
2722 * @flow_id: Flow ID passed to ndo_rx_flow_steer()
2723 * @filter_id: Filter ID returned by ndo_rx_flow_steer()
2724 *
2725 * Drivers that implement ndo_rx_flow_steer() should periodically call
2726 * this function for each installed filter and remove the filters for
2727 * which it returns %true.
2728 */
2729bool rps_may_expire_flow(struct net_device *dev, u16 rxq_index,
2730 u32 flow_id, u16 filter_id)
2731{
2732 struct netdev_rx_queue *rxqueue = dev->_rx + rxq_index;
2733 struct rps_dev_flow_table *flow_table;
2734 struct rps_dev_flow *rflow;
2735 bool expire = true;
2736 int cpu;
2737
2738 rcu_read_lock();
2739 flow_table = rcu_dereference(rxqueue->rps_flow_table);
2740 if (flow_table && flow_id <= flow_table->mask) {
2741 rflow = &flow_table->flows[flow_id];
2742 cpu = ACCESS_ONCE(rflow->cpu);
2743 if (rflow->filter == filter_id && cpu != RPS_NO_CPU &&
2744 ((int)(per_cpu(softnet_data, cpu).input_queue_head -
2745 rflow->last_qtail) <
2746 (int)(10 * flow_table->mask)))
2747 expire = false;
2748 }
2749 rcu_read_unlock();
2750 return expire;
2751}
2752EXPORT_SYMBOL(rps_may_expire_flow);
2753
2754#endif /* CONFIG_RFS_ACCEL */
2755
2636/* Called from hardirq (IPI) context */ 2756/* Called from hardirq (IPI) context */
2637static void rps_trigger_softirq(void *data) 2757static void rps_trigger_softirq(void *data)
2638{ 2758{
@@ -2850,8 +2970,8 @@ EXPORT_SYMBOL_GPL(br_fdb_test_addr_hook);
2850 * when CONFIG_NET_CLS_ACT is? otherwise some useless instructions 2970 * when CONFIG_NET_CLS_ACT is? otherwise some useless instructions
2851 * a compare and 2 stores extra right now if we dont have it on 2971 * a compare and 2 stores extra right now if we dont have it on
2852 * but have CONFIG_NET_CLS_ACT 2972 * but have CONFIG_NET_CLS_ACT
2853 * NOTE: This doesnt stop any functionality; if you dont have 2973 * NOTE: This doesn't stop any functionality; if you dont have
2854 * the ingress scheduler, you just cant add policies on ingress. 2974 * the ingress scheduler, you just can't add policies on ingress.
2855 * 2975 *
2856 */ 2976 */
2857static int ing_filter(struct sk_buff *skb, struct netdev_queue *rxq) 2977static int ing_filter(struct sk_buff *skb, struct netdev_queue *rxq)
@@ -2920,6 +3040,8 @@ out:
2920 * on a failure. 3040 * on a failure.
2921 * 3041 *
2922 * The caller must hold the rtnl_mutex. 3042 * The caller must hold the rtnl_mutex.
3043 *
3044 * For a general description of rx_handler, see enum rx_handler_result.
2923 */ 3045 */
2924int netdev_rx_handler_register(struct net_device *dev, 3046int netdev_rx_handler_register(struct net_device *dev,
2925 rx_handler_func_t *rx_handler, 3047 rx_handler_func_t *rx_handler,
@@ -2954,64 +3076,32 @@ void netdev_rx_handler_unregister(struct net_device *dev)
2954} 3076}
2955EXPORT_SYMBOL_GPL(netdev_rx_handler_unregister); 3077EXPORT_SYMBOL_GPL(netdev_rx_handler_unregister);
2956 3078
2957static inline void skb_bond_set_mac_by_master(struct sk_buff *skb, 3079static void vlan_on_bond_hook(struct sk_buff *skb)
2958 struct net_device *master)
2959{
2960 if (skb->pkt_type == PACKET_HOST) {
2961 u16 *dest = (u16 *) eth_hdr(skb)->h_dest;
2962
2963 memcpy(dest, master->dev_addr, ETH_ALEN);
2964 }
2965}
2966
2967/* On bonding slaves other than the currently active slave, suppress
2968 * duplicates except for 802.3ad ETH_P_SLOW, alb non-mcast/bcast, and
2969 * ARP on active-backup slaves with arp_validate enabled.
2970 */
2971int __skb_bond_should_drop(struct sk_buff *skb, struct net_device *master)
2972{ 3080{
2973 struct net_device *dev = skb->dev; 3081 /*
2974 3082 * Make sure ARP frames received on VLAN interfaces stacked on
2975 if (master->priv_flags & IFF_MASTER_ARPMON) 3083 * bonding interfaces still make their way to any base bonding
2976 dev->last_rx = jiffies; 3084 * device that may have registered for a specific ptype.
2977 3085 */
2978 if ((master->priv_flags & IFF_MASTER_ALB) && 3086 if (skb->dev->priv_flags & IFF_802_1Q_VLAN &&
2979 (master->priv_flags & IFF_BRIDGE_PORT)) { 3087 vlan_dev_real_dev(skb->dev)->priv_flags & IFF_BONDING &&
2980 /* Do address unmangle. The local destination address 3088 skb->protocol == htons(ETH_P_ARP)) {
2981 * will be always the one master has. Provides the right 3089 struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);
2982 * functionality in a bridge.
2983 */
2984 skb_bond_set_mac_by_master(skb, master);
2985 }
2986
2987 if (dev->priv_flags & IFF_SLAVE_INACTIVE) {
2988 if ((dev->priv_flags & IFF_SLAVE_NEEDARP) &&
2989 skb->protocol == __cpu_to_be16(ETH_P_ARP))
2990 return 0;
2991
2992 if (master->priv_flags & IFF_MASTER_ALB) {
2993 if (skb->pkt_type != PACKET_BROADCAST &&
2994 skb->pkt_type != PACKET_MULTICAST)
2995 return 0;
2996 }
2997 if (master->priv_flags & IFF_MASTER_8023AD &&
2998 skb->protocol == __cpu_to_be16(ETH_P_SLOW))
2999 return 0;
3000 3090
3001 return 1; 3091 if (!skb2)
3092 return;
3093 skb2->dev = vlan_dev_real_dev(skb->dev);
3094 netif_rx(skb2);
3002 } 3095 }
3003 return 0;
3004} 3096}
3005EXPORT_SYMBOL(__skb_bond_should_drop);
3006 3097
3007static int __netif_receive_skb(struct sk_buff *skb) 3098static int __netif_receive_skb(struct sk_buff *skb)
3008{ 3099{
3009 struct packet_type *ptype, *pt_prev; 3100 struct packet_type *ptype, *pt_prev;
3010 rx_handler_func_t *rx_handler; 3101 rx_handler_func_t *rx_handler;
3011 struct net_device *orig_dev; 3102 struct net_device *orig_dev;
3012 struct net_device *master; 3103 struct net_device *null_or_dev;
3013 struct net_device *null_or_orig; 3104 bool deliver_exact = false;
3014 struct net_device *orig_or_bond;
3015 int ret = NET_RX_DROP; 3105 int ret = NET_RX_DROP;
3016 __be16 type; 3106 __be16 type;
3017 3107
@@ -3026,28 +3116,8 @@ static int __netif_receive_skb(struct sk_buff *skb)
3026 3116
3027 if (!skb->skb_iif) 3117 if (!skb->skb_iif)
3028 skb->skb_iif = skb->dev->ifindex; 3118 skb->skb_iif = skb->dev->ifindex;
3029
3030 /*
3031 * bonding note: skbs received on inactive slaves should only
3032 * be delivered to pkt handlers that are exact matches. Also
3033 * the deliver_no_wcard flag will be set. If packet handlers
3034 * are sensitive to duplicate packets these skbs will need to
3035 * be dropped at the handler.
3036 */
3037 null_or_orig = NULL;
3038 orig_dev = skb->dev; 3119 orig_dev = skb->dev;
3039 master = ACCESS_ONCE(orig_dev->master);
3040 if (skb->deliver_no_wcard)
3041 null_or_orig = orig_dev;
3042 else if (master) {
3043 if (skb_bond_should_drop(skb, master)) {
3044 skb->deliver_no_wcard = 1;
3045 null_or_orig = orig_dev; /* deliver only exact match */
3046 } else
3047 skb->dev = master;
3048 }
3049 3120
3050 __this_cpu_inc(softnet_data.processed);
3051 skb_reset_network_header(skb); 3121 skb_reset_network_header(skb);
3052 skb_reset_transport_header(skb); 3122 skb_reset_transport_header(skb);
3053 skb->mac_len = skb->network_header - skb->mac_header; 3123 skb->mac_len = skb->network_header - skb->mac_header;
@@ -3056,6 +3126,10 @@ static int __netif_receive_skb(struct sk_buff *skb)
3056 3126
3057 rcu_read_lock(); 3127 rcu_read_lock();
3058 3128
3129another_round:
3130
3131 __this_cpu_inc(softnet_data.processed);
3132
3059#ifdef CONFIG_NET_CLS_ACT 3133#ifdef CONFIG_NET_CLS_ACT
3060 if (skb->tc_verd & TC_NCLS) { 3134 if (skb->tc_verd & TC_NCLS) {
3061 skb->tc_verd = CLR_TC_NCLS(skb->tc_verd); 3135 skb->tc_verd = CLR_TC_NCLS(skb->tc_verd);
@@ -3064,8 +3138,7 @@ static int __netif_receive_skb(struct sk_buff *skb)
3064#endif 3138#endif
3065 3139
3066 list_for_each_entry_rcu(ptype, &ptype_all, list) { 3140 list_for_each_entry_rcu(ptype, &ptype_all, list) {
3067 if (ptype->dev == null_or_orig || ptype->dev == skb->dev || 3141 if (!ptype->dev || ptype->dev == skb->dev) {
3068 ptype->dev == orig_dev) {
3069 if (pt_prev) 3142 if (pt_prev)
3070 ret = deliver_skb(skb, pt_prev, orig_dev); 3143 ret = deliver_skb(skb, pt_prev, orig_dev);
3071 pt_prev = ptype; 3144 pt_prev = ptype;
@@ -3079,16 +3152,24 @@ static int __netif_receive_skb(struct sk_buff *skb)
3079ncls: 3152ncls:
3080#endif 3153#endif
3081 3154
3082 /* Handle special case of bridge or macvlan */
3083 rx_handler = rcu_dereference(skb->dev->rx_handler); 3155 rx_handler = rcu_dereference(skb->dev->rx_handler);
3084 if (rx_handler) { 3156 if (rx_handler) {
3085 if (pt_prev) { 3157 if (pt_prev) {
3086 ret = deliver_skb(skb, pt_prev, orig_dev); 3158 ret = deliver_skb(skb, pt_prev, orig_dev);
3087 pt_prev = NULL; 3159 pt_prev = NULL;
3088 } 3160 }
3089 skb = rx_handler(skb); 3161 switch (rx_handler(&skb)) {
3090 if (!skb) 3162 case RX_HANDLER_CONSUMED:
3091 goto out; 3163 goto out;
3164 case RX_HANDLER_ANOTHER:
3165 goto another_round;
3166 case RX_HANDLER_EXACT:
3167 deliver_exact = true;
3168 case RX_HANDLER_PASS:
3169 break;
3170 default:
3171 BUG();
3172 }
3092 } 3173 }
3093 3174
3094 if (vlan_tx_tag_present(skb)) { 3175 if (vlan_tx_tag_present(skb)) {
@@ -3103,24 +3184,17 @@ ncls:
3103 goto out; 3184 goto out;
3104 } 3185 }
3105 3186
3106 /* 3187 vlan_on_bond_hook(skb);
3107 * Make sure frames received on VLAN interfaces stacked on 3188
3108 * bonding interfaces still make their way to any base bonding 3189 /* deliver only exact match when indicated */
3109 * device that may have registered for a specific ptype. The 3190 null_or_dev = deliver_exact ? skb->dev : NULL;
3110 * handler may have to adjust skb->dev and orig_dev.
3111 */
3112 orig_or_bond = orig_dev;
3113 if ((skb->dev->priv_flags & IFF_802_1Q_VLAN) &&
3114 (vlan_dev_real_dev(skb->dev)->priv_flags & IFF_BONDING)) {
3115 orig_or_bond = vlan_dev_real_dev(skb->dev);
3116 }
3117 3191
3118 type = skb->protocol; 3192 type = skb->protocol;
3119 list_for_each_entry_rcu(ptype, 3193 list_for_each_entry_rcu(ptype,
3120 &ptype_base[ntohs(type) & PTYPE_HASH_MASK], list) { 3194 &ptype_base[ntohs(type) & PTYPE_HASH_MASK], list) {
3121 if (ptype->type == type && (ptype->dev == null_or_orig || 3195 if (ptype->type == type &&
3122 ptype->dev == skb->dev || ptype->dev == orig_dev || 3196 (ptype->dev == null_or_dev || ptype->dev == skb->dev ||
3123 ptype->dev == orig_or_bond)) { 3197 ptype->dev == orig_dev)) {
3124 if (pt_prev) 3198 if (pt_prev)
3125 ret = deliver_skb(skb, pt_prev, orig_dev); 3199 ret = deliver_skb(skb, pt_prev, orig_dev);
3126 pt_prev = ptype; 3200 pt_prev = ptype;
@@ -3726,7 +3800,7 @@ static void net_rx_action(struct softirq_action *h)
3726 * with netpoll's poll_napi(). Only the entity which 3800 * with netpoll's poll_napi(). Only the entity which
3727 * obtains the lock and sees NAPI_STATE_SCHED set will 3801 * obtains the lock and sees NAPI_STATE_SCHED set will
3728 * actually make the ->poll() call. Therefore we avoid 3802 * actually make the ->poll() call. Therefore we avoid
3729 * accidently calling ->poll() when NAPI is not scheduled. 3803 * accidentally calling ->poll() when NAPI is not scheduled.
3730 */ 3804 */
3731 work = 0; 3805 work = 0;
3732 if (test_bit(NAPI_STATE_SCHED, &n->state)) { 3806 if (test_bit(NAPI_STATE_SCHED, &n->state)) {
@@ -3917,12 +3991,15 @@ void *dev_seq_start(struct seq_file *seq, loff_t *pos)
3917 3991
3918void *dev_seq_next(struct seq_file *seq, void *v, loff_t *pos) 3992void *dev_seq_next(struct seq_file *seq, void *v, loff_t *pos)
3919{ 3993{
3920 struct net_device *dev = (v == SEQ_START_TOKEN) ? 3994 struct net_device *dev = v;
3921 first_net_device(seq_file_net(seq)) : 3995
3922 next_net_device((struct net_device *)v); 3996 if (v == SEQ_START_TOKEN)
3997 dev = first_net_device_rcu(seq_file_net(seq));
3998 else
3999 dev = next_net_device_rcu(dev);
3923 4000
3924 ++*pos; 4001 ++*pos;
3925 return rcu_dereference(dev); 4002 return dev;
3926} 4003}
3927 4004
3928void dev_seq_stop(struct seq_file *seq, void *v) 4005void dev_seq_stop(struct seq_file *seq, void *v)
@@ -4206,15 +4283,14 @@ static int __init dev_proc_init(void)
4206 4283
4207 4284
4208/** 4285/**
4209 * netdev_set_master - set up master/slave pair 4286 * netdev_set_master - set up master pointer
4210 * @slave: slave device 4287 * @slave: slave device
4211 * @master: new master device 4288 * @master: new master device
4212 * 4289 *
4213 * Changes the master device of the slave. Pass %NULL to break the 4290 * Changes the master device of the slave. Pass %NULL to break the
4214 * bonding. The caller must hold the RTNL semaphore. On a failure 4291 * bonding. The caller must hold the RTNL semaphore. On a failure
4215 * a negative errno code is returned. On success the reference counts 4292 * a negative errno code is returned. On success the reference counts
4216 * are adjusted, %RTM_NEWLINK is sent to the routing socket and the 4293 * are adjusted and the function returns zero.
4217 * function returns zero.
4218 */ 4294 */
4219int netdev_set_master(struct net_device *slave, struct net_device *master) 4295int netdev_set_master(struct net_device *slave, struct net_device *master)
4220{ 4296{
@@ -4234,6 +4310,29 @@ int netdev_set_master(struct net_device *slave, struct net_device *master)
4234 synchronize_net(); 4310 synchronize_net();
4235 dev_put(old); 4311 dev_put(old);
4236 } 4312 }
4313 return 0;
4314}
4315EXPORT_SYMBOL(netdev_set_master);
4316
4317/**
4318 * netdev_set_bond_master - set up bonding master/slave pair
4319 * @slave: slave device
4320 * @master: new master device
4321 *
4322 * Changes the master device of the slave. Pass %NULL to break the
4323 * bonding. The caller must hold the RTNL semaphore. On a failure
4324 * a negative errno code is returned. On success %RTM_NEWLINK is sent
4325 * to the routing socket and the function returns zero.
4326 */
4327int netdev_set_bond_master(struct net_device *slave, struct net_device *master)
4328{
4329 int err;
4330
4331 ASSERT_RTNL();
4332
4333 err = netdev_set_master(slave, master);
4334 if (err)
4335 return err;
4237 if (master) 4336 if (master)
4238 slave->flags |= IFF_SLAVE; 4337 slave->flags |= IFF_SLAVE;
4239 else 4338 else
@@ -4242,7 +4341,7 @@ int netdev_set_master(struct net_device *slave, struct net_device *master)
4242 rtmsg_ifinfo(RTM_NEWLINK, slave, IFF_SLAVE); 4341 rtmsg_ifinfo(RTM_NEWLINK, slave, IFF_SLAVE);
4243 return 0; 4342 return 0;
4244} 4343}
4245EXPORT_SYMBOL(netdev_set_master); 4344EXPORT_SYMBOL(netdev_set_bond_master);
4246 4345
4247static void dev_change_rx_flags(struct net_device *dev, int flags) 4346static void dev_change_rx_flags(struct net_device *dev, int flags)
4248{ 4347{
@@ -4579,6 +4678,17 @@ int dev_set_mtu(struct net_device *dev, int new_mtu)
4579EXPORT_SYMBOL(dev_set_mtu); 4678EXPORT_SYMBOL(dev_set_mtu);
4580 4679
4581/** 4680/**
4681 * dev_set_group - Change group this device belongs to
4682 * @dev: device
4683 * @new_group: group this device should belong to
4684 */
4685void dev_set_group(struct net_device *dev, int new_group)
4686{
4687 dev->group = new_group;
4688}
4689EXPORT_SYMBOL(dev_set_group);
4690
4691/**
4582 * dev_set_mac_address - Change Media Access Control Address 4692 * dev_set_mac_address - Change Media Access Control Address
4583 * @dev: device 4693 * @dev: device
4584 * @sa: new address 4694 * @sa: new address
@@ -4663,7 +4773,7 @@ static int dev_ifsioc_locked(struct net *net, struct ifreq *ifr, unsigned int cm
4663 * is never reached 4773 * is never reached
4664 */ 4774 */
4665 WARN_ON(1); 4775 WARN_ON(1);
4666 err = -EINVAL; 4776 err = -ENOTTY;
4667 break; 4777 break;
4668 4778
4669 } 4779 }
@@ -4931,7 +5041,7 @@ int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg)
4931 /* Set the per device memory buffer space. 5041 /* Set the per device memory buffer space.
4932 * Not applicable in our case */ 5042 * Not applicable in our case */
4933 case SIOCSIFLINK: 5043 case SIOCSIFLINK:
4934 return -EINVAL; 5044 return -ENOTTY;
4935 5045
4936 /* 5046 /*
4937 * Unknown or private ioctl. 5047 * Unknown or private ioctl.
@@ -4952,7 +5062,7 @@ int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg)
4952 /* Take care of Wireless Extensions */ 5062 /* Take care of Wireless Extensions */
4953 if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) 5063 if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST)
4954 return wext_handle_ioctl(net, &ifr, cmd, arg); 5064 return wext_handle_ioctl(net, &ifr, cmd, arg);
4955 return -EINVAL; 5065 return -ENOTTY;
4956 } 5066 }
4957} 5067}
4958 5068
@@ -5069,41 +5179,59 @@ static void rollback_registered(struct net_device *dev)
5069 list_del(&single); 5179 list_del(&single);
5070} 5180}
5071 5181
5072unsigned long netdev_fix_features(unsigned long features, const char *name) 5182u32 netdev_fix_features(struct net_device *dev, u32 features)
5073{ 5183{
5184 /* Fix illegal checksum combinations */
5185 if ((features & NETIF_F_HW_CSUM) &&
5186 (features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) {
5187 netdev_info(dev, "mixed HW and IP checksum settings.\n");
5188 features &= ~(NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM);
5189 }
5190
5191 if ((features & NETIF_F_NO_CSUM) &&
5192 (features & (NETIF_F_HW_CSUM|NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) {
5193 netdev_info(dev, "mixed no checksumming and other settings.\n");
5194 features &= ~(NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM|NETIF_F_HW_CSUM);
5195 }
5196
5074 /* Fix illegal SG+CSUM combinations. */ 5197 /* Fix illegal SG+CSUM combinations. */
5075 if ((features & NETIF_F_SG) && 5198 if ((features & NETIF_F_SG) &&
5076 !(features & NETIF_F_ALL_CSUM)) { 5199 !(features & NETIF_F_ALL_CSUM)) {
5077 if (name) 5200 netdev_info(dev,
5078 printk(KERN_NOTICE "%s: Dropping NETIF_F_SG since no " 5201 "Dropping NETIF_F_SG since no checksum feature.\n");
5079 "checksum feature.\n", name);
5080 features &= ~NETIF_F_SG; 5202 features &= ~NETIF_F_SG;
5081 } 5203 }
5082 5204
5083 /* TSO requires that SG is present as well. */ 5205 /* TSO requires that SG is present as well. */
5084 if ((features & NETIF_F_TSO) && !(features & NETIF_F_SG)) { 5206 if ((features & NETIF_F_ALL_TSO) && !(features & NETIF_F_SG)) {
5085 if (name) 5207 netdev_info(dev, "Dropping TSO features since no SG feature.\n");
5086 printk(KERN_NOTICE "%s: Dropping NETIF_F_TSO since no " 5208 features &= ~NETIF_F_ALL_TSO;
5087 "SG feature.\n", name); 5209 }
5088 features &= ~NETIF_F_TSO; 5210
5211 /* TSO ECN requires that TSO is present as well. */
5212 if ((features & NETIF_F_ALL_TSO) == NETIF_F_TSO_ECN)
5213 features &= ~NETIF_F_TSO_ECN;
5214
5215 /* Software GSO depends on SG. */
5216 if ((features & NETIF_F_GSO) && !(features & NETIF_F_SG)) {
5217 netdev_info(dev, "Dropping NETIF_F_GSO since no SG feature.\n");
5218 features &= ~NETIF_F_GSO;
5089 } 5219 }
5090 5220
5221 /* UFO needs SG and checksumming */
5091 if (features & NETIF_F_UFO) { 5222 if (features & NETIF_F_UFO) {
5092 /* maybe split UFO into V4 and V6? */ 5223 /* maybe split UFO into V4 and V6? */
5093 if (!((features & NETIF_F_GEN_CSUM) || 5224 if (!((features & NETIF_F_GEN_CSUM) ||
5094 (features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM)) 5225 (features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))
5095 == (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) { 5226 == (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) {
5096 if (name) 5227 netdev_info(dev,
5097 printk(KERN_ERR "%s: Dropping NETIF_F_UFO " 5228 "Dropping NETIF_F_UFO since no checksum offload features.\n");
5098 "since no checksum offload features.\n",
5099 name);
5100 features &= ~NETIF_F_UFO; 5229 features &= ~NETIF_F_UFO;
5101 } 5230 }
5102 5231
5103 if (!(features & NETIF_F_SG)) { 5232 if (!(features & NETIF_F_SG)) {
5104 if (name) 5233 netdev_info(dev,
5105 printk(KERN_ERR "%s: Dropping NETIF_F_UFO " 5234 "Dropping NETIF_F_UFO since no NETIF_F_SG feature.\n");
5106 "since no NETIF_F_SG feature.\n", name);
5107 features &= ~NETIF_F_UFO; 5235 features &= ~NETIF_F_UFO;
5108 } 5236 }
5109 } 5237 }
@@ -5112,6 +5240,37 @@ unsigned long netdev_fix_features(unsigned long features, const char *name)
5112} 5240}
5113EXPORT_SYMBOL(netdev_fix_features); 5241EXPORT_SYMBOL(netdev_fix_features);
5114 5242
5243void netdev_update_features(struct net_device *dev)
5244{
5245 u32 features;
5246 int err = 0;
5247
5248 features = netdev_get_wanted_features(dev);
5249
5250 if (dev->netdev_ops->ndo_fix_features)
5251 features = dev->netdev_ops->ndo_fix_features(dev, features);
5252
5253 /* driver might be less strict about feature dependencies */
5254 features = netdev_fix_features(dev, features);
5255
5256 if (dev->features == features)
5257 return;
5258
5259 netdev_info(dev, "Features changed: 0x%08x -> 0x%08x\n",
5260 dev->features, features);
5261
5262 if (dev->netdev_ops->ndo_set_features)
5263 err = dev->netdev_ops->ndo_set_features(dev, features);
5264
5265 if (!err)
5266 dev->features = features;
5267 else if (err < 0)
5268 netdev_err(dev,
5269 "set_features() failed (%d); wanted 0x%08x, left 0x%08x\n",
5270 err, features, dev->features);
5271}
5272EXPORT_SYMBOL(netdev_update_features);
5273
5115/** 5274/**
5116 * netif_stacked_transfer_operstate - transfer operstate 5275 * netif_stacked_transfer_operstate - transfer operstate
5117 * @rootdev: the root or lower level device to transfer state from 5276 * @rootdev: the root or lower level device to transfer state from
@@ -5246,27 +5405,19 @@ int register_netdevice(struct net_device *dev)
5246 if (dev->iflink == -1) 5405 if (dev->iflink == -1)
5247 dev->iflink = dev->ifindex; 5406 dev->iflink = dev->ifindex;
5248 5407
5249 /* Fix illegal checksum combinations */ 5408 /* Transfer changeable features to wanted_features and enable
5250 if ((dev->features & NETIF_F_HW_CSUM) && 5409 * software offloads (GSO and GRO).
5251 (dev->features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) { 5410 */
5252 printk(KERN_NOTICE "%s: mixed HW and IP checksum settings.\n", 5411 dev->hw_features |= NETIF_F_SOFT_FEATURES;
5253 dev->name); 5412 dev->features |= NETIF_F_SOFT_FEATURES;
5254 dev->features &= ~(NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM); 5413 dev->wanted_features = dev->features & dev->hw_features;
5255 }
5256 5414
5257 if ((dev->features & NETIF_F_NO_CSUM) && 5415 /* Avoid warning from netdev_fix_features() for GSO without SG */
5258 (dev->features & (NETIF_F_HW_CSUM|NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) { 5416 if (!(dev->wanted_features & NETIF_F_SG)) {
5259 printk(KERN_NOTICE "%s: mixed no checksumming and other settings.\n", 5417 dev->wanted_features &= ~NETIF_F_GSO;
5260 dev->name); 5418 dev->features &= ~NETIF_F_GSO;
5261 dev->features &= ~(NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM|NETIF_F_HW_CSUM);
5262 } 5419 }
5263 5420
5264 dev->features = netdev_fix_features(dev->features, dev->name);
5265
5266 /* Enable software GSO if SG is supported. */
5267 if (dev->features & NETIF_F_SG)
5268 dev->features |= NETIF_F_GSO;
5269
5270 /* Enable GRO and NETIF_F_HIGHDMA for vlans by default, 5421 /* Enable GRO and NETIF_F_HIGHDMA for vlans by default,
5271 * vlan_dev_init() will do the dev->features check, so these features 5422 * vlan_dev_init() will do the dev->features check, so these features
5272 * are enabled only if supported by underlying device. 5423 * are enabled only if supported by underlying device.
@@ -5283,6 +5434,8 @@ int register_netdevice(struct net_device *dev)
5283 goto err_uninit; 5434 goto err_uninit;
5284 dev->reg_state = NETREG_REGISTERED; 5435 dev->reg_state = NETREG_REGISTERED;
5285 5436
5437 netdev_update_features(dev);
5438
5286 /* 5439 /*
5287 * Default initial state at registry is that the 5440 * Default initial state at registry is that the
5288 * device is present. 5441 * device is present.
@@ -5687,6 +5840,7 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
5687#endif 5840#endif
5688 5841
5689 strcpy(dev->name, name); 5842 strcpy(dev->name, name);
5843 dev->group = INIT_NETDEV_GROUP;
5690 return dev; 5844 return dev;
5691 5845
5692free_all: 5846free_all:
@@ -6001,8 +6155,7 @@ static int dev_cpu_callback(struct notifier_block *nfb,
6001 * @one to the master device with current feature set @all. Will not 6155 * @one to the master device with current feature set @all. Will not
6002 * enable anything that is off in @mask. Returns the new feature set. 6156 * enable anything that is off in @mask. Returns the new feature set.
6003 */ 6157 */
6004unsigned long netdev_increment_features(unsigned long all, unsigned long one, 6158u32 netdev_increment_features(u32 all, u32 one, u32 mask)
6005 unsigned long mask)
6006{ 6159{
6007 /* If device needs checksumming, downgrade to it. */ 6160 /* If device needs checksumming, downgrade to it. */
6008 if (all & NETIF_F_NO_CSUM && !(one & NETIF_F_NO_CSUM)) 6161 if (all & NETIF_F_NO_CSUM && !(one & NETIF_F_NO_CSUM))
@@ -6187,7 +6340,7 @@ static void __net_exit default_device_exit(struct net *net)
6187 if (dev->rtnl_link_ops) 6340 if (dev->rtnl_link_ops)
6188 continue; 6341 continue;
6189 6342
6190 /* Push remaing network devices to init_net */ 6343 /* Push remaining network devices to init_net */
6191 snprintf(fb_name, IFNAMSIZ, "dev%d", dev->ifindex); 6344 snprintf(fb_name, IFNAMSIZ, "dev%d", dev->ifindex);
6192 err = dev_change_net_namespace(dev, &init_net, fb_name); 6345 err = dev_change_net_namespace(dev, &init_net, fb_name);
6193 if (err) { 6346 if (err) {
diff --git a/net/core/dev_addr_lists.c b/net/core/dev_addr_lists.c
index 508f9c18992f..7b39f3ed2fda 100644
--- a/net/core/dev_addr_lists.c
+++ b/net/core/dev_addr_lists.c
@@ -144,7 +144,7 @@ void __hw_addr_del_multiple(struct netdev_hw_addr_list *to_list,
144 144
145 list_for_each_entry(ha, &from_list->list, list) { 145 list_for_each_entry(ha, &from_list->list, list) {
146 type = addr_type ? addr_type : ha->type; 146 type = addr_type ? addr_type : ha->type;
147 __hw_addr_del(to_list, ha->addr, addr_len, addr_type); 147 __hw_addr_del(to_list, ha->addr, addr_len, type);
148 } 148 }
149} 149}
150EXPORT_SYMBOL(__hw_addr_del_multiple); 150EXPORT_SYMBOL(__hw_addr_del_multiple);
@@ -357,8 +357,8 @@ EXPORT_SYMBOL(dev_addr_add_multiple);
357/** 357/**
358 * dev_addr_del_multiple - Delete device addresses by another device 358 * dev_addr_del_multiple - Delete device addresses by another device
359 * @to_dev: device where the addresses will be deleted 359 * @to_dev: device where the addresses will be deleted
360 * @from_dev: device by which addresses the addresses will be deleted 360 * @from_dev: device supplying the addresses to be deleted
361 * @addr_type: address type - 0 means type will used from from_dev 361 * @addr_type: address type - 0 means type will be used from from_dev
362 * 362 *
363 * Deletes addresses in to device by the list of addresses in from device. 363 * Deletes addresses in to device by the list of addresses in from device.
364 * 364 *
diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c
index 36e603c78ce9..706502ff64aa 100644
--- a/net/core/drop_monitor.c
+++ b/net/core/drop_monitor.c
@@ -350,7 +350,7 @@ static int __init init_net_drop_monitor(void)
350 struct per_cpu_dm_data *data; 350 struct per_cpu_dm_data *data;
351 int cpu, rc; 351 int cpu, rc;
352 352
353 printk(KERN_INFO "Initalizing network drop monitor service\n"); 353 printk(KERN_INFO "Initializing network drop monitor service\n");
354 354
355 if (sizeof(void *) > 8) { 355 if (sizeof(void *) > 8) {
356 printk(KERN_ERR "Unable to store program counters on this arch, Drop monitor failed\n"); 356 printk(KERN_ERR "Unable to store program counters on this arch, Drop monitor failed\n");
diff --git a/net/core/dst.c b/net/core/dst.c
index b99c7c7ffce2..91104d35de7d 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -164,7 +164,9 @@ int dst_discard(struct sk_buff *skb)
164} 164}
165EXPORT_SYMBOL(dst_discard); 165EXPORT_SYMBOL(dst_discard);
166 166
167void *dst_alloc(struct dst_ops *ops) 167const u32 dst_default_metrics[RTAX_MAX];
168
169void *dst_alloc(struct dst_ops *ops, int initial_ref)
168{ 170{
169 struct dst_entry *dst; 171 struct dst_entry *dst;
170 172
@@ -175,11 +177,12 @@ void *dst_alloc(struct dst_ops *ops)
175 dst = kmem_cache_zalloc(ops->kmem_cachep, GFP_ATOMIC); 177 dst = kmem_cache_zalloc(ops->kmem_cachep, GFP_ATOMIC);
176 if (!dst) 178 if (!dst)
177 return NULL; 179 return NULL;
178 atomic_set(&dst->__refcnt, 0); 180 atomic_set(&dst->__refcnt, initial_ref);
179 dst->ops = ops; 181 dst->ops = ops;
180 dst->lastuse = jiffies; 182 dst->lastuse = jiffies;
181 dst->path = dst; 183 dst->path = dst;
182 dst->input = dst->output = dst_discard; 184 dst->input = dst->output = dst_discard;
185 dst_init_metrics(dst, dst_default_metrics, true);
183#if RT_CACHE_DEBUG >= 2 186#if RT_CACHE_DEBUG >= 2
184 atomic_inc(&dst_total); 187 atomic_inc(&dst_total);
185#endif 188#endif
@@ -282,6 +285,42 @@ void dst_release(struct dst_entry *dst)
282} 285}
283EXPORT_SYMBOL(dst_release); 286EXPORT_SYMBOL(dst_release);
284 287
288u32 *dst_cow_metrics_generic(struct dst_entry *dst, unsigned long old)
289{
290 u32 *p = kmalloc(sizeof(u32) * RTAX_MAX, GFP_ATOMIC);
291
292 if (p) {
293 u32 *old_p = __DST_METRICS_PTR(old);
294 unsigned long prev, new;
295
296 memcpy(p, old_p, sizeof(u32) * RTAX_MAX);
297
298 new = (unsigned long) p;
299 prev = cmpxchg(&dst->_metrics, old, new);
300
301 if (prev != old) {
302 kfree(p);
303 p = __DST_METRICS_PTR(prev);
304 if (prev & DST_METRICS_READ_ONLY)
305 p = NULL;
306 }
307 }
308 return p;
309}
310EXPORT_SYMBOL(dst_cow_metrics_generic);
311
312/* Caller asserts that dst_metrics_read_only(dst) is false. */
313void __dst_destroy_metrics_generic(struct dst_entry *dst, unsigned long old)
314{
315 unsigned long prev, new;
316
317 new = (unsigned long) dst_default_metrics;
318 prev = cmpxchg(&dst->_metrics, old, new);
319 if (prev == old)
320 kfree(__DST_METRICS_PTR(old));
321}
322EXPORT_SYMBOL(__dst_destroy_metrics_generic);
323
285/** 324/**
286 * skb_dst_set_noref - sets skb dst, without a reference 325 * skb_dst_set_noref - sets skb dst, without a reference
287 * @skb: buffer 326 * @skb: buffer
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index ff2302910b5e..74ead9eca126 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -34,12 +34,6 @@ u32 ethtool_op_get_link(struct net_device *dev)
34} 34}
35EXPORT_SYMBOL(ethtool_op_get_link); 35EXPORT_SYMBOL(ethtool_op_get_link);
36 36
37u32 ethtool_op_get_rx_csum(struct net_device *dev)
38{
39 return (dev->features & NETIF_F_ALL_CSUM) != 0;
40}
41EXPORT_SYMBOL(ethtool_op_get_rx_csum);
42
43u32 ethtool_op_get_tx_csum(struct net_device *dev) 37u32 ethtool_op_get_tx_csum(struct net_device *dev)
44{ 38{
45 return (dev->features & NETIF_F_ALL_CSUM) != 0; 39 return (dev->features & NETIF_F_ALL_CSUM) != 0;
@@ -55,6 +49,7 @@ int ethtool_op_set_tx_csum(struct net_device *dev, u32 data)
55 49
56 return 0; 50 return 0;
57} 51}
52EXPORT_SYMBOL(ethtool_op_set_tx_csum);
58 53
59int ethtool_op_set_tx_hw_csum(struct net_device *dev, u32 data) 54int ethtool_op_set_tx_hw_csum(struct net_device *dev, u32 data)
60{ 55{
@@ -146,9 +141,24 @@ u32 ethtool_op_get_flags(struct net_device *dev)
146} 141}
147EXPORT_SYMBOL(ethtool_op_get_flags); 142EXPORT_SYMBOL(ethtool_op_get_flags);
148 143
144/* Check if device can enable (or disable) particular feature coded in "data"
145 * argument. Flags "supported" describe features that can be toggled by device.
146 * If feature can not be toggled, it state (enabled or disabled) must match
147 * hardcoded device features state, otherwise flags are marked as invalid.
148 */
149bool ethtool_invalid_flags(struct net_device *dev, u32 data, u32 supported)
150{
151 u32 features = dev->features & flags_dup_features;
152 /* "data" can contain only flags_dup_features bits,
153 * see __ethtool_set_flags */
154
155 return (features & ~supported) != (data & ~supported);
156}
157EXPORT_SYMBOL(ethtool_invalid_flags);
158
149int ethtool_op_set_flags(struct net_device *dev, u32 data, u32 supported) 159int ethtool_op_set_flags(struct net_device *dev, u32 data, u32 supported)
150{ 160{
151 if (data & ~supported) 161 if (ethtool_invalid_flags(dev, data, supported))
152 return -EINVAL; 162 return -EINVAL;
153 163
154 dev->features = ((dev->features & ~flags_dup_features) | 164 dev->features = ((dev->features & ~flags_dup_features) |
@@ -171,6 +181,381 @@ EXPORT_SYMBOL(ethtool_ntuple_flush);
171 181
172/* Handlers for each ethtool command */ 182/* Handlers for each ethtool command */
173 183
184#define ETHTOOL_DEV_FEATURE_WORDS 1
185
186static void ethtool_get_features_compat(struct net_device *dev,
187 struct ethtool_get_features_block *features)
188{
189 if (!dev->ethtool_ops)
190 return;
191
192 /* getting RX checksum */
193 if (dev->ethtool_ops->get_rx_csum)
194 if (dev->ethtool_ops->get_rx_csum(dev))
195 features[0].active |= NETIF_F_RXCSUM;
196
197 /* mark legacy-changeable features */
198 if (dev->ethtool_ops->set_sg)
199 features[0].available |= NETIF_F_SG;
200 if (dev->ethtool_ops->set_tx_csum)
201 features[0].available |= NETIF_F_ALL_CSUM;
202 if (dev->ethtool_ops->set_tso)
203 features[0].available |= NETIF_F_ALL_TSO;
204 if (dev->ethtool_ops->set_rx_csum)
205 features[0].available |= NETIF_F_RXCSUM;
206 if (dev->ethtool_ops->set_flags)
207 features[0].available |= flags_dup_features;
208}
209
210static int ethtool_set_feature_compat(struct net_device *dev,
211 int (*legacy_set)(struct net_device *, u32),
212 struct ethtool_set_features_block *features, u32 mask)
213{
214 u32 do_set;
215
216 if (!legacy_set)
217 return 0;
218
219 if (!(features[0].valid & mask))
220 return 0;
221
222 features[0].valid &= ~mask;
223
224 do_set = !!(features[0].requested & mask);
225
226 if (legacy_set(dev, do_set) < 0)
227 netdev_info(dev,
228 "Legacy feature change (%s) failed for 0x%08x\n",
229 do_set ? "set" : "clear", mask);
230
231 return 1;
232}
233
234static int ethtool_set_features_compat(struct net_device *dev,
235 struct ethtool_set_features_block *features)
236{
237 int compat;
238
239 if (!dev->ethtool_ops)
240 return 0;
241
242 compat = ethtool_set_feature_compat(dev, dev->ethtool_ops->set_sg,
243 features, NETIF_F_SG);
244 compat |= ethtool_set_feature_compat(dev, dev->ethtool_ops->set_tx_csum,
245 features, NETIF_F_ALL_CSUM);
246 compat |= ethtool_set_feature_compat(dev, dev->ethtool_ops->set_tso,
247 features, NETIF_F_ALL_TSO);
248 compat |= ethtool_set_feature_compat(dev, dev->ethtool_ops->set_rx_csum,
249 features, NETIF_F_RXCSUM);
250 compat |= ethtool_set_feature_compat(dev, dev->ethtool_ops->set_flags,
251 features, flags_dup_features);
252
253 return compat;
254}
255
256static int ethtool_get_features(struct net_device *dev, void __user *useraddr)
257{
258 struct ethtool_gfeatures cmd = {
259 .cmd = ETHTOOL_GFEATURES,
260 .size = ETHTOOL_DEV_FEATURE_WORDS,
261 };
262 struct ethtool_get_features_block features[ETHTOOL_DEV_FEATURE_WORDS] = {
263 {
264 .available = dev->hw_features,
265 .requested = dev->wanted_features,
266 .active = dev->features,
267 .never_changed = NETIF_F_NEVER_CHANGE,
268 },
269 };
270 u32 __user *sizeaddr;
271 u32 copy_size;
272
273 ethtool_get_features_compat(dev, features);
274
275 sizeaddr = useraddr + offsetof(struct ethtool_gfeatures, size);
276 if (get_user(copy_size, sizeaddr))
277 return -EFAULT;
278
279 if (copy_size > ETHTOOL_DEV_FEATURE_WORDS)
280 copy_size = ETHTOOL_DEV_FEATURE_WORDS;
281
282 if (copy_to_user(useraddr, &cmd, sizeof(cmd)))
283 return -EFAULT;
284 useraddr += sizeof(cmd);
285 if (copy_to_user(useraddr, features, copy_size * sizeof(*features)))
286 return -EFAULT;
287
288 return 0;
289}
290
291static int ethtool_set_features(struct net_device *dev, void __user *useraddr)
292{
293 struct ethtool_sfeatures cmd;
294 struct ethtool_set_features_block features[ETHTOOL_DEV_FEATURE_WORDS];
295 int ret = 0;
296
297 if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
298 return -EFAULT;
299 useraddr += sizeof(cmd);
300
301 if (cmd.size != ETHTOOL_DEV_FEATURE_WORDS)
302 return -EINVAL;
303
304 if (copy_from_user(features, useraddr, sizeof(features)))
305 return -EFAULT;
306
307 if (features[0].valid & ~NETIF_F_ETHTOOL_BITS)
308 return -EINVAL;
309
310 if (ethtool_set_features_compat(dev, features))
311 ret |= ETHTOOL_F_COMPAT;
312
313 if (features[0].valid & ~dev->hw_features) {
314 features[0].valid &= dev->hw_features;
315 ret |= ETHTOOL_F_UNSUPPORTED;
316 }
317
318 dev->wanted_features &= ~features[0].valid;
319 dev->wanted_features |= features[0].valid & features[0].requested;
320 netdev_update_features(dev);
321
322 if ((dev->wanted_features ^ dev->features) & features[0].valid)
323 ret |= ETHTOOL_F_WISH;
324
325 return ret;
326}
327
328static const char netdev_features_strings[ETHTOOL_DEV_FEATURE_WORDS * 32][ETH_GSTRING_LEN] = {
329 /* NETIF_F_SG */ "tx-scatter-gather",
330 /* NETIF_F_IP_CSUM */ "tx-checksum-ipv4",
331 /* NETIF_F_NO_CSUM */ "tx-checksum-unneeded",
332 /* NETIF_F_HW_CSUM */ "tx-checksum-ip-generic",
333 /* NETIF_F_IPV6_CSUM */ "tx_checksum-ipv6",
334 /* NETIF_F_HIGHDMA */ "highdma",
335 /* NETIF_F_FRAGLIST */ "tx-scatter-gather-fraglist",
336 /* NETIF_F_HW_VLAN_TX */ "tx-vlan-hw-insert",
337
338 /* NETIF_F_HW_VLAN_RX */ "rx-vlan-hw-parse",
339 /* NETIF_F_HW_VLAN_FILTER */ "rx-vlan-filter",
340 /* NETIF_F_VLAN_CHALLENGED */ "vlan-challenged",
341 /* NETIF_F_GSO */ "tx-generic-segmentation",
342 /* NETIF_F_LLTX */ "tx-lockless",
343 /* NETIF_F_NETNS_LOCAL */ "netns-local",
344 /* NETIF_F_GRO */ "rx-gro",
345 /* NETIF_F_LRO */ "rx-lro",
346
347 /* NETIF_F_TSO */ "tx-tcp-segmentation",
348 /* NETIF_F_UFO */ "tx-udp-fragmentation",
349 /* NETIF_F_GSO_ROBUST */ "tx-gso-robust",
350 /* NETIF_F_TSO_ECN */ "tx-tcp-ecn-segmentation",
351 /* NETIF_F_TSO6 */ "tx-tcp6-segmentation",
352 /* NETIF_F_FSO */ "tx-fcoe-segmentation",
353 "",
354 "",
355
356 /* NETIF_F_FCOE_CRC */ "tx-checksum-fcoe-crc",
357 /* NETIF_F_SCTP_CSUM */ "tx-checksum-sctp",
358 /* NETIF_F_FCOE_MTU */ "fcoe-mtu",
359 /* NETIF_F_NTUPLE */ "rx-ntuple-filter",
360 /* NETIF_F_RXHASH */ "rx-hashing",
361 /* NETIF_F_RXCSUM */ "rx-checksum",
362 "",
363 "",
364};
365
366static int __ethtool_get_sset_count(struct net_device *dev, int sset)
367{
368 const struct ethtool_ops *ops = dev->ethtool_ops;
369
370 if (sset == ETH_SS_FEATURES)
371 return ARRAY_SIZE(netdev_features_strings);
372
373 if (ops && ops->get_sset_count && ops->get_strings)
374 return ops->get_sset_count(dev, sset);
375 else
376 return -EOPNOTSUPP;
377}
378
379static void __ethtool_get_strings(struct net_device *dev,
380 u32 stringset, u8 *data)
381{
382 const struct ethtool_ops *ops = dev->ethtool_ops;
383
384 if (stringset == ETH_SS_FEATURES)
385 memcpy(data, netdev_features_strings,
386 sizeof(netdev_features_strings));
387 else
388 /* ops->get_strings is valid because checked earlier */
389 ops->get_strings(dev, stringset, data);
390}
391
392static u32 ethtool_get_feature_mask(u32 eth_cmd)
393{
394 /* feature masks of legacy discrete ethtool ops */
395
396 switch (eth_cmd) {
397 case ETHTOOL_GTXCSUM:
398 case ETHTOOL_STXCSUM:
399 return NETIF_F_ALL_CSUM | NETIF_F_SCTP_CSUM;
400 case ETHTOOL_GRXCSUM:
401 case ETHTOOL_SRXCSUM:
402 return NETIF_F_RXCSUM;
403 case ETHTOOL_GSG:
404 case ETHTOOL_SSG:
405 return NETIF_F_SG;
406 case ETHTOOL_GTSO:
407 case ETHTOOL_STSO:
408 return NETIF_F_ALL_TSO;
409 case ETHTOOL_GUFO:
410 case ETHTOOL_SUFO:
411 return NETIF_F_UFO;
412 case ETHTOOL_GGSO:
413 case ETHTOOL_SGSO:
414 return NETIF_F_GSO;
415 case ETHTOOL_GGRO:
416 case ETHTOOL_SGRO:
417 return NETIF_F_GRO;
418 default:
419 BUG();
420 }
421}
422
423static void *__ethtool_get_one_feature_actor(struct net_device *dev, u32 ethcmd)
424{
425 const struct ethtool_ops *ops = dev->ethtool_ops;
426
427 if (!ops)
428 return NULL;
429
430 switch (ethcmd) {
431 case ETHTOOL_GTXCSUM:
432 return ops->get_tx_csum;
433 case ETHTOOL_GRXCSUM:
434 return ops->get_rx_csum;
435 case ETHTOOL_SSG:
436 return ops->get_sg;
437 case ETHTOOL_STSO:
438 return ops->get_tso;
439 case ETHTOOL_SUFO:
440 return ops->get_ufo;
441 default:
442 return NULL;
443 }
444}
445
446static u32 __ethtool_get_rx_csum_oldbug(struct net_device *dev)
447{
448 return !!(dev->features & NETIF_F_ALL_CSUM);
449}
450
451static int ethtool_get_one_feature(struct net_device *dev,
452 char __user *useraddr, u32 ethcmd)
453{
454 u32 mask = ethtool_get_feature_mask(ethcmd);
455 struct ethtool_value edata = {
456 .cmd = ethcmd,
457 .data = !!(dev->features & mask),
458 };
459
460 /* compatibility with discrete get_ ops */
461 if (!(dev->hw_features & mask)) {
462 u32 (*actor)(struct net_device *);
463
464 actor = __ethtool_get_one_feature_actor(dev, ethcmd);
465
466 /* bug compatibility with old get_rx_csum */
467 if (ethcmd == ETHTOOL_GRXCSUM && !actor)
468 actor = __ethtool_get_rx_csum_oldbug;
469
470 if (actor)
471 edata.data = actor(dev);
472 }
473
474 if (copy_to_user(useraddr, &edata, sizeof(edata)))
475 return -EFAULT;
476 return 0;
477}
478
479static int __ethtool_set_tx_csum(struct net_device *dev, u32 data);
480static int __ethtool_set_rx_csum(struct net_device *dev, u32 data);
481static int __ethtool_set_sg(struct net_device *dev, u32 data);
482static int __ethtool_set_tso(struct net_device *dev, u32 data);
483static int __ethtool_set_ufo(struct net_device *dev, u32 data);
484
485static int ethtool_set_one_feature(struct net_device *dev,
486 void __user *useraddr, u32 ethcmd)
487{
488 struct ethtool_value edata;
489 u32 mask;
490
491 if (copy_from_user(&edata, useraddr, sizeof(edata)))
492 return -EFAULT;
493
494 mask = ethtool_get_feature_mask(ethcmd);
495 mask &= dev->hw_features;
496 if (mask) {
497 if (edata.data)
498 dev->wanted_features |= mask;
499 else
500 dev->wanted_features &= ~mask;
501
502 netdev_update_features(dev);
503 return 0;
504 }
505
506 /* Driver is not converted to ndo_fix_features or does not
507 * support changing this offload. In the latter case it won't
508 * have corresponding ethtool_ops field set.
509 *
510 * Following part is to be removed after all drivers advertise
511 * their changeable features in netdev->hw_features and stop
512 * using discrete offload setting ops.
513 */
514
515 switch (ethcmd) {
516 case ETHTOOL_STXCSUM:
517 return __ethtool_set_tx_csum(dev, edata.data);
518 case ETHTOOL_SRXCSUM:
519 return __ethtool_set_rx_csum(dev, edata.data);
520 case ETHTOOL_SSG:
521 return __ethtool_set_sg(dev, edata.data);
522 case ETHTOOL_STSO:
523 return __ethtool_set_tso(dev, edata.data);
524 case ETHTOOL_SUFO:
525 return __ethtool_set_ufo(dev, edata.data);
526 default:
527 return -EOPNOTSUPP;
528 }
529}
530
531int __ethtool_set_flags(struct net_device *dev, u32 data)
532{
533 u32 changed;
534
535 if (data & ~flags_dup_features)
536 return -EINVAL;
537
538 /* legacy set_flags() op */
539 if (dev->ethtool_ops->set_flags) {
540 if (unlikely(dev->hw_features & flags_dup_features))
541 netdev_warn(dev,
542 "driver BUG: mixed hw_features and set_flags()\n");
543 return dev->ethtool_ops->set_flags(dev, data);
544 }
545
546 /* allow changing only bits set in hw_features */
547 changed = (data ^ dev->wanted_features) & flags_dup_features;
548 if (changed & ~dev->hw_features)
549 return (changed & dev->hw_features) ? -EINVAL : -EOPNOTSUPP;
550
551 dev->wanted_features =
552 (dev->wanted_features & ~changed) | data;
553
554 netdev_update_features(dev);
555
556 return 0;
557}
558
174static int ethtool_get_settings(struct net_device *dev, void __user *useraddr) 559static int ethtool_get_settings(struct net_device *dev, void __user *useraddr)
175{ 560{
176 struct ethtool_cmd cmd = { .cmd = ETHTOOL_GSET }; 561 struct ethtool_cmd cmd = { .cmd = ETHTOOL_GSET };
@@ -251,14 +636,10 @@ static noinline_for_stack int ethtool_get_sset_info(struct net_device *dev,
251 void __user *useraddr) 636 void __user *useraddr)
252{ 637{
253 struct ethtool_sset_info info; 638 struct ethtool_sset_info info;
254 const struct ethtool_ops *ops = dev->ethtool_ops;
255 u64 sset_mask; 639 u64 sset_mask;
256 int i, idx = 0, n_bits = 0, ret, rc; 640 int i, idx = 0, n_bits = 0, ret, rc;
257 u32 *info_buf = NULL; 641 u32 *info_buf = NULL;
258 642
259 if (!ops->get_sset_count)
260 return -EOPNOTSUPP;
261
262 if (copy_from_user(&info, useraddr, sizeof(info))) 643 if (copy_from_user(&info, useraddr, sizeof(info)))
263 return -EFAULT; 644 return -EFAULT;
264 645
@@ -285,7 +666,7 @@ static noinline_for_stack int ethtool_get_sset_info(struct net_device *dev,
285 if (!(sset_mask & (1ULL << i))) 666 if (!(sset_mask & (1ULL << i)))
286 continue; 667 continue;
287 668
288 rc = ops->get_sset_count(dev, i); 669 rc = __ethtool_get_sset_count(dev, i);
289 if (rc >= 0) { 670 if (rc >= 0) {
290 info.sset_mask |= (1ULL << i); 671 info.sset_mask |= (1ULL << i);
291 info_buf[idx++] = rc; 672 info_buf[idx++] = rc;
@@ -1091,6 +1472,12 @@ static int __ethtool_set_sg(struct net_device *dev, u32 data)
1091{ 1472{
1092 int err; 1473 int err;
1093 1474
1475 if (!dev->ethtool_ops->set_sg)
1476 return -EOPNOTSUPP;
1477
1478 if (data && !(dev->features & NETIF_F_ALL_CSUM))
1479 return -EINVAL;
1480
1094 if (!data && dev->ethtool_ops->set_tso) { 1481 if (!data && dev->ethtool_ops->set_tso) {
1095 err = dev->ethtool_ops->set_tso(dev, 0); 1482 err = dev->ethtool_ops->set_tso(dev, 0);
1096 if (err) 1483 if (err)
@@ -1105,145 +1492,55 @@ static int __ethtool_set_sg(struct net_device *dev, u32 data)
1105 return dev->ethtool_ops->set_sg(dev, data); 1492 return dev->ethtool_ops->set_sg(dev, data);
1106} 1493}
1107 1494
1108static int ethtool_set_tx_csum(struct net_device *dev, char __user *useraddr) 1495static int __ethtool_set_tx_csum(struct net_device *dev, u32 data)
1109{ 1496{
1110 struct ethtool_value edata;
1111 int err; 1497 int err;
1112 1498
1113 if (!dev->ethtool_ops->set_tx_csum) 1499 if (!dev->ethtool_ops->set_tx_csum)
1114 return -EOPNOTSUPP; 1500 return -EOPNOTSUPP;
1115 1501
1116 if (copy_from_user(&edata, useraddr, sizeof(edata))) 1502 if (!data && dev->ethtool_ops->set_sg) {
1117 return -EFAULT;
1118
1119 if (!edata.data && dev->ethtool_ops->set_sg) {
1120 err = __ethtool_set_sg(dev, 0); 1503 err = __ethtool_set_sg(dev, 0);
1121 if (err) 1504 if (err)
1122 return err; 1505 return err;
1123 } 1506 }
1124 1507
1125 return dev->ethtool_ops->set_tx_csum(dev, edata.data); 1508 return dev->ethtool_ops->set_tx_csum(dev, data);
1126} 1509}
1127EXPORT_SYMBOL(ethtool_op_set_tx_csum);
1128 1510
1129static int ethtool_set_rx_csum(struct net_device *dev, char __user *useraddr) 1511static int __ethtool_set_rx_csum(struct net_device *dev, u32 data)
1130{ 1512{
1131 struct ethtool_value edata;
1132
1133 if (!dev->ethtool_ops->set_rx_csum) 1513 if (!dev->ethtool_ops->set_rx_csum)
1134 return -EOPNOTSUPP; 1514 return -EOPNOTSUPP;
1135 1515
1136 if (copy_from_user(&edata, useraddr, sizeof(edata))) 1516 if (!data)
1137 return -EFAULT;
1138
1139 if (!edata.data && dev->ethtool_ops->set_sg)
1140 dev->features &= ~NETIF_F_GRO; 1517 dev->features &= ~NETIF_F_GRO;
1141 1518
1142 return dev->ethtool_ops->set_rx_csum(dev, edata.data); 1519 return dev->ethtool_ops->set_rx_csum(dev, data);
1143} 1520}
1144 1521
1145static int ethtool_set_sg(struct net_device *dev, char __user *useraddr) 1522static int __ethtool_set_tso(struct net_device *dev, u32 data)
1146{ 1523{
1147 struct ethtool_value edata;
1148
1149 if (!dev->ethtool_ops->set_sg)
1150 return -EOPNOTSUPP;
1151
1152 if (copy_from_user(&edata, useraddr, sizeof(edata)))
1153 return -EFAULT;
1154
1155 if (edata.data &&
1156 !(dev->features & NETIF_F_ALL_CSUM))
1157 return -EINVAL;
1158
1159 return __ethtool_set_sg(dev, edata.data);
1160}
1161
1162static int ethtool_set_tso(struct net_device *dev, char __user *useraddr)
1163{
1164 struct ethtool_value edata;
1165
1166 if (!dev->ethtool_ops->set_tso) 1524 if (!dev->ethtool_ops->set_tso)
1167 return -EOPNOTSUPP; 1525 return -EOPNOTSUPP;
1168 1526
1169 if (copy_from_user(&edata, useraddr, sizeof(edata))) 1527 if (data && !(dev->features & NETIF_F_SG))
1170 return -EFAULT;
1171
1172 if (edata.data && !(dev->features & NETIF_F_SG))
1173 return -EINVAL; 1528 return -EINVAL;
1174 1529
1175 return dev->ethtool_ops->set_tso(dev, edata.data); 1530 return dev->ethtool_ops->set_tso(dev, data);
1176} 1531}
1177 1532
1178static int ethtool_set_ufo(struct net_device *dev, char __user *useraddr) 1533static int __ethtool_set_ufo(struct net_device *dev, u32 data)
1179{ 1534{
1180 struct ethtool_value edata;
1181
1182 if (!dev->ethtool_ops->set_ufo) 1535 if (!dev->ethtool_ops->set_ufo)
1183 return -EOPNOTSUPP; 1536 return -EOPNOTSUPP;
1184 if (copy_from_user(&edata, useraddr, sizeof(edata))) 1537 if (data && !(dev->features & NETIF_F_SG))
1185 return -EFAULT;
1186 if (edata.data && !(dev->features & NETIF_F_SG))
1187 return -EINVAL; 1538 return -EINVAL;
1188 if (edata.data && !((dev->features & NETIF_F_GEN_CSUM) || 1539 if (data && !((dev->features & NETIF_F_GEN_CSUM) ||
1189 (dev->features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM)) 1540 (dev->features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))
1190 == (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) 1541 == (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM)))
1191 return -EINVAL; 1542 return -EINVAL;
1192 return dev->ethtool_ops->set_ufo(dev, edata.data); 1543 return dev->ethtool_ops->set_ufo(dev, data);
1193}
1194
1195static int ethtool_get_gso(struct net_device *dev, char __user *useraddr)
1196{
1197 struct ethtool_value edata = { ETHTOOL_GGSO };
1198
1199 edata.data = dev->features & NETIF_F_GSO;
1200 if (copy_to_user(useraddr, &edata, sizeof(edata)))
1201 return -EFAULT;
1202 return 0;
1203}
1204
1205static int ethtool_set_gso(struct net_device *dev, char __user *useraddr)
1206{
1207 struct ethtool_value edata;
1208
1209 if (copy_from_user(&edata, useraddr, sizeof(edata)))
1210 return -EFAULT;
1211 if (edata.data)
1212 dev->features |= NETIF_F_GSO;
1213 else
1214 dev->features &= ~NETIF_F_GSO;
1215 return 0;
1216}
1217
1218static int ethtool_get_gro(struct net_device *dev, char __user *useraddr)
1219{
1220 struct ethtool_value edata = { ETHTOOL_GGRO };
1221
1222 edata.data = dev->features & NETIF_F_GRO;
1223 if (copy_to_user(useraddr, &edata, sizeof(edata)))
1224 return -EFAULT;
1225 return 0;
1226}
1227
1228static int ethtool_set_gro(struct net_device *dev, char __user *useraddr)
1229{
1230 struct ethtool_value edata;
1231
1232 if (copy_from_user(&edata, useraddr, sizeof(edata)))
1233 return -EFAULT;
1234
1235 if (edata.data) {
1236 u32 rxcsum = dev->ethtool_ops->get_rx_csum ?
1237 dev->ethtool_ops->get_rx_csum(dev) :
1238 ethtool_op_get_rx_csum(dev);
1239
1240 if (!rxcsum)
1241 return -EINVAL;
1242 dev->features |= NETIF_F_GRO;
1243 } else
1244 dev->features &= ~NETIF_F_GRO;
1245
1246 return 0;
1247} 1544}
1248 1545
1249static int ethtool_self_test(struct net_device *dev, char __user *useraddr) 1546static int ethtool_self_test(struct net_device *dev, char __user *useraddr)
@@ -1287,17 +1584,13 @@ static int ethtool_self_test(struct net_device *dev, char __user *useraddr)
1287static int ethtool_get_strings(struct net_device *dev, void __user *useraddr) 1584static int ethtool_get_strings(struct net_device *dev, void __user *useraddr)
1288{ 1585{
1289 struct ethtool_gstrings gstrings; 1586 struct ethtool_gstrings gstrings;
1290 const struct ethtool_ops *ops = dev->ethtool_ops;
1291 u8 *data; 1587 u8 *data;
1292 int ret; 1588 int ret;
1293 1589
1294 if (!ops->get_strings || !ops->get_sset_count)
1295 return -EOPNOTSUPP;
1296
1297 if (copy_from_user(&gstrings, useraddr, sizeof(gstrings))) 1590 if (copy_from_user(&gstrings, useraddr, sizeof(gstrings)))
1298 return -EFAULT; 1591 return -EFAULT;
1299 1592
1300 ret = ops->get_sset_count(dev, gstrings.string_set); 1593 ret = __ethtool_get_sset_count(dev, gstrings.string_set);
1301 if (ret < 0) 1594 if (ret < 0)
1302 return ret; 1595 return ret;
1303 1596
@@ -1307,7 +1600,7 @@ static int ethtool_get_strings(struct net_device *dev, void __user *useraddr)
1307 if (!data) 1600 if (!data)
1308 return -ENOMEM; 1601 return -ENOMEM;
1309 1602
1310 ops->get_strings(dev, gstrings.string_set, data); 1603 __ethtool_get_strings(dev, gstrings.string_set, data);
1311 1604
1312 ret = -EFAULT; 1605 ret = -EFAULT;
1313 if (copy_to_user(useraddr, &gstrings, sizeof(gstrings))) 1606 if (copy_to_user(useraddr, &gstrings, sizeof(gstrings)))
@@ -1317,7 +1610,7 @@ static int ethtool_get_strings(struct net_device *dev, void __user *useraddr)
1317 goto out; 1610 goto out;
1318 ret = 0; 1611 ret = 0;
1319 1612
1320 out: 1613out:
1321 kfree(data); 1614 kfree(data);
1322 return ret; 1615 return ret;
1323} 1616}
@@ -1458,7 +1751,7 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
1458 void __user *useraddr = ifr->ifr_data; 1751 void __user *useraddr = ifr->ifr_data;
1459 u32 ethcmd; 1752 u32 ethcmd;
1460 int rc; 1753 int rc;
1461 unsigned long old_features; 1754 u32 old_features;
1462 1755
1463 if (!dev || !netif_device_present(dev)) 1756 if (!dev || !netif_device_present(dev))
1464 return -ENODEV; 1757 return -ENODEV;
@@ -1500,6 +1793,7 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
1500 case ETHTOOL_GRXCLSRLCNT: 1793 case ETHTOOL_GRXCLSRLCNT:
1501 case ETHTOOL_GRXCLSRULE: 1794 case ETHTOOL_GRXCLSRULE:
1502 case ETHTOOL_GRXCLSRLALL: 1795 case ETHTOOL_GRXCLSRLALL:
1796 case ETHTOOL_GFEATURES:
1503 break; 1797 break;
1504 default: 1798 default:
1505 if (!capable(CAP_NET_ADMIN)) 1799 if (!capable(CAP_NET_ADMIN))
@@ -1570,42 +1864,6 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
1570 case ETHTOOL_SPAUSEPARAM: 1864 case ETHTOOL_SPAUSEPARAM:
1571 rc = ethtool_set_pauseparam(dev, useraddr); 1865 rc = ethtool_set_pauseparam(dev, useraddr);
1572 break; 1866 break;
1573 case ETHTOOL_GRXCSUM:
1574 rc = ethtool_get_value(dev, useraddr, ethcmd,
1575 (dev->ethtool_ops->get_rx_csum ?
1576 dev->ethtool_ops->get_rx_csum :
1577 ethtool_op_get_rx_csum));
1578 break;
1579 case ETHTOOL_SRXCSUM:
1580 rc = ethtool_set_rx_csum(dev, useraddr);
1581 break;
1582 case ETHTOOL_GTXCSUM:
1583 rc = ethtool_get_value(dev, useraddr, ethcmd,
1584 (dev->ethtool_ops->get_tx_csum ?
1585 dev->ethtool_ops->get_tx_csum :
1586 ethtool_op_get_tx_csum));
1587 break;
1588 case ETHTOOL_STXCSUM:
1589 rc = ethtool_set_tx_csum(dev, useraddr);
1590 break;
1591 case ETHTOOL_GSG:
1592 rc = ethtool_get_value(dev, useraddr, ethcmd,
1593 (dev->ethtool_ops->get_sg ?
1594 dev->ethtool_ops->get_sg :
1595 ethtool_op_get_sg));
1596 break;
1597 case ETHTOOL_SSG:
1598 rc = ethtool_set_sg(dev, useraddr);
1599 break;
1600 case ETHTOOL_GTSO:
1601 rc = ethtool_get_value(dev, useraddr, ethcmd,
1602 (dev->ethtool_ops->get_tso ?
1603 dev->ethtool_ops->get_tso :
1604 ethtool_op_get_tso));
1605 break;
1606 case ETHTOOL_STSO:
1607 rc = ethtool_set_tso(dev, useraddr);
1608 break;
1609 case ETHTOOL_TEST: 1867 case ETHTOOL_TEST:
1610 rc = ethtool_self_test(dev, useraddr); 1868 rc = ethtool_self_test(dev, useraddr);
1611 break; 1869 break;
@@ -1621,21 +1879,6 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
1621 case ETHTOOL_GPERMADDR: 1879 case ETHTOOL_GPERMADDR:
1622 rc = ethtool_get_perm_addr(dev, useraddr); 1880 rc = ethtool_get_perm_addr(dev, useraddr);
1623 break; 1881 break;
1624 case ETHTOOL_GUFO:
1625 rc = ethtool_get_value(dev, useraddr, ethcmd,
1626 (dev->ethtool_ops->get_ufo ?
1627 dev->ethtool_ops->get_ufo :
1628 ethtool_op_get_ufo));
1629 break;
1630 case ETHTOOL_SUFO:
1631 rc = ethtool_set_ufo(dev, useraddr);
1632 break;
1633 case ETHTOOL_GGSO:
1634 rc = ethtool_get_gso(dev, useraddr);
1635 break;
1636 case ETHTOOL_SGSO:
1637 rc = ethtool_set_gso(dev, useraddr);
1638 break;
1639 case ETHTOOL_GFLAGS: 1882 case ETHTOOL_GFLAGS:
1640 rc = ethtool_get_value(dev, useraddr, ethcmd, 1883 rc = ethtool_get_value(dev, useraddr, ethcmd,
1641 (dev->ethtool_ops->get_flags ? 1884 (dev->ethtool_ops->get_flags ?
@@ -1643,8 +1886,7 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
1643 ethtool_op_get_flags)); 1886 ethtool_op_get_flags));
1644 break; 1887 break;
1645 case ETHTOOL_SFLAGS: 1888 case ETHTOOL_SFLAGS:
1646 rc = ethtool_set_value(dev, useraddr, 1889 rc = ethtool_set_value(dev, useraddr, __ethtool_set_flags);
1647 dev->ethtool_ops->set_flags);
1648 break; 1890 break;
1649 case ETHTOOL_GPFLAGS: 1891 case ETHTOOL_GPFLAGS:
1650 rc = ethtool_get_value(dev, useraddr, ethcmd, 1892 rc = ethtool_get_value(dev, useraddr, ethcmd,
@@ -1666,12 +1908,6 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
1666 case ETHTOOL_SRXCLSRLINS: 1908 case ETHTOOL_SRXCLSRLINS:
1667 rc = ethtool_set_rxnfc(dev, ethcmd, useraddr); 1909 rc = ethtool_set_rxnfc(dev, ethcmd, useraddr);
1668 break; 1910 break;
1669 case ETHTOOL_GGRO:
1670 rc = ethtool_get_gro(dev, useraddr);
1671 break;
1672 case ETHTOOL_SGRO:
1673 rc = ethtool_set_gro(dev, useraddr);
1674 break;
1675 case ETHTOOL_FLASHDEV: 1911 case ETHTOOL_FLASHDEV:
1676 rc = ethtool_flash_device(dev, useraddr); 1912 rc = ethtool_flash_device(dev, useraddr);
1677 break; 1913 break;
@@ -1693,6 +1929,30 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
1693 case ETHTOOL_SRXFHINDIR: 1929 case ETHTOOL_SRXFHINDIR:
1694 rc = ethtool_set_rxfh_indir(dev, useraddr); 1930 rc = ethtool_set_rxfh_indir(dev, useraddr);
1695 break; 1931 break;
1932 case ETHTOOL_GFEATURES:
1933 rc = ethtool_get_features(dev, useraddr);
1934 break;
1935 case ETHTOOL_SFEATURES:
1936 rc = ethtool_set_features(dev, useraddr);
1937 break;
1938 case ETHTOOL_GTXCSUM:
1939 case ETHTOOL_GRXCSUM:
1940 case ETHTOOL_GSG:
1941 case ETHTOOL_GTSO:
1942 case ETHTOOL_GUFO:
1943 case ETHTOOL_GGSO:
1944 case ETHTOOL_GGRO:
1945 rc = ethtool_get_one_feature(dev, useraddr, ethcmd);
1946 break;
1947 case ETHTOOL_STXCSUM:
1948 case ETHTOOL_SRXCSUM:
1949 case ETHTOOL_SSG:
1950 case ETHTOOL_STSO:
1951 case ETHTOOL_SUFO:
1952 case ETHTOOL_SGSO:
1953 case ETHTOOL_SGRO:
1954 rc = ethtool_set_one_feature(dev, useraddr, ethcmd);
1955 break;
1696 default: 1956 default:
1697 rc = -EOPNOTSUPP; 1957 rc = -EOPNOTSUPP;
1698 } 1958 }
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index a20e5d3bbfa0..8248ebb5891d 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -181,13 +181,13 @@ static int fib_rule_match(struct fib_rule *rule, struct fib_rules_ops *ops,
181{ 181{
182 int ret = 0; 182 int ret = 0;
183 183
184 if (rule->iifindex && (rule->iifindex != fl->iif)) 184 if (rule->iifindex && (rule->iifindex != fl->flowi_iif))
185 goto out; 185 goto out;
186 186
187 if (rule->oifindex && (rule->oifindex != fl->oif)) 187 if (rule->oifindex && (rule->oifindex != fl->flowi_oif))
188 goto out; 188 goto out;
189 189
190 if ((rule->mark ^ fl->mark) & rule->mark_mask) 190 if ((rule->mark ^ fl->flowi_mark) & rule->mark_mask)
191 goto out; 191 goto out;
192 192
193 ret = ops->match(rule, fl, flags); 193 ret = ops->match(rule, fl, flags);
diff --git a/net/core/filter.c b/net/core/filter.c
index afc58374ca96..afb8afb066bb 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -142,14 +142,14 @@ int sk_filter(struct sock *sk, struct sk_buff *skb)
142 if (err) 142 if (err)
143 return err; 143 return err;
144 144
145 rcu_read_lock_bh(); 145 rcu_read_lock();
146 filter = rcu_dereference_bh(sk->sk_filter); 146 filter = rcu_dereference(sk->sk_filter);
147 if (filter) { 147 if (filter) {
148 unsigned int pkt_len = sk_run_filter(skb, filter->insns); 148 unsigned int pkt_len = sk_run_filter(skb, filter->insns);
149 149
150 err = pkt_len ? pskb_trim(skb, pkt_len) : -EPERM; 150 err = pkt_len ? pskb_trim(skb, pkt_len) : -EPERM;
151 } 151 }
152 rcu_read_unlock_bh(); 152 rcu_read_unlock();
153 153
154 return err; 154 return err;
155} 155}
@@ -425,7 +425,7 @@ EXPORT_SYMBOL(sk_run_filter);
425 * As we dont want to clear mem[] array for each packet going through 425 * As we dont want to clear mem[] array for each packet going through
426 * sk_run_filter(), we check that filter loaded by user never try to read 426 * sk_run_filter(), we check that filter loaded by user never try to read
427 * a cell if not previously written, and we check all branches to be sure 427 * a cell if not previously written, and we check all branches to be sure
428 * a malicious user doesnt try to abuse us. 428 * a malicious user doesn't try to abuse us.
429 */ 429 */
430static int check_load_and_stores(struct sock_filter *filter, int flen) 430static int check_load_and_stores(struct sock_filter *filter, int flen)
431{ 431{
diff --git a/net/core/flow.c b/net/core/flow.c
index 127c8a7ffd61..990703b8863b 100644
--- a/net/core/flow.c
+++ b/net/core/flow.c
@@ -172,9 +172,9 @@ static void flow_new_hash_rnd(struct flow_cache *fc,
172 172
173static u32 flow_hash_code(struct flow_cache *fc, 173static u32 flow_hash_code(struct flow_cache *fc,
174 struct flow_cache_percpu *fcp, 174 struct flow_cache_percpu *fcp,
175 struct flowi *key) 175 const struct flowi *key)
176{ 176{
177 u32 *k = (u32 *) key; 177 const u32 *k = (const u32 *) key;
178 178
179 return jhash2(k, (sizeof(*key) / sizeof(u32)), fcp->hash_rnd) 179 return jhash2(k, (sizeof(*key) / sizeof(u32)), fcp->hash_rnd)
180 & (flow_cache_hash_size(fc) - 1); 180 & (flow_cache_hash_size(fc) - 1);
@@ -186,17 +186,17 @@ typedef unsigned long flow_compare_t;
186 * important assumptions that we can here, such as alignment and 186 * important assumptions that we can here, such as alignment and
187 * constant size. 187 * constant size.
188 */ 188 */
189static int flow_key_compare(struct flowi *key1, struct flowi *key2) 189static int flow_key_compare(const struct flowi *key1, const struct flowi *key2)
190{ 190{
191 flow_compare_t *k1, *k1_lim, *k2; 191 const flow_compare_t *k1, *k1_lim, *k2;
192 const int n_elem = sizeof(struct flowi) / sizeof(flow_compare_t); 192 const int n_elem = sizeof(struct flowi) / sizeof(flow_compare_t);
193 193
194 BUILD_BUG_ON(sizeof(struct flowi) % sizeof(flow_compare_t)); 194 BUILD_BUG_ON(sizeof(struct flowi) % sizeof(flow_compare_t));
195 195
196 k1 = (flow_compare_t *) key1; 196 k1 = (const flow_compare_t *) key1;
197 k1_lim = k1 + n_elem; 197 k1_lim = k1 + n_elem;
198 198
199 k2 = (flow_compare_t *) key2; 199 k2 = (const flow_compare_t *) key2;
200 200
201 do { 201 do {
202 if (*k1++ != *k2++) 202 if (*k1++ != *k2++)
@@ -207,7 +207,7 @@ static int flow_key_compare(struct flowi *key1, struct flowi *key2)
207} 207}
208 208
209struct flow_cache_object * 209struct flow_cache_object *
210flow_cache_lookup(struct net *net, struct flowi *key, u16 family, u8 dir, 210flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
211 flow_resolve_t resolver, void *ctx) 211 flow_resolve_t resolver, void *ctx)
212{ 212{
213 struct flow_cache *fc = &flow_cache_global; 213 struct flow_cache *fc = &flow_cache_global;
diff --git a/net/core/link_watch.c b/net/core/link_watch.c
index 01a1101b5936..a7b342131869 100644
--- a/net/core/link_watch.c
+++ b/net/core/link_watch.c
@@ -129,7 +129,7 @@ static void linkwatch_schedule_work(int urgent)
129 if (!cancel_delayed_work(&linkwatch_work)) 129 if (!cancel_delayed_work(&linkwatch_work))
130 return; 130 return;
131 131
132 /* Otherwise we reschedule it again for immediate exection. */ 132 /* Otherwise we reschedule it again for immediate execution. */
133 schedule_delayed_work(&linkwatch_work, 0); 133 schedule_delayed_work(&linkwatch_work, 0);
134} 134}
135 135
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 60a902913429..799f06e03a22 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -316,7 +316,7 @@ static struct neigh_hash_table *neigh_hash_alloc(unsigned int entries)
316{ 316{
317 size_t size = entries * sizeof(struct neighbour *); 317 size_t size = entries * sizeof(struct neighbour *);
318 struct neigh_hash_table *ret; 318 struct neigh_hash_table *ret;
319 struct neighbour **buckets; 319 struct neighbour __rcu **buckets;
320 320
321 ret = kmalloc(sizeof(*ret), GFP_ATOMIC); 321 ret = kmalloc(sizeof(*ret), GFP_ATOMIC);
322 if (!ret) 322 if (!ret)
@@ -324,14 +324,14 @@ static struct neigh_hash_table *neigh_hash_alloc(unsigned int entries)
324 if (size <= PAGE_SIZE) 324 if (size <= PAGE_SIZE)
325 buckets = kzalloc(size, GFP_ATOMIC); 325 buckets = kzalloc(size, GFP_ATOMIC);
326 else 326 else
327 buckets = (struct neighbour **) 327 buckets = (struct neighbour __rcu **)
328 __get_free_pages(GFP_ATOMIC | __GFP_ZERO, 328 __get_free_pages(GFP_ATOMIC | __GFP_ZERO,
329 get_order(size)); 329 get_order(size));
330 if (!buckets) { 330 if (!buckets) {
331 kfree(ret); 331 kfree(ret);
332 return NULL; 332 return NULL;
333 } 333 }
334 rcu_assign_pointer(ret->hash_buckets, buckets); 334 ret->hash_buckets = buckets;
335 ret->hash_mask = entries - 1; 335 ret->hash_mask = entries - 1;
336 get_random_bytes(&ret->hash_rnd, sizeof(ret->hash_rnd)); 336 get_random_bytes(&ret->hash_rnd, sizeof(ret->hash_rnd));
337 return ret; 337 return ret;
@@ -343,7 +343,7 @@ static void neigh_hash_free_rcu(struct rcu_head *head)
343 struct neigh_hash_table, 343 struct neigh_hash_table,
344 rcu); 344 rcu);
345 size_t size = (nht->hash_mask + 1) * sizeof(struct neighbour *); 345 size_t size = (nht->hash_mask + 1) * sizeof(struct neighbour *);
346 struct neighbour **buckets = nht->hash_buckets; 346 struct neighbour __rcu **buckets = nht->hash_buckets;
347 347
348 if (size <= PAGE_SIZE) 348 if (size <= PAGE_SIZE)
349 kfree(buckets); 349 kfree(buckets);
@@ -1540,7 +1540,7 @@ void neigh_table_init_no_netlink(struct neigh_table *tbl)
1540 panic("cannot create neighbour proc dir entry"); 1540 panic("cannot create neighbour proc dir entry");
1541#endif 1541#endif
1542 1542
1543 tbl->nht = neigh_hash_alloc(8); 1543 RCU_INIT_POINTER(tbl->nht, neigh_hash_alloc(8));
1544 1544
1545 phsize = (PNEIGH_HASHMASK + 1) * sizeof(struct pneigh_entry *); 1545 phsize = (PNEIGH_HASHMASK + 1) * sizeof(struct pneigh_entry *);
1546 tbl->phash_buckets = kzalloc(phsize, GFP_KERNEL); 1546 tbl->phash_buckets = kzalloc(phsize, GFP_KERNEL);
@@ -1602,7 +1602,8 @@ int neigh_table_clear(struct neigh_table *tbl)
1602 } 1602 }
1603 write_unlock(&neigh_tbl_lock); 1603 write_unlock(&neigh_tbl_lock);
1604 1604
1605 call_rcu(&tbl->nht->rcu, neigh_hash_free_rcu); 1605 call_rcu(&rcu_dereference_protected(tbl->nht, 1)->rcu,
1606 neigh_hash_free_rcu);
1606 tbl->nht = NULL; 1607 tbl->nht = NULL;
1607 1608
1608 kfree(tbl->phash_buckets); 1609 kfree(tbl->phash_buckets);
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index e23c01be5a5b..5ceb257e860c 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -99,7 +99,7 @@ NETDEVICE_SHOW(addr_assign_type, fmt_dec);
99NETDEVICE_SHOW(addr_len, fmt_dec); 99NETDEVICE_SHOW(addr_len, fmt_dec);
100NETDEVICE_SHOW(iflink, fmt_dec); 100NETDEVICE_SHOW(iflink, fmt_dec);
101NETDEVICE_SHOW(ifindex, fmt_dec); 101NETDEVICE_SHOW(ifindex, fmt_dec);
102NETDEVICE_SHOW(features, fmt_long_hex); 102NETDEVICE_SHOW(features, fmt_hex);
103NETDEVICE_SHOW(type, fmt_dec); 103NETDEVICE_SHOW(type, fmt_dec);
104NETDEVICE_SHOW(link_mode, fmt_dec); 104NETDEVICE_SHOW(link_mode, fmt_dec);
105 105
@@ -295,6 +295,20 @@ static ssize_t show_ifalias(struct device *dev,
295 return ret; 295 return ret;
296} 296}
297 297
298NETDEVICE_SHOW(group, fmt_dec);
299
300static int change_group(struct net_device *net, unsigned long new_group)
301{
302 dev_set_group(net, (int) new_group);
303 return 0;
304}
305
306static ssize_t store_group(struct device *dev, struct device_attribute *attr,
307 const char *buf, size_t len)
308{
309 return netdev_store(dev, attr, buf, len, change_group);
310}
311
298static struct device_attribute net_class_attributes[] = { 312static struct device_attribute net_class_attributes[] = {
299 __ATTR(addr_assign_type, S_IRUGO, show_addr_assign_type, NULL), 313 __ATTR(addr_assign_type, S_IRUGO, show_addr_assign_type, NULL),
300 __ATTR(addr_len, S_IRUGO, show_addr_len, NULL), 314 __ATTR(addr_len, S_IRUGO, show_addr_len, NULL),
@@ -316,6 +330,7 @@ static struct device_attribute net_class_attributes[] = {
316 __ATTR(flags, S_IRUGO | S_IWUSR, show_flags, store_flags), 330 __ATTR(flags, S_IRUGO | S_IWUSR, show_flags, store_flags),
317 __ATTR(tx_queue_len, S_IRUGO | S_IWUSR, show_tx_queue_len, 331 __ATTR(tx_queue_len, S_IRUGO | S_IWUSR, show_tx_queue_len,
318 store_tx_queue_len), 332 store_tx_queue_len),
333 __ATTR(netdev_group, S_IRUGO | S_IWUSR, show_group, store_group),
319 {} 334 {}
320}; 335};
321 336
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 02dc2cbcbe86..06be2431753e 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -193,6 +193,17 @@ void netpoll_poll_dev(struct net_device *dev)
193 193
194 poll_napi(dev); 194 poll_napi(dev);
195 195
196 if (dev->priv_flags & IFF_SLAVE) {
197 if (dev->npinfo) {
198 struct net_device *bond_dev = dev->master;
199 struct sk_buff *skb;
200 while ((skb = skb_dequeue(&dev->npinfo->arp_tx))) {
201 skb->dev = bond_dev;
202 skb_queue_tail(&bond_dev->npinfo->arp_tx, skb);
203 }
204 }
205 }
206
196 service_arp_queue(dev->npinfo); 207 service_arp_queue(dev->npinfo);
197 208
198 zap_completion_queue(); 209 zap_completion_queue();
@@ -313,9 +324,7 @@ void netpoll_send_skb_on_dev(struct netpoll *np, struct sk_buff *skb,
313 tries > 0; --tries) { 324 tries > 0; --tries) {
314 if (__netif_tx_trylock(txq)) { 325 if (__netif_tx_trylock(txq)) {
315 if (!netif_tx_queue_stopped(txq)) { 326 if (!netif_tx_queue_stopped(txq)) {
316 dev->priv_flags |= IFF_IN_NETPOLL;
317 status = ops->ndo_start_xmit(skb, dev); 327 status = ops->ndo_start_xmit(skb, dev);
318 dev->priv_flags &= ~IFF_IN_NETPOLL;
319 if (status == NETDEV_TX_OK) 328 if (status == NETDEV_TX_OK)
320 txq_trans_update(txq); 329 txq_trans_update(txq);
321 } 330 }
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index a9e7fc4c461f..aeeece72b72f 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -251,6 +251,7 @@ struct pktgen_dev {
251 int max_pkt_size; /* = ETH_ZLEN; */ 251 int max_pkt_size; /* = ETH_ZLEN; */
252 int pkt_overhead; /* overhead for MPLS, VLANs, IPSEC etc */ 252 int pkt_overhead; /* overhead for MPLS, VLANs, IPSEC etc */
253 int nfrags; 253 int nfrags;
254 struct page *page;
254 u64 delay; /* nano-seconds */ 255 u64 delay; /* nano-seconds */
255 256
256 __u64 count; /* Default No packets to send */ 257 __u64 count; /* Default No packets to send */
@@ -1134,6 +1135,10 @@ static ssize_t pktgen_if_write(struct file *file,
1134 if (node_possible(value)) { 1135 if (node_possible(value)) {
1135 pkt_dev->node = value; 1136 pkt_dev->node = value;
1136 sprintf(pg_result, "OK: node=%d", pkt_dev->node); 1137 sprintf(pg_result, "OK: node=%d", pkt_dev->node);
1138 if (pkt_dev->page) {
1139 put_page(pkt_dev->page);
1140 pkt_dev->page = NULL;
1141 }
1137 } 1142 }
1138 else 1143 else
1139 sprintf(pg_result, "ERROR: node not possible"); 1144 sprintf(pg_result, "ERROR: node not possible");
@@ -2605,6 +2610,89 @@ static inline __be16 build_tci(unsigned int id, unsigned int cfi,
2605 return htons(id | (cfi << 12) | (prio << 13)); 2610 return htons(id | (cfi << 12) | (prio << 13));
2606} 2611}
2607 2612
2613static void pktgen_finalize_skb(struct pktgen_dev *pkt_dev, struct sk_buff *skb,
2614 int datalen)
2615{
2616 struct timeval timestamp;
2617 struct pktgen_hdr *pgh;
2618
2619 pgh = (struct pktgen_hdr *)skb_put(skb, sizeof(*pgh));
2620 datalen -= sizeof(*pgh);
2621
2622 if (pkt_dev->nfrags <= 0) {
2623 memset(skb_put(skb, datalen), 0, datalen);
2624 } else {
2625 int frags = pkt_dev->nfrags;
2626 int i, len;
2627
2628
2629 if (frags > MAX_SKB_FRAGS)
2630 frags = MAX_SKB_FRAGS;
2631 len = datalen - frags * PAGE_SIZE;
2632 if (len > 0) {
2633 memset(skb_put(skb, len), 0, len);
2634 datalen = frags * PAGE_SIZE;
2635 }
2636
2637 i = 0;
2638 while (datalen > 0) {
2639 if (unlikely(!pkt_dev->page)) {
2640 int node = numa_node_id();
2641
2642 if (pkt_dev->node >= 0 && (pkt_dev->flags & F_NODE))
2643 node = pkt_dev->node;
2644 pkt_dev->page = alloc_pages_node(node, GFP_KERNEL | __GFP_ZERO, 0);
2645 if (!pkt_dev->page)
2646 break;
2647 }
2648 skb_shinfo(skb)->frags[i].page = pkt_dev->page;
2649 get_page(pkt_dev->page);
2650 skb_shinfo(skb)->frags[i].page_offset = 0;
2651 skb_shinfo(skb)->frags[i].size =
2652 (datalen < PAGE_SIZE ? datalen : PAGE_SIZE);
2653 datalen -= skb_shinfo(skb)->frags[i].size;
2654 skb->len += skb_shinfo(skb)->frags[i].size;
2655 skb->data_len += skb_shinfo(skb)->frags[i].size;
2656 i++;
2657 skb_shinfo(skb)->nr_frags = i;
2658 }
2659
2660 while (i < frags) {
2661 int rem;
2662
2663 if (i == 0)
2664 break;
2665
2666 rem = skb_shinfo(skb)->frags[i - 1].size / 2;
2667 if (rem == 0)
2668 break;
2669
2670 skb_shinfo(skb)->frags[i - 1].size -= rem;
2671
2672 skb_shinfo(skb)->frags[i] =
2673 skb_shinfo(skb)->frags[i - 1];
2674 get_page(skb_shinfo(skb)->frags[i].page);
2675 skb_shinfo(skb)->frags[i].page =
2676 skb_shinfo(skb)->frags[i - 1].page;
2677 skb_shinfo(skb)->frags[i].page_offset +=
2678 skb_shinfo(skb)->frags[i - 1].size;
2679 skb_shinfo(skb)->frags[i].size = rem;
2680 i++;
2681 skb_shinfo(skb)->nr_frags = i;
2682 }
2683 }
2684
2685 /* Stamp the time, and sequence number,
2686 * convert them to network byte order
2687 */
2688 pgh->pgh_magic = htonl(PKTGEN_MAGIC);
2689 pgh->seq_num = htonl(pkt_dev->seq_num);
2690
2691 do_gettimeofday(&timestamp);
2692 pgh->tv_sec = htonl(timestamp.tv_sec);
2693 pgh->tv_usec = htonl(timestamp.tv_usec);
2694}
2695
2608static struct sk_buff *fill_packet_ipv4(struct net_device *odev, 2696static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
2609 struct pktgen_dev *pkt_dev) 2697 struct pktgen_dev *pkt_dev)
2610{ 2698{
@@ -2613,7 +2701,6 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
2613 struct udphdr *udph; 2701 struct udphdr *udph;
2614 int datalen, iplen; 2702 int datalen, iplen;
2615 struct iphdr *iph; 2703 struct iphdr *iph;
2616 struct pktgen_hdr *pgh = NULL;
2617 __be16 protocol = htons(ETH_P_IP); 2704 __be16 protocol = htons(ETH_P_IP);
2618 __be32 *mpls; 2705 __be32 *mpls;
2619 __be16 *vlan_tci = NULL; /* Encapsulates priority and VLAN ID */ 2706 __be16 *vlan_tci = NULL; /* Encapsulates priority and VLAN ID */
@@ -2729,76 +2816,7 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
2729 pkt_dev->pkt_overhead); 2816 pkt_dev->pkt_overhead);
2730 skb->dev = odev; 2817 skb->dev = odev;
2731 skb->pkt_type = PACKET_HOST; 2818 skb->pkt_type = PACKET_HOST;
2732 2819 pktgen_finalize_skb(pkt_dev, skb, datalen);
2733 if (pkt_dev->nfrags <= 0) {
2734 pgh = (struct pktgen_hdr *)skb_put(skb, datalen);
2735 memset(pgh + 1, 0, datalen - sizeof(struct pktgen_hdr));
2736 } else {
2737 int frags = pkt_dev->nfrags;
2738 int i, len;
2739
2740 pgh = (struct pktgen_hdr *)(((char *)(udph)) + 8);
2741
2742 if (frags > MAX_SKB_FRAGS)
2743 frags = MAX_SKB_FRAGS;
2744 if (datalen > frags * PAGE_SIZE) {
2745 len = datalen - frags * PAGE_SIZE;
2746 memset(skb_put(skb, len), 0, len);
2747 datalen = frags * PAGE_SIZE;
2748 }
2749
2750 i = 0;
2751 while (datalen > 0) {
2752 struct page *page = alloc_pages(GFP_KERNEL | __GFP_ZERO, 0);
2753 skb_shinfo(skb)->frags[i].page = page;
2754 skb_shinfo(skb)->frags[i].page_offset = 0;
2755 skb_shinfo(skb)->frags[i].size =
2756 (datalen < PAGE_SIZE ? datalen : PAGE_SIZE);
2757 datalen -= skb_shinfo(skb)->frags[i].size;
2758 skb->len += skb_shinfo(skb)->frags[i].size;
2759 skb->data_len += skb_shinfo(skb)->frags[i].size;
2760 i++;
2761 skb_shinfo(skb)->nr_frags = i;
2762 }
2763
2764 while (i < frags) {
2765 int rem;
2766
2767 if (i == 0)
2768 break;
2769
2770 rem = skb_shinfo(skb)->frags[i - 1].size / 2;
2771 if (rem == 0)
2772 break;
2773
2774 skb_shinfo(skb)->frags[i - 1].size -= rem;
2775
2776 skb_shinfo(skb)->frags[i] =
2777 skb_shinfo(skb)->frags[i - 1];
2778 get_page(skb_shinfo(skb)->frags[i].page);
2779 skb_shinfo(skb)->frags[i].page =
2780 skb_shinfo(skb)->frags[i - 1].page;
2781 skb_shinfo(skb)->frags[i].page_offset +=
2782 skb_shinfo(skb)->frags[i - 1].size;
2783 skb_shinfo(skb)->frags[i].size = rem;
2784 i++;
2785 skb_shinfo(skb)->nr_frags = i;
2786 }
2787 }
2788
2789 /* Stamp the time, and sequence number,
2790 * convert them to network byte order
2791 */
2792 if (pgh) {
2793 struct timeval timestamp;
2794
2795 pgh->pgh_magic = htonl(PKTGEN_MAGIC);
2796 pgh->seq_num = htonl(pkt_dev->seq_num);
2797
2798 do_gettimeofday(&timestamp);
2799 pgh->tv_sec = htonl(timestamp.tv_sec);
2800 pgh->tv_usec = htonl(timestamp.tv_usec);
2801 }
2802 2820
2803#ifdef CONFIG_XFRM 2821#ifdef CONFIG_XFRM
2804 if (!process_ipsec(pkt_dev, skb, protocol)) 2822 if (!process_ipsec(pkt_dev, skb, protocol))
@@ -2980,7 +2998,6 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
2980 struct udphdr *udph; 2998 struct udphdr *udph;
2981 int datalen; 2999 int datalen;
2982 struct ipv6hdr *iph; 3000 struct ipv6hdr *iph;
2983 struct pktgen_hdr *pgh = NULL;
2984 __be16 protocol = htons(ETH_P_IPV6); 3001 __be16 protocol = htons(ETH_P_IPV6);
2985 __be32 *mpls; 3002 __be32 *mpls;
2986 __be16 *vlan_tci = NULL; /* Encapsulates priority and VLAN ID */ 3003 __be16 *vlan_tci = NULL; /* Encapsulates priority and VLAN ID */
@@ -3083,75 +3100,7 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
3083 skb->dev = odev; 3100 skb->dev = odev;
3084 skb->pkt_type = PACKET_HOST; 3101 skb->pkt_type = PACKET_HOST;
3085 3102
3086 if (pkt_dev->nfrags <= 0) 3103 pktgen_finalize_skb(pkt_dev, skb, datalen);
3087 pgh = (struct pktgen_hdr *)skb_put(skb, datalen);
3088 else {
3089 int frags = pkt_dev->nfrags;
3090 int i;
3091
3092 pgh = (struct pktgen_hdr *)(((char *)(udph)) + 8);
3093
3094 if (frags > MAX_SKB_FRAGS)
3095 frags = MAX_SKB_FRAGS;
3096 if (datalen > frags * PAGE_SIZE) {
3097 skb_put(skb, datalen - frags * PAGE_SIZE);
3098 datalen = frags * PAGE_SIZE;
3099 }
3100
3101 i = 0;
3102 while (datalen > 0) {
3103 struct page *page = alloc_pages(GFP_KERNEL, 0);
3104 skb_shinfo(skb)->frags[i].page = page;
3105 skb_shinfo(skb)->frags[i].page_offset = 0;
3106 skb_shinfo(skb)->frags[i].size =
3107 (datalen < PAGE_SIZE ? datalen : PAGE_SIZE);
3108 datalen -= skb_shinfo(skb)->frags[i].size;
3109 skb->len += skb_shinfo(skb)->frags[i].size;
3110 skb->data_len += skb_shinfo(skb)->frags[i].size;
3111 i++;
3112 skb_shinfo(skb)->nr_frags = i;
3113 }
3114
3115 while (i < frags) {
3116 int rem;
3117
3118 if (i == 0)
3119 break;
3120
3121 rem = skb_shinfo(skb)->frags[i - 1].size / 2;
3122 if (rem == 0)
3123 break;
3124
3125 skb_shinfo(skb)->frags[i - 1].size -= rem;
3126
3127 skb_shinfo(skb)->frags[i] =
3128 skb_shinfo(skb)->frags[i - 1];
3129 get_page(skb_shinfo(skb)->frags[i].page);
3130 skb_shinfo(skb)->frags[i].page =
3131 skb_shinfo(skb)->frags[i - 1].page;
3132 skb_shinfo(skb)->frags[i].page_offset +=
3133 skb_shinfo(skb)->frags[i - 1].size;
3134 skb_shinfo(skb)->frags[i].size = rem;
3135 i++;
3136 skb_shinfo(skb)->nr_frags = i;
3137 }
3138 }
3139
3140 /* Stamp the time, and sequence number,
3141 * convert them to network byte order
3142 * should we update cloned packets too ?
3143 */
3144 if (pgh) {
3145 struct timeval timestamp;
3146
3147 pgh->pgh_magic = htonl(PKTGEN_MAGIC);
3148 pgh->seq_num = htonl(pkt_dev->seq_num);
3149
3150 do_gettimeofday(&timestamp);
3151 pgh->tv_sec = htonl(timestamp.tv_sec);
3152 pgh->tv_usec = htonl(timestamp.tv_usec);
3153 }
3154 /* pkt_dev->seq_num++; FF: you really mean this? */
3155 3104
3156 return skb; 3105 return skb;
3157} 3106}
@@ -3321,7 +3270,7 @@ static void show_results(struct pktgen_dev *pkt_dev, int nr_frags)
3321 pkt_dev->started_at); 3270 pkt_dev->started_at);
3322 ktime_t idle = ns_to_ktime(pkt_dev->idle_acc); 3271 ktime_t idle = ns_to_ktime(pkt_dev->idle_acc);
3323 3272
3324 p += sprintf(p, "OK: %llu(c%llu+d%llu) nsec, %llu (%dbyte,%dfrags)\n", 3273 p += sprintf(p, "OK: %llu(c%llu+d%llu) usec, %llu (%dbyte,%dfrags)\n",
3325 (unsigned long long)ktime_to_us(elapsed), 3274 (unsigned long long)ktime_to_us(elapsed),
3326 (unsigned long long)ktime_to_us(ktime_sub(elapsed, idle)), 3275 (unsigned long long)ktime_to_us(ktime_sub(elapsed, idle)),
3327 (unsigned long long)ktime_to_us(idle), 3276 (unsigned long long)ktime_to_us(idle),
@@ -3812,7 +3761,10 @@ static int __init pktgen_create_thread(int cpu)
3812 list_add_tail(&t->th_list, &pktgen_threads); 3761 list_add_tail(&t->th_list, &pktgen_threads);
3813 init_completion(&t->start_done); 3762 init_completion(&t->start_done);
3814 3763
3815 p = kthread_create(pktgen_thread_worker, t, "kpktgend_%d", cpu); 3764 p = kthread_create_on_node(pktgen_thread_worker,
3765 t,
3766 cpu_to_node(cpu),
3767 "kpktgend_%d", cpu);
3816 if (IS_ERR(p)) { 3768 if (IS_ERR(p)) {
3817 pr_err("kernel_thread() failed for cpu %d\n", t->cpu); 3769 pr_err("kernel_thread() failed for cpu %d\n", t->cpu);
3818 list_del(&t->th_list); 3770 list_del(&t->th_list);
@@ -3884,6 +3836,8 @@ static int pktgen_remove_device(struct pktgen_thread *t,
3884 free_SAs(pkt_dev); 3836 free_SAs(pkt_dev);
3885#endif 3837#endif
3886 vfree(pkt_dev->flows); 3838 vfree(pkt_dev->flows);
3839 if (pkt_dev->page)
3840 put_page(pkt_dev->page);
3887 kfree(pkt_dev); 3841 kfree(pkt_dev);
3888 return 0; 3842 return 0;
3889} 3843}
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 2d65c6bb24c1..d7c4bb4b1820 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -196,7 +196,7 @@ EXPORT_SYMBOL_GPL(__rtnl_register);
196 * as failure of this function is very unlikely, it can only happen due 196 * as failure of this function is very unlikely, it can only happen due
197 * to lack of memory when allocating the chain to store all message 197 * to lack of memory when allocating the chain to store all message
198 * handlers for a protocol. Meant for use in init functions where lack 198 * handlers for a protocol. Meant for use in init functions where lack
199 * of memory implies no sense in continueing. 199 * of memory implies no sense in continuing.
200 */ 200 */
201void rtnl_register(int protocol, int msgtype, 201void rtnl_register(int protocol, int msgtype,
202 rtnl_doit_func doit, rtnl_dumpit_func dumpit) 202 rtnl_doit_func doit, rtnl_dumpit_func dumpit)
@@ -868,6 +868,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
868 netif_running(dev) ? dev->operstate : IF_OPER_DOWN); 868 netif_running(dev) ? dev->operstate : IF_OPER_DOWN);
869 NLA_PUT_U8(skb, IFLA_LINKMODE, dev->link_mode); 869 NLA_PUT_U8(skb, IFLA_LINKMODE, dev->link_mode);
870 NLA_PUT_U32(skb, IFLA_MTU, dev->mtu); 870 NLA_PUT_U32(skb, IFLA_MTU, dev->mtu);
871 NLA_PUT_U32(skb, IFLA_GROUP, dev->group);
871 872
872 if (dev->ifindex != dev->iflink) 873 if (dev->ifindex != dev->iflink)
873 NLA_PUT_U32(skb, IFLA_LINK, dev->iflink); 874 NLA_PUT_U32(skb, IFLA_LINK, dev->iflink);
@@ -1035,6 +1036,7 @@ const struct nla_policy ifla_policy[IFLA_MAX+1] = {
1035 [IFLA_MAP] = { .len = sizeof(struct rtnl_link_ifmap) }, 1036 [IFLA_MAP] = { .len = sizeof(struct rtnl_link_ifmap) },
1036 [IFLA_MTU] = { .type = NLA_U32 }, 1037 [IFLA_MTU] = { .type = NLA_U32 },
1037 [IFLA_LINK] = { .type = NLA_U32 }, 1038 [IFLA_LINK] = { .type = NLA_U32 },
1039 [IFLA_MASTER] = { .type = NLA_U32 },
1038 [IFLA_TXQLEN] = { .type = NLA_U32 }, 1040 [IFLA_TXQLEN] = { .type = NLA_U32 },
1039 [IFLA_WEIGHT] = { .type = NLA_U32 }, 1041 [IFLA_WEIGHT] = { .type = NLA_U32 },
1040 [IFLA_OPERSTATE] = { .type = NLA_U8 }, 1042 [IFLA_OPERSTATE] = { .type = NLA_U8 },
@@ -1177,6 +1179,41 @@ static int do_setvfinfo(struct net_device *dev, struct nlattr *attr)
1177 return err; 1179 return err;
1178} 1180}
1179 1181
1182static int do_set_master(struct net_device *dev, int ifindex)
1183{
1184 struct net_device *master_dev;
1185 const struct net_device_ops *ops;
1186 int err;
1187
1188 if (dev->master) {
1189 if (dev->master->ifindex == ifindex)
1190 return 0;
1191 ops = dev->master->netdev_ops;
1192 if (ops->ndo_del_slave) {
1193 err = ops->ndo_del_slave(dev->master, dev);
1194 if (err)
1195 return err;
1196 } else {
1197 return -EOPNOTSUPP;
1198 }
1199 }
1200
1201 if (ifindex) {
1202 master_dev = __dev_get_by_index(dev_net(dev), ifindex);
1203 if (!master_dev)
1204 return -EINVAL;
1205 ops = master_dev->netdev_ops;
1206 if (ops->ndo_add_slave) {
1207 err = ops->ndo_add_slave(master_dev, dev);
1208 if (err)
1209 return err;
1210 } else {
1211 return -EOPNOTSUPP;
1212 }
1213 }
1214 return 0;
1215}
1216
1180static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm, 1217static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
1181 struct nlattr **tb, char *ifname, int modified) 1218 struct nlattr **tb, char *ifname, int modified)
1182{ 1219{
@@ -1264,6 +1301,11 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
1264 modified = 1; 1301 modified = 1;
1265 } 1302 }
1266 1303
1304 if (tb[IFLA_GROUP]) {
1305 dev_set_group(dev, nla_get_u32(tb[IFLA_GROUP]));
1306 modified = 1;
1307 }
1308
1267 /* 1309 /*
1268 * Interface selected by interface index but interface 1310 * Interface selected by interface index but interface
1269 * name provided implies that a name change has been 1311 * name provided implies that a name change has been
@@ -1295,6 +1337,13 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
1295 goto errout; 1337 goto errout;
1296 } 1338 }
1297 1339
1340 if (tb[IFLA_MASTER]) {
1341 err = do_set_master(dev, nla_get_u32(tb[IFLA_MASTER]));
1342 if (err)
1343 goto errout;
1344 modified = 1;
1345 }
1346
1298 if (tb[IFLA_TXQLEN]) 1347 if (tb[IFLA_TXQLEN])
1299 dev->tx_queue_len = nla_get_u32(tb[IFLA_TXQLEN]); 1348 dev->tx_queue_len = nla_get_u32(tb[IFLA_TXQLEN]);
1300 1349
@@ -1391,7 +1440,7 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
1391errout: 1440errout:
1392 if (err < 0 && modified && net_ratelimit()) 1441 if (err < 0 && modified && net_ratelimit())
1393 printk(KERN_WARNING "A link change request failed with " 1442 printk(KERN_WARNING "A link change request failed with "
1394 "some changes comitted already. Interface %s may " 1443 "some changes committed already. Interface %s may "
1395 "have been left with an inconsistent configuration, " 1444 "have been left with an inconsistent configuration, "
1396 "please check.\n", dev->name); 1445 "please check.\n", dev->name);
1397 1446
@@ -1541,6 +1590,8 @@ struct net_device *rtnl_create_link(struct net *src_net, struct net *net,
1541 set_operstate(dev, nla_get_u8(tb[IFLA_OPERSTATE])); 1590 set_operstate(dev, nla_get_u8(tb[IFLA_OPERSTATE]));
1542 if (tb[IFLA_LINKMODE]) 1591 if (tb[IFLA_LINKMODE])
1543 dev->link_mode = nla_get_u8(tb[IFLA_LINKMODE]); 1592 dev->link_mode = nla_get_u8(tb[IFLA_LINKMODE]);
1593 if (tb[IFLA_GROUP])
1594 dev_set_group(dev, nla_get_u32(tb[IFLA_GROUP]));
1544 1595
1545 return dev; 1596 return dev;
1546 1597
@@ -1551,6 +1602,24 @@ err:
1551} 1602}
1552EXPORT_SYMBOL(rtnl_create_link); 1603EXPORT_SYMBOL(rtnl_create_link);
1553 1604
1605static int rtnl_group_changelink(struct net *net, int group,
1606 struct ifinfomsg *ifm,
1607 struct nlattr **tb)
1608{
1609 struct net_device *dev;
1610 int err;
1611
1612 for_each_netdev(net, dev) {
1613 if (dev->group == group) {
1614 err = do_setlink(dev, ifm, tb, NULL, 0);
1615 if (err < 0)
1616 return err;
1617 }
1618 }
1619
1620 return 0;
1621}
1622
1554static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) 1623static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
1555{ 1624{
1556 struct net *net = sock_net(skb->sk); 1625 struct net *net = sock_net(skb->sk);
@@ -1578,10 +1647,12 @@ replay:
1578 ifm = nlmsg_data(nlh); 1647 ifm = nlmsg_data(nlh);
1579 if (ifm->ifi_index > 0) 1648 if (ifm->ifi_index > 0)
1580 dev = __dev_get_by_index(net, ifm->ifi_index); 1649 dev = __dev_get_by_index(net, ifm->ifi_index);
1581 else if (ifname[0]) 1650 else {
1582 dev = __dev_get_by_name(net, ifname); 1651 if (ifname[0])
1583 else 1652 dev = __dev_get_by_name(net, ifname);
1584 dev = NULL; 1653 else
1654 dev = NULL;
1655 }
1585 1656
1586 err = validate_linkmsg(dev, tb); 1657 err = validate_linkmsg(dev, tb);
1587 if (err < 0) 1658 if (err < 0)
@@ -1645,8 +1716,13 @@ replay:
1645 return do_setlink(dev, ifm, tb, ifname, modified); 1716 return do_setlink(dev, ifm, tb, ifname, modified);
1646 } 1717 }
1647 1718
1648 if (!(nlh->nlmsg_flags & NLM_F_CREATE)) 1719 if (!(nlh->nlmsg_flags & NLM_F_CREATE)) {
1720 if (ifm->ifi_index == 0 && tb[IFLA_GROUP])
1721 return rtnl_group_changelink(net,
1722 nla_get_u32(tb[IFLA_GROUP]),
1723 ifm, tb);
1649 return -ENODEV; 1724 return -ENODEV;
1725 }
1650 1726
1651 if (ifm->ifi_index) 1727 if (ifm->ifi_index)
1652 return -EOPNOTSUPP; 1728 return -EOPNOTSUPP;
diff --git a/net/core/scm.c b/net/core/scm.c
index bbe454450801..4c1ef026d695 100644
--- a/net/core/scm.c
+++ b/net/core/scm.c
@@ -95,7 +95,7 @@ static int scm_fp_copy(struct cmsghdr *cmsg, struct scm_fp_list **fplp)
95 int fd = fdp[i]; 95 int fd = fdp[i];
96 struct file *file; 96 struct file *file;
97 97
98 if (fd < 0 || !(file = fget(fd))) 98 if (fd < 0 || !(file = fget_raw(fd)))
99 return -EBADF; 99 return -EBADF;
100 *fpp++ = file; 100 *fpp++ = file;
101 fpl->count++; 101 fpl->count++;
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index d883dcc78b6b..7ebeed0a877c 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -523,7 +523,6 @@ static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
523 new->ip_summed = old->ip_summed; 523 new->ip_summed = old->ip_summed;
524 skb_copy_queue_mapping(new, old); 524 skb_copy_queue_mapping(new, old);
525 new->priority = old->priority; 525 new->priority = old->priority;
526 new->deliver_no_wcard = old->deliver_no_wcard;
527#if defined(CONFIG_IP_VS) || defined(CONFIG_IP_VS_MODULE) 526#if defined(CONFIG_IP_VS) || defined(CONFIG_IP_VS_MODULE)
528 new->ipvs_property = old->ipvs_property; 527 new->ipvs_property = old->ipvs_property;
529#endif 528#endif
@@ -2268,7 +2267,7 @@ EXPORT_SYMBOL(skb_prepare_seq_read);
2268 * of bytes already consumed and the next call to 2267 * of bytes already consumed and the next call to
2269 * skb_seq_read() will return the remaining part of the block. 2268 * skb_seq_read() will return the remaining part of the block.
2270 * 2269 *
2271 * Note 1: The size of each block of data returned can be arbitary, 2270 * Note 1: The size of each block of data returned can be arbitrary,
2272 * this limitation is the cost for zerocopy seqeuental 2271 * this limitation is the cost for zerocopy seqeuental
2273 * reads of potentially non linear data. 2272 * reads of potentially non linear data.
2274 * 2273 *
@@ -2434,8 +2433,6 @@ int skb_append_datato_frags(struct sock *sk, struct sk_buff *skb,
2434 return -ENOMEM; 2433 return -ENOMEM;
2435 2434
2436 /* initialize the next frag */ 2435 /* initialize the next frag */
2437 sk->sk_sndmsg_page = page;
2438 sk->sk_sndmsg_off = 0;
2439 skb_fill_page_desc(skb, frg_cnt, page, 0, 0); 2436 skb_fill_page_desc(skb, frg_cnt, page, 0, 0);
2440 skb->truesize += PAGE_SIZE; 2437 skb->truesize += PAGE_SIZE;
2441 atomic_add(PAGE_SIZE, &sk->sk_wmem_alloc); 2438 atomic_add(PAGE_SIZE, &sk->sk_wmem_alloc);
@@ -2455,7 +2452,6 @@ int skb_append_datato_frags(struct sock *sk, struct sk_buff *skb,
2455 return -EFAULT; 2452 return -EFAULT;
2456 2453
2457 /* copy was successful so update the size parameters */ 2454 /* copy was successful so update the size parameters */
2458 sk->sk_sndmsg_off += copy;
2459 frag->size += copy; 2455 frag->size += copy;
2460 skb->len += copy; 2456 skb->len += copy;
2461 skb->data_len += copy; 2457 skb->data_len += copy;
@@ -2498,7 +2494,7 @@ EXPORT_SYMBOL_GPL(skb_pull_rcsum);
2498 * a pointer to the first in a list of new skbs for the segments. 2494 * a pointer to the first in a list of new skbs for the segments.
2499 * In case of error it returns ERR_PTR(err). 2495 * In case of error it returns ERR_PTR(err).
2500 */ 2496 */
2501struct sk_buff *skb_segment(struct sk_buff *skb, int features) 2497struct sk_buff *skb_segment(struct sk_buff *skb, u32 features)
2502{ 2498{
2503 struct sk_buff *segs = NULL; 2499 struct sk_buff *segs = NULL;
2504 struct sk_buff *tail = NULL; 2500 struct sk_buff *tail = NULL;
@@ -2508,7 +2504,7 @@ struct sk_buff *skb_segment(struct sk_buff *skb, int features)
2508 unsigned int offset = doffset; 2504 unsigned int offset = doffset;
2509 unsigned int headroom; 2505 unsigned int headroom;
2510 unsigned int len; 2506 unsigned int len;
2511 int sg = features & NETIF_F_SG; 2507 int sg = !!(features & NETIF_F_SG);
2512 int nfrags = skb_shinfo(skb)->nr_frags; 2508 int nfrags = skb_shinfo(skb)->nr_frags;
2513 int err = -ENOMEM; 2509 int err = -ENOMEM;
2514 int i = 0; 2510 int i = 0;
diff --git a/net/core/sock.c b/net/core/sock.c
index 7dfed792434d..6e819780c232 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -215,7 +215,7 @@ __u32 sysctl_rmem_max __read_mostly = SK_RMEM_MAX;
215__u32 sysctl_wmem_default __read_mostly = SK_WMEM_MAX; 215__u32 sysctl_wmem_default __read_mostly = SK_WMEM_MAX;
216__u32 sysctl_rmem_default __read_mostly = SK_RMEM_MAX; 216__u32 sysctl_rmem_default __read_mostly = SK_RMEM_MAX;
217 217
218/* Maximal space eaten by iovec or ancilliary data plus some space */ 218/* Maximal space eaten by iovec or ancillary data plus some space */
219int sysctl_optmem_max __read_mostly = sizeof(unsigned long)*(2*UIO_MAXIOV+512); 219int sysctl_optmem_max __read_mostly = sizeof(unsigned long)*(2*UIO_MAXIOV+512);
220EXPORT_SYMBOL(sysctl_optmem_max); 220EXPORT_SYMBOL(sysctl_optmem_max);
221 221
@@ -1175,7 +1175,7 @@ static void __sk_free(struct sock *sk)
1175void sk_free(struct sock *sk) 1175void sk_free(struct sock *sk)
1176{ 1176{
1177 /* 1177 /*
1178 * We substract one from sk_wmem_alloc and can know if 1178 * We subtract one from sk_wmem_alloc and can know if
1179 * some packets are still in some tx queue. 1179 * some packets are still in some tx queue.
1180 * If not null, sock_wfree() will call __sk_free(sk) later 1180 * If not null, sock_wfree() will call __sk_free(sk) later
1181 */ 1181 */
@@ -1185,10 +1185,10 @@ void sk_free(struct sock *sk)
1185EXPORT_SYMBOL(sk_free); 1185EXPORT_SYMBOL(sk_free);
1186 1186
1187/* 1187/*
1188 * Last sock_put should drop referrence to sk->sk_net. It has already 1188 * Last sock_put should drop reference to sk->sk_net. It has already
1189 * been dropped in sk_change_net. Taking referrence to stopping namespace 1189 * been dropped in sk_change_net. Taking reference to stopping namespace
1190 * is not an option. 1190 * is not an option.
1191 * Take referrence to a socket to remove it from hash _alive_ and after that 1191 * Take reference to a socket to remove it from hash _alive_ and after that
1192 * destroy it in the context of init_net. 1192 * destroy it in the context of init_net.
1193 */ 1193 */
1194void sk_release_kernel(struct sock *sk) 1194void sk_release_kernel(struct sock *sk)