diff options
author | Wei Liu <wei.liu2@citrix.com> | 2013-05-01 20:43:59 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-05-02 16:50:08 -0400 |
commit | 376414945d15aa636e65f7e773c1e398b7a21cb9 (patch) | |
tree | 4950ccac38966156f0a5bee6665efd666be610f1 /drivers/net | |
parent | 59ccb4ebbc35e36a3c143f2d1355deb75c2e628f (diff) |
xen-netback: better names for thresholds
This patch only changes some names to avoid confusion.
In this patch we have:
MAX_SKB_SLOTS_DEFAULT -> FATAL_SKB_SLOTS_DEFAULT
max_skb_slots -> fatal_skb_slots
#define XEN_NETBK_LEGACY_SLOTS_MAX XEN_NETIF_NR_SLOTS_MIN
The fatal_skb_slots is the threshold to determine whether a packet is
malicious.
XEN_NETBK_LEGACY_SLOTS_MAX is the maximum slots a valid packet can have at
this point. It is defined to be XEN_NETIF_NR_SLOTS_MIN because that's
guaranteed to be supported by all backends.
Suggested-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/xen-netback/netback.c | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c index ce8109f7d56f..37984e6d4e99 100644 --- a/drivers/net/xen-netback/netback.c +++ b/drivers/net/xen-netback/netback.c | |||
@@ -51,9 +51,17 @@ | |||
51 | * This is the maximum slots a skb can have. If a guest sends a skb | 51 | * This is the maximum slots a skb can have. If a guest sends a skb |
52 | * which exceeds this limit it is considered malicious. | 52 | * which exceeds this limit it is considered malicious. |
53 | */ | 53 | */ |
54 | #define MAX_SKB_SLOTS_DEFAULT 20 | 54 | #define FATAL_SKB_SLOTS_DEFAULT 20 |
55 | static unsigned int max_skb_slots = MAX_SKB_SLOTS_DEFAULT; | 55 | static unsigned int fatal_skb_slots = FATAL_SKB_SLOTS_DEFAULT; |
56 | module_param(max_skb_slots, uint, 0444); | 56 | module_param(fatal_skb_slots, uint, 0444); |
57 | |||
58 | /* | ||
59 | * To avoid confusion, we define XEN_NETBK_LEGACY_SLOTS_MAX indicating | ||
60 | * the maximum slots a valid packet can use. Now this value is defined | ||
61 | * to be XEN_NETIF_NR_SLOTS_MIN, which is supposed to be supported by | ||
62 | * all backend. | ||
63 | */ | ||
64 | #define XEN_NETBK_LEGACY_SLOTS_MAX XEN_NETIF_NR_SLOTS_MIN | ||
57 | 65 | ||
58 | typedef unsigned int pending_ring_idx_t; | 66 | typedef unsigned int pending_ring_idx_t; |
59 | #define INVALID_PENDING_RING_IDX (~0U) | 67 | #define INVALID_PENDING_RING_IDX (~0U) |
@@ -953,25 +961,26 @@ static int netbk_count_requests(struct xenvif *vif, | |||
953 | /* This guest is really using too many slots and | 961 | /* This guest is really using too many slots and |
954 | * considered malicious. | 962 | * considered malicious. |
955 | */ | 963 | */ |
956 | if (unlikely(slots >= max_skb_slots)) { | 964 | if (unlikely(slots >= fatal_skb_slots)) { |
957 | netdev_err(vif->dev, | 965 | netdev_err(vif->dev, |
958 | "Malicious frontend using %d slots, threshold %u\n", | 966 | "Malicious frontend using %d slots, threshold %u\n", |
959 | slots, max_skb_slots); | 967 | slots, fatal_skb_slots); |
960 | netbk_fatal_tx_err(vif); | 968 | netbk_fatal_tx_err(vif); |
961 | return -E2BIG; | 969 | return -E2BIG; |
962 | } | 970 | } |
963 | 971 | ||
964 | /* Xen network protocol had implicit dependency on | 972 | /* Xen network protocol had implicit dependency on |
965 | * MAX_SKB_FRAGS. XEN_NETIF_NR_SLOTS_MIN is set to the | 973 | * MAX_SKB_FRAGS. XEN_NETBK_LEGACY_SLOTS_MAX is set to |
966 | * historical MAX_SKB_FRAGS value 18 to honor the same | 974 | * the historical MAX_SKB_FRAGS value 18 to honor the |
967 | * behavior as before. Any packet using more than 18 | 975 | * same behavior as before. Any packet using more than |
968 | * slots but less than max_skb_slots slots is dropped | 976 | * 18 slots but less than fatal_skb_slots slots is |
977 | * dropped | ||
969 | */ | 978 | */ |
970 | if (!drop_err && slots >= XEN_NETIF_NR_SLOTS_MIN) { | 979 | if (!drop_err && slots >= XEN_NETBK_LEGACY_SLOTS_MAX) { |
971 | if (net_ratelimit()) | 980 | if (net_ratelimit()) |
972 | netdev_dbg(vif->dev, | 981 | netdev_dbg(vif->dev, |
973 | "Too many slots (%d) exceeding limit (%d), dropping packet\n", | 982 | "Too many slots (%d) exceeding limit (%d), dropping packet\n", |
974 | slots, XEN_NETIF_NR_SLOTS_MIN); | 983 | slots, XEN_NETBK_LEGACY_SLOTS_MAX); |
975 | drop_err = -E2BIG; | 984 | drop_err = -E2BIG; |
976 | } | 985 | } |
977 | 986 | ||
@@ -1053,7 +1062,7 @@ static struct gnttab_copy *xen_netbk_get_requests(struct xen_netbk *netbk, | |||
1053 | struct pending_tx_info *first = NULL; | 1062 | struct pending_tx_info *first = NULL; |
1054 | 1063 | ||
1055 | /* At this point shinfo->nr_frags is in fact the number of | 1064 | /* At this point shinfo->nr_frags is in fact the number of |
1056 | * slots, which can be as large as XEN_NETIF_NR_SLOTS_MIN. | 1065 | * slots, which can be as large as XEN_NETBK_LEGACY_SLOTS_MAX. |
1057 | */ | 1066 | */ |
1058 | nr_slots = shinfo->nr_frags; | 1067 | nr_slots = shinfo->nr_frags; |
1059 | 1068 | ||
@@ -1415,12 +1424,12 @@ static unsigned xen_netbk_tx_build_gops(struct xen_netbk *netbk) | |||
1415 | struct sk_buff *skb; | 1424 | struct sk_buff *skb; |
1416 | int ret; | 1425 | int ret; |
1417 | 1426 | ||
1418 | while ((nr_pending_reqs(netbk) + XEN_NETIF_NR_SLOTS_MIN | 1427 | while ((nr_pending_reqs(netbk) + XEN_NETBK_LEGACY_SLOTS_MAX |
1419 | < MAX_PENDING_REQS) && | 1428 | < MAX_PENDING_REQS) && |
1420 | !list_empty(&netbk->net_schedule_list)) { | 1429 | !list_empty(&netbk->net_schedule_list)) { |
1421 | struct xenvif *vif; | 1430 | struct xenvif *vif; |
1422 | struct xen_netif_tx_request txreq; | 1431 | struct xen_netif_tx_request txreq; |
1423 | struct xen_netif_tx_request txfrags[XEN_NETIF_NR_SLOTS_MIN]; | 1432 | struct xen_netif_tx_request txfrags[XEN_NETBK_LEGACY_SLOTS_MAX]; |
1424 | struct page *page; | 1433 | struct page *page; |
1425 | struct xen_netif_extra_info extras[XEN_NETIF_EXTRA_TYPE_MAX-1]; | 1434 | struct xen_netif_extra_info extras[XEN_NETIF_EXTRA_TYPE_MAX-1]; |
1426 | u16 pending_idx; | 1435 | u16 pending_idx; |
@@ -1508,7 +1517,7 @@ static unsigned xen_netbk_tx_build_gops(struct xen_netbk *netbk) | |||
1508 | pending_idx = netbk->pending_ring[index]; | 1517 | pending_idx = netbk->pending_ring[index]; |
1509 | 1518 | ||
1510 | data_len = (txreq.size > PKT_PROT_LEN && | 1519 | data_len = (txreq.size > PKT_PROT_LEN && |
1511 | ret < XEN_NETIF_NR_SLOTS_MIN) ? | 1520 | ret < XEN_NETBK_LEGACY_SLOTS_MAX) ? |
1512 | PKT_PROT_LEN : txreq.size; | 1521 | PKT_PROT_LEN : txreq.size; |
1513 | 1522 | ||
1514 | skb = alloc_skb(data_len + NET_SKB_PAD + NET_IP_ALIGN, | 1523 | skb = alloc_skb(data_len + NET_SKB_PAD + NET_IP_ALIGN, |
@@ -1787,7 +1796,7 @@ static inline int rx_work_todo(struct xen_netbk *netbk) | |||
1787 | static inline int tx_work_todo(struct xen_netbk *netbk) | 1796 | static inline int tx_work_todo(struct xen_netbk *netbk) |
1788 | { | 1797 | { |
1789 | 1798 | ||
1790 | if ((nr_pending_reqs(netbk) + XEN_NETIF_NR_SLOTS_MIN | 1799 | if ((nr_pending_reqs(netbk) + XEN_NETBK_LEGACY_SLOTS_MAX |
1791 | < MAX_PENDING_REQS) && | 1800 | < MAX_PENDING_REQS) && |
1792 | !list_empty(&netbk->net_schedule_list)) | 1801 | !list_empty(&netbk->net_schedule_list)) |
1793 | return 1; | 1802 | return 1; |
@@ -1872,11 +1881,11 @@ static int __init netback_init(void) | |||
1872 | if (!xen_domain()) | 1881 | if (!xen_domain()) |
1873 | return -ENODEV; | 1882 | return -ENODEV; |
1874 | 1883 | ||
1875 | if (max_skb_slots < XEN_NETIF_NR_SLOTS_MIN) { | 1884 | if (fatal_skb_slots < XEN_NETBK_LEGACY_SLOTS_MAX) { |
1876 | printk(KERN_INFO | 1885 | printk(KERN_INFO |
1877 | "xen-netback: max_skb_slots too small (%d), bump it to XEN_NETIF_NR_SLOTS_MIN (%d)\n", | 1886 | "xen-netback: fatal_skb_slots too small (%d), bump it to XEN_NETBK_LEGACY_SLOTS_MAX (%d)\n", |
1878 | max_skb_slots, XEN_NETIF_NR_SLOTS_MIN); | 1887 | fatal_skb_slots, XEN_NETBK_LEGACY_SLOTS_MAX); |
1879 | max_skb_slots = XEN_NETIF_NR_SLOTS_MIN; | 1888 | fatal_skb_slots = XEN_NETBK_LEGACY_SLOTS_MAX; |
1880 | } | 1889 | } |
1881 | 1890 | ||
1882 | xen_netbk_group_nr = num_online_cpus(); | 1891 | xen_netbk_group_nr = num_online_cpus(); |