Re: [PATCH iproute2] ip link set vf: Added "query_rss" command
On 04/13/15 14:04, Vlad Zolotarov wrote: On 03/25/15 00:47, Stephen Hemminger wrote: On Sun, 22 Mar 2015 20:52:58 +0200 Vlad Zolotarov wrote: Add a new option to toggle the ability of querying the RSS configuration of a specific VF. VF RSS information like RSS hash key may be considered sensitive on some devices where this information is shared between VF and PF and thus its querying may be prohibited by default. This new option allows a system administrator with privileges to modify a PF state to control if the above VF querying is allowed or not. For example: To enable RSS querying of VF[0] of ethX: >> ip link set dev ethX vf 0 query_rss on Signed-off-by: Vlad Zolotarov Holding off on this going into iproute until kernel component goes into net-next Hi. The kernel patches have been pulled by Dave. Could u, pls., proceed with this one? ping ;) thanks, vlad -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH net] net/bonding: Make DRV macros private
From: Matan Barak The bonding modules currently defines four macros with general names that pollute the global namespace: DRV_VERSION DRV_RELDATE DRV_NAME DRV_DESCRIPTION Fixing that by defining a private bonding_priv.h header files which includes those defines. Signed-off-by: Matan Barak Signed-off-by: Or Gerlitz --- Hi Dave, We've been hitting this small issue when working on rdma-next (4.2) features to the IB driver, so just to avoid unnecessary deps sending it as fix for 4.1-rc1 Matan used the somehow old header for the new file, hope this is OK, and if not, we'll change... Or. drivers/net/bonding/bond_main.c|2 ++ drivers/net/bonding/bond_procfs.c |1 + drivers/net/bonding/bonding_priv.h | 25 + include/net/bonding.h |7 --- 4 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 drivers/net/bonding/bonding_priv.h diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 78dde56..3a10551 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -82,6 +82,8 @@ #include #include +#include "bonding_priv.h" + /* Module parameters */ /* monitor all links that often (in milliseconds). <=0 disables monitoring */ diff --git a/drivers/net/bonding/bond_procfs.c b/drivers/net/bonding/bond_procfs.c index 62694cf..b20b35a 100644 --- a/drivers/net/bonding/bond_procfs.c +++ b/drivers/net/bonding/bond_procfs.c @@ -4,6 +4,7 @@ #include #include +#include "bonding_priv.h" static void *bond_info_seq_start(struct seq_file *seq, loff_t *pos) __acquires(RCU) diff --git a/drivers/net/bonding/bonding_priv.h b/drivers/net/bonding/bonding_priv.h new file mode 100644 index 000..5a4d81a --- /dev/null +++ b/drivers/net/bonding/bonding_priv.h @@ -0,0 +1,25 @@ +/* + * Bond several ethernet interfaces into a Cisco, running 'Etherchannel'. + * + * Portions are (c) Copyright 1995 Simon "Guru Aleph-Null" Janes + * NCM: Network and Communications Management, Inc. + * + * BUT, I'm the one who modified it for ethernet, so: + * (c) Copyright 1999, Thomas Davis, tada...@lbl.gov + * + * This software may be used and distributed according to the terms + * of the GNU Public License, incorporated herein by reference. + * + */ + +#ifndef _BONDING_PRIV_H +#define _BONDING_PRIV_H + +#define DRV_VERSION"3.7.1" +#define DRV_RELDATE"April 27, 2011" +#define DRV_NAME "bonding" +#define DRV_DESCRIPTION"Ethernet Channel Bonding Driver" + +#define bond_version DRV_DESCRIPTION ": v" DRV_VERSION " (" DRV_RELDATE ")\n" + +#endif diff --git a/include/net/bonding.h b/include/net/bonding.h index fda6fee..78ed135 100644 --- a/include/net/bonding.h +++ b/include/net/bonding.h @@ -30,13 +30,6 @@ #include #include -#define DRV_VERSION"3.7.1" -#define DRV_RELDATE"April 27, 2011" -#define DRV_NAME "bonding" -#define DRV_DESCRIPTION"Ethernet Channel Bonding Driver" - -#define bond_version DRV_DESCRIPTION ": v" DRV_VERSION " (" DRV_RELDATE ")\n" - #define BOND_MAX_ARP_TARGETS 16 #define BOND_DEFAULT_MIIMON100 -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH net 2/2] net/mlx4_en: Prevent setting invalid RSS hash function
mlx4_en_check_rxfh_func() was checking for hardware support before setting a known RSS hash function, but didn't do any check before setting unknown RSS hash function. Need to make it fail on such values. In this occasion, moved the actual setting of the new value from the check function into mlx4_en_set_rxfh(). Fixes: 947cbb0 ("net/mlx4_en: Support for configurable RSS hash function") Signed-off-by: Amir Vadai --- drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 29 ++--- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c index 3f44e2b..a2ddf3d 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c @@ -1102,20 +1102,21 @@ static int mlx4_en_check_rxfh_func(struct net_device *dev, u8 hfunc) struct mlx4_en_priv *priv = netdev_priv(dev); /* check if requested function is supported by the device */ - if ((hfunc == ETH_RSS_HASH_TOP && -!(priv->mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_RSS_TOP)) || - (hfunc == ETH_RSS_HASH_XOR && -!(priv->mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_RSS_XOR))) - return -EINVAL; + if (hfunc == ETH_RSS_HASH_TOP) { + if (!(priv->mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_RSS_TOP)) + return -EINVAL; + if (!(dev->features & NETIF_F_RXHASH)) + en_warn(priv, "Toeplitz hash function should be used in conjunction with RX hashing for optimal performance\n"); + return 0; + } else if (hfunc == ETH_RSS_HASH_XOR) { + if (!(priv->mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_RSS_XOR)) + return -EINVAL; + if (dev->features & NETIF_F_RXHASH) + en_warn(priv, "Enabling both XOR Hash function and RX Hashing can limit RPS functionality\n"); + return 0; + } - priv->rss_hash_fn = hfunc; - if (hfunc == ETH_RSS_HASH_TOP && !(dev->features & NETIF_F_RXHASH)) - en_warn(priv, - "Toeplitz hash function should be used in conjunction with RX hashing for optimal performance\n"); - if (hfunc == ETH_RSS_HASH_XOR && (dev->features & NETIF_F_RXHASH)) - en_warn(priv, - "Enabling both XOR Hash function and RX Hashing can limit RPS functionality\n"); - return 0; + return -EINVAL; } static int mlx4_en_get_rxfh(struct net_device *dev, u32 *ring_index, u8 *key, @@ -1189,6 +1190,8 @@ static int mlx4_en_set_rxfh(struct net_device *dev, const u32 *ring_index, priv->prof->rss_rings = rss_rings; if (key) memcpy(priv->rss_key, key, MLX4_EN_RSS_KEY_SIZE); + if (hfunc != ETH_RSS_HASH_NO_CHANGE) + priv->rss_hash_fn = hfunc; if (port_up) { err = mlx4_en_start_port(dev); -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH net 0/2] net/ethtool, mlx4_en: RSS hash function setting fixes
Hi Dave, This small patchset fixes a small issue in the ethtool User/kernel API. Hash function is represented as an eight bit field, every bit represents a function. Currently possible values are: 1 for Toeplitz and 2 for XOR. This commit changes the representation from bit flags into a value. Because only one hash function will be used at a time, there is no sense using bit flags for it. Since today only 2 functions are supported, and there is no user space ethtool that supports this feature, we can switch into values without causing any backward compatibility issues. After this patchset is applied, I will send the user space patch. In this occasion I added a missing validation to the hash function value. This patchset was applied and tested over commit 2ea2f62 ("net: fix crash in build_skb()") Please push this patchset to stable 3.19.y in which those two issues were introduced. Thanks, Amir Amir Vadai (2): ethtool: Use values instead of bit flags for RSS hash function net/mlx4_en: Prevent setting invalid RSS hash function drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 29 ++--- include/linux/ethtool.h | 9 ++-- net/core/ethtool.c | 4 ++-- 3 files changed, 20 insertions(+), 22 deletions(-) -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH net 1/2] ethtool: Use values instead of bit flags for RSS hash function
The RX indirection hash function is eight bits. Using more than one hash function doesn't make sense, therefore using this field as a value instead of a bit flag. Moving from bit flags into value shouldn't introduce any backward compatibility issues, since currently there are only 2 functions, therfore the actual value in the field hfunc is the same like before 1 for Toeplitz and 2 for XOR. Fixes: 892311f ("ethtool: Support for configurable RSS hash function") Signed-off-by: Amir Vadai --- include/linux/ethtool.h | 9 ++--- net/core/ethtool.c | 4 ++-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 653dc9c..d19f31a 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -60,8 +60,8 @@ enum ethtool_phys_id_state { }; enum { - ETH_RSS_HASH_TOP_BIT, /* Configurable RSS hash function - Toeplitz */ - ETH_RSS_HASH_XOR_BIT, /* Configurable RSS hash function - Xor */ + ETH_RSS_HASH_TOP = 1, /* Configurable RSS hash function - Toeplitz */ + ETH_RSS_HASH_XOR = 2, /* Configurable RSS hash function - Xor */ /* * Add your fresh new hash function bits above and remember to update @@ -70,11 +70,6 @@ enum { ETH_RSS_HASH_FUNCS_COUNT }; -#define __ETH_RSS_HASH_BIT(bit)((u32)1 << (bit)) -#define __ETH_RSS_HASH(name) __ETH_RSS_HASH_BIT(ETH_RSS_HASH_##name##_BIT) - -#define ETH_RSS_HASH_TOP __ETH_RSS_HASH(TOP) -#define ETH_RSS_HASH_XOR __ETH_RSS_HASH(XOR) #define ETH_RSS_HASH_UNKNOWN 0 #define ETH_RSS_HASH_NO_CHANGE 0 diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 1d00b89..1a1db95 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c @@ -103,8 +103,8 @@ static const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN] static const char rss_hash_func_strings[ETH_RSS_HASH_FUNCS_COUNT][ETH_GSTRING_LEN] = { - [ETH_RSS_HASH_TOP_BIT] ="toeplitz", - [ETH_RSS_HASH_XOR_BIT] ="xor", + [ETH_RSS_HASH_TOP] ="toeplitz", + [ETH_RSS_HASH_XOR] ="xor", }; static int ethtool_get_features(struct net_device *dev, void __user *useraddr) -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 3/4] checkpatch: Fix processing of MEMSET issues
Remove 's' modifier to avoid reporting the same warning several times. Signed-off-by: Mateusz Kulikowski --- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 263e831..c05befe 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5010,7 +5010,7 @@ sub process { # Check for misused memsets if ($^V && $^V ge 5.10.0 && defined $stat && - $stat =~ /^\+(?:.*?)\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*$FuncArg\s*\)/s) { + $stat =~ /^\+(?:.*?)\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*$FuncArg\s*\)/) { my $ms_addr = $2; my $ms_val = $7; -- 1.8.4.1 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 1/4] checkpatch: suggest using ether_addr_equal*()
Check if memcmp() is used to compare ethernet addresses and suggest using ether_addr_equal() or ether_addr_equal_unaligned() Signed-off-by: Mateusz Kulikowski --- scripts/checkpatch.pl | 8 1 file changed, 8 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 89b1df4..0a511b7 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5035,6 +5035,14 @@ sub process { } } +# Check for memcmp(foo, bar, ETH_ALEN) that could be ether_addr_equal*(foo, bar) + if ($^V && $^V ge 5.10.0 && + defined $stat && + $stat =~ /^\+(?:.*?)\bmemcmp\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/) { + WARN("PREFER_ETHER_ADDR_EQUAL", +"Prefer ether_addr_equal() or ether_addr_equal_unaligned() over memcmp()\n" . "$here\n$stat\n") + } + # typecasts on min/max could be min_t/max_t if ($^V && $^V ge 5.10.0 && defined $stat && -- 1.8.4.1 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 4/4] checkpatch: Add multi-line handling for PREFER_ETHER_ADDR_COPY
Handle multi-line memcpy() properly. Signed-off-by: Mateusz Kulikowski --- scripts/checkpatch.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index c05befe..6311950 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5027,9 +5027,10 @@ sub process { # Check for memcpy(foo, bar, ETH_ALEN) that could be ether_addr_copy(foo, bar) if ($^V && $^V ge 5.10.0 && - $line =~ /^\+(?:.*?)\bmemcpy\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/s) { + defined $stat && + $stat =~ /^\+(?:.*?)\bmemcpy\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/) { if (WARN("PREFER_ETHER_ADDR_COPY", -"Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)\n" . $herecurr) && +"Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)\n" . "$here\n$stat\n") && $fix) { $fixed[$fixlinenr] =~ s/\bmemcpy\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/ether_addr_copy($2, $7)/; } -- 1.8.4.1 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 2/4] checkpatch: suggest using eth_zero_addr() and eth_broadcast_addr()
Suggest using eth_zero_addr() or eth_broadcast_addr() instead of memset(). Signed-off-by: Mateusz Kulikowski --- scripts/checkpatch.pl | 23 +++ 1 file changed, 23 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 0a511b7..263e831 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5043,6 +5043,29 @@ sub process { "Prefer ether_addr_equal() or ether_addr_equal_unaligned() over memcmp()\n" . "$here\n$stat\n") } +# check for memset(foo, 0x0, ETH_ALEN) that could be eth_zero_addr +# check for memset(foo, 0xFF, ETH_ALEN) that could be eth_broadcast_addr + if ($^V && $^V ge 5.10.0 && + defined $stat && + $stat =~ /^\+(?:.*?)\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/) { + + my $ms_val = $7; + + if ($ms_val =~ /^(?:0x|)0+$/i) { + if (WARN("PREFER_ETH_ZERO_ADDR", +"Prefer eth_zero_addr over memset()\n" . "$here\n$stat\n") && + $fix) { + $fixed[$fixlinenr] =~ s/\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*,\s*ETH_ALEN\s*\)/eth_zero_addr($2)/; + } + } elsif ($ms_val =~ /^(?:0xff|255)$/i) { + if (WARN("PREFER_ETH_BROADCAST_ADDR", +"Prefer eth_broadcast_addr() over memset()\n" . "$here\n$stat\n") && + $fix) { + $fixed[$fixlinenr] =~ s/\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*,\s*ETH_ALEN\s*\)/eth_broadcast_addr($2)/; + } + } + } + # typecasts on min/max could be min_t/max_t if ($^V && $^V ge 5.10.0 && defined $stat && -- 1.8.4.1 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 0/4] new ethernet address manipulation checks
Changes in v3: - Fixed handling of MEMSET issues (due to '/s' at the end the same error/warning was reported several times) - Added handling of multiline PREFER_ETHER_ADDR_COPY warnings - Review: added --fix option to eth_zero/broadcast_addr checks - All new warnings are multi-line aware (fixes work on single lines only) Changes in v2 (applied review comments): - Fixed indentation in both patches - Detect memset(foo, 0x00, ETH_ALEN) - Detect memset(foo, 255, ETH_ALEN) - Rephrased 2/2 commit message Patch Notes from v1: Add 3 new warnings to checkpatch: 1) PREFER_ETHER_ADDR_EQUAL Replace memcmp(foo, bar, ETH_ALEN) with ether_addr_equal*() 2) PREFER_ETH_ZERO_ADDR Replace memset(foo, 0, ETH_ALEN) with eth_zero_addr() 3) PREFER_ETH_BROADCAST_ADDR Replace memset(foo, 0xFF, ETH_ALEN) with eth_broadcast_addr() Mateusz Kulikowski (4): checkpatch: suggest using ether_addr_equal*() checkpatch: suggest using eth_zero_addr() and eth_broadcast_addr() checkpatch: Fix processing of MEMSET issues checkpatch: Add multi-line handling for PREFER_ETHER_ADDR_COPY scripts/checkpatch.pl | 38 +++--- 1 file changed, 35 insertions(+), 3 deletions(-) -- 1.8.4.1 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH net 0/2] net/ethtool, mlx4_en: RSS hash function setting fixes
On Sun, Apr 26, 2015 at 5:36 PM, Amir Vadai wrote: > Hi Dave, > > This small patchset fixes a small issue in the ethtool User/kernel API. > > Hash function is represented as an eight bit field, every bit represents a > function. Currently possible values are: 1 for Toeplitz and 2 for XOR. > This commit changes the representation from bit flags into a value. Because > only one hash function will be used at a time, there is no sense using bit > flags for it. > Since today only 2 functions are supported, and there is no user space ethtool > that supports this feature, we can switch into values without causing any > backward compatibility issues. > > After this patchset is applied, I will send the user space patch. > > In this occasion I added a missing validation to the hash function value. > > This patchset was applied and tested over commit 2ea2f62 ("net: fix crash in > build_skb()") > > Please push this patchset to stable 3.19.y in which those two issues were > introduced. and 4.0.y too I guess? -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 0/4] new ethernet address manipulation checks
(adding Andrew Morton) On Sun, 2015-04-26 at 18:43 +0200, Mateusz Kulikowski wrote: > Changes in v3: > - Fixed handling of MEMSET issues (due to '/s' at the end the same > error/warning was reported several times) > - Added handling of multiline PREFER_ETHER_ADDR_COPY warnings > - Review: added --fix option to eth_zero/broadcast_addr checks > - All new warnings are multi-line aware (fixes work on single lines only) Acked-by: Joe Perches Thanks Mateusz -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH net-next V7 0/2] openvswitch: Add support for 802.1AD
Add support for 802.1AD to the openvswitch kernel module. Although the Open Flow specification specified support for 802.1AD (qinq) as well as push and pop vlan headers, So far Open vSwitch has only supported a single tag header. This accompanies version 7 of the patch submitted to openvswitch dev list. For discussion, history and previous versions, of the kernel patch, see the OVS dev mailing list, openvswitch.org/pipermail/dev/.. Thomas F Herbert (2): add flow key field for ctag Flow handling, actions, and vlan parsing for 8021AD include/uapi/linux/openvswitch.h | 17 net/openvswitch/actions.c| 6 ++- net/openvswitch/flow.c | 83 +--- net/openvswitch/flow.h | 1 + net/openvswitch/flow_netlink.c | 81 --- 5 files changed, 160 insertions(+), 28 deletions(-) -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH net-next V7 2/2] net: openvswitch: 802.1ad: Flow handling, actions, and vlan parsing
Add support for 802.1ad including the ability to push and pop double tagged vlans. Signed-off-by: Thomas F Herbert --- net/openvswitch/actions.c | 6 ++- net/openvswitch/flow.c | 83 +++--- net/openvswitch/flow.h | 1 + net/openvswitch/flow_netlink.c | 81 ++--- 4 files changed, 151 insertions(+), 20 deletions(-) diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c index b491c1c..0831019 100644 --- a/net/openvswitch/actions.c +++ b/net/openvswitch/actions.c @@ -219,7 +219,8 @@ static int pop_vlan(struct sk_buff *skb, struct sw_flow_key *key) int err; err = skb_vlan_pop(skb); - if (skb_vlan_tag_present(skb)) + if (skb_vlan_tag_present(skb) && + skb->protocol != htons(ETH_P_8021Q)) invalidate_flow_key(key); else key->eth.tci = 0; @@ -229,7 +230,8 @@ static int pop_vlan(struct sk_buff *skb, struct sw_flow_key *key) static int push_vlan(struct sk_buff *skb, struct sw_flow_key *key, const struct ovs_action_push_vlan *vlan) { - if (skb_vlan_tag_present(skb)) + if (skb_vlan_tag_present(skb) && + skb->protocol != htons(ETH_P_8021Q)) invalidate_flow_key(key); else key->eth.tci = vlan->vlan_tci; diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c index 2dacc7b..6989451 100644 --- a/net/openvswitch/flow.c +++ b/net/openvswitch/flow.c @@ -298,21 +298,78 @@ static bool icmp6hdr_ok(struct sk_buff *skb) static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key) { struct qtag_prefix { - __be16 eth_type; /* ETH_P_8021Q */ + __be16 eth_type; /* ETH_P_8021Q or ETH_P_8021AD */ __be16 tci; }; - struct qtag_prefix *qp; + struct qtag_prefix *qp = (struct qtag_prefix *) skb->data; - if (unlikely(skb->len < sizeof(struct qtag_prefix) + sizeof(__be16))) - return 0; + struct qinqtag_prefix { + __be16 eth_type; /* ETH_P_8021Q or ETH_P_8021AD */ + __be16 tci; + __be16 inner_tpid; /* ETH_P_8021Q */ + __be16 ctci; + }; + + if (likely(skb_vlan_tag_present(skb))) { + + key->eth.tci = htons(skb->vlan_tci); + + /* +* Case where upstream +* processing has already stripped the outer vlan tag. +*/ + if (unlikely(skb->vlan_proto == htons(ETH_P_8021AD))) { + + if (unlikely(skb->len < sizeof(struct qtag_prefix) + + sizeof(__be16))) + return 0; + + if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) + + sizeof(__be16 { + return -ENOMEM; + } + + if (likely(qp->eth_type == htons(ETH_P_8021Q))) { + key->eth.ctci = qp->tci | htons(VLAN_TAG_PRESENT); + __skb_pull(skb, sizeof(struct qtag_prefix)); + } + } +return 0; + } - if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) + -sizeof(__be16 - return -ENOMEM; - qp = (struct qtag_prefix *) skb->data; - key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT); - __skb_pull(skb, sizeof(struct qtag_prefix)); +if (qp->eth_type == htons(ETH_P_8021AD)) { + struct qinqtag_prefix *qinqp = (struct qinqtag_prefix *) skb->data; + + if (unlikely(skb->len < sizeof(struct qinqtag_prefix) + + sizeof(__be16))) + return 0; + + if (unlikely(!pskb_may_pull(skb, sizeof(struct qinqtag_prefix) + + sizeof(__be16 { + return -ENOMEM; + } + key->eth.tci = qinqp->tci | htons(VLAN_TAG_PRESENT); + key->eth.ctci = qinqp->ctci | htons(VLAN_TAG_PRESENT); + + __skb_pull(skb, sizeof(struct qinqtag_prefix)); + +return 0; + + } +if (qp->eth_type == htons(ETH_P_8021Q)) { + + if (unlikely(skb->len < sizeof(struct qtag_prefix) + + sizeof(__be16))) + return -ENOMEM; + + if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) + + sizeof(__be16 + return 0; + key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT); + + __skb_pull(skb, sizeof(struct qtag_prefix)); + } return 0; } @@ -474,9 +531,9 @@ static int key_extract(struct sk_buff
[PATCH net-next V7 1/2] net: openvswitch: 802.1ad uapi changes.
openvswitch: Add support for 8021.AD Change the description of the VLAN tpid field. Signed-off-by: Thomas F Herbert --- include/uapi/linux/openvswitch.h | 17 + 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h index bbd49a0..f2ccdef 100644 --- a/include/uapi/linux/openvswitch.h +++ b/include/uapi/linux/openvswitch.h @@ -559,13 +559,13 @@ struct ovs_action_push_mpls { * @vlan_tci: Tag control identifier (TCI) to push. The CFI bit must be set * (but it will not be set in the 802.1Q header that is pushed). * - * The @vlan_tpid value is typically %ETH_P_8021Q. The only acceptable TPID - * values are those that the kernel module also parses as 802.1Q headers, to - * prevent %OVS_ACTION_ATTR_PUSH_VLAN followed by %OVS_ACTION_ATTR_POP_VLAN - * from having surprising results. + * The @vlan_tpid value is typically %ETH_P_8021Q or %ETH_P_8021AD. + * The only acceptable TPID values are those that the kernel module also parses + * as 802.1Q or 802.1AD headers, to prevent %OVS_ACTION_ATTR_PUSH_VLAN followed + * by %OVS_ACTION_ATTR_POP_VLAN from having surprising results. */ struct ovs_action_push_vlan { - __be16 vlan_tpid; /* 802.1Q TPID. */ + __be16 vlan_tpid; /* 802.1Q or 802.1ad TPID. */ __be16 vlan_tci;/* 802.1Q TCI (VLAN ID and priority). */ }; @@ -605,9 +605,10 @@ struct ovs_action_hash { * is copied from the value to the packet header field, rest of the bits are * left unchanged. The non-masked value bits must be passed in as zeroes. * Masking is not supported for the %OVS_KEY_ATTR_TUNNEL attribute. - * @OVS_ACTION_ATTR_PUSH_VLAN: Push a new outermost 802.1Q header onto the - * packet. - * @OVS_ACTION_ATTR_POP_VLAN: Pop the outermost 802.1Q header off the packet. + * @OVS_ACTION_ATTR_PUSH_VLAN: Push a new outermost 802.1Q or 802.1ad header + * onto the packet. + * @OVS_ACTION_ATTR_POP_VLAN: Pop the outermost 802.1Q or 802.1ad header + * from the packet. * @OVS_ACTION_ATTR_SAMPLE: Probabilitically executes actions, as specified in * the nested %OVS_SAMPLE_ATTR_* attributes. * @OVS_ACTION_ATTR_PUSH_MPLS: Push a new MPLS label stack entry onto the -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] Bluetooth: Skip the shutdown routine if the interface is not up
Most likely, the shutdown routine requires the interface to be up. This is the case for BTUSB_INTEL: the routine tries to send a command to the interface, but since this one is down, it fails and exits once HCI_INIT_TIMEOUT has expired. Signed-off-by: Gabriele Mazzotta --- net/bluetooth/hci_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 476709b..4663c3d 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1557,7 +1557,8 @@ static int hci_dev_do_close(struct hci_dev *hdev) { BT_DBG("%s %p", hdev->name, hdev); - if (!hci_dev_test_flag(hdev, HCI_UNREGISTER)) { + if (!hci_dev_test_flag(hdev, HCI_UNREGISTER) && + test_bit(HCI_UP, &hdev->flags)) { /* Execute vendor specific shutdown routine */ if (hdev->shutdown) hdev->shutdown(hdev); -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2] ppp: mppe: sanity error path rework
We are going to need sanity error path a little further, rework to be able to use the sanity error path anywhere in decompressor. Signed-off-by: Sylvain Rochet --- drivers/net/ppp/ppp_mppe.c | 29 + 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/net/ppp/ppp_mppe.c b/drivers/net/ppp/ppp_mppe.c index 911b216..692ee0f 100644 --- a/drivers/net/ppp/ppp_mppe.c +++ b/drivers/net/ppp/ppp_mppe.c @@ -478,7 +478,6 @@ mppe_decompress(void *arg, unsigned char *ibuf, int isize, unsigned char *obuf, struct blkcipher_desc desc = { .tfm = state->arc4 }; unsigned ccount; int flushed = MPPE_BITS(ibuf) & MPPE_BIT_FLUSHED; - int sanity = 0; struct scatterlist sg_in[1], sg_out[1]; if (isize <= PPP_HDRLEN + MPPE_OVHD) { @@ -514,31 +513,19 @@ mppe_decompress(void *arg, unsigned char *ibuf, int isize, unsigned char *obuf, "mppe_decompress[%d]: ENCRYPTED bit not set!\n", state->unit); state->sanity_errors += 100; - sanity = 1; + goto sanity_error; } if (!state->stateful && !flushed) { printk(KERN_DEBUG "mppe_decompress[%d]: FLUSHED bit not set in " "stateless mode!\n", state->unit); state->sanity_errors += 100; - sanity = 1; + goto sanity_error; } if (state->stateful && ((ccount & 0xff) == 0xff) && !flushed) { printk(KERN_DEBUG "mppe_decompress[%d]: FLUSHED bit not set on " "flag packet!\n", state->unit); state->sanity_errors += 100; - sanity = 1; - } - - if (sanity) { - if (state->sanity_errors < SANITY_MAX) - return DECOMP_ERROR; - else - /* -* Take LCP down if the peer is sending too many bogons. -* We don't want to do this for a single or just a few -* instances since it could just be due to packet corruption. -*/ - return DECOMP_FATALERROR; + goto sanity_error; } /* @@ -649,6 +636,16 @@ mppe_decompress(void *arg, unsigned char *ibuf, int isize, unsigned char *obuf, state->sanity_errors >>= 1; return osize; + +sanity_error: + if (state->sanity_errors < SANITY_MAX) + return DECOMP_ERROR; + else + /* Take LCP down if the peer is sending too many bogons. +* We don't want to do this for a single or just a few +* instances since it could just be due to packet corruption. +*/ + return DECOMP_FATALERROR; } /* -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2] ppp: mppe: discard late packet in stateless mode
When PPP is used over a link which does not guarantee packet ordering, we might get late MPPE packets. This is a problem because MPPE must be kept synchronized and the current implementation does not drop them and rekey 4095 times instead of 0, which is wrong. In order to prevent rekeying about a whole count space times (~ 4095 times), drop packets which are not within the forward 4096/2 window and increase sanity error counter. Signed-off-by: Sylvain Rochet --- drivers/net/ppp/ppp_mppe.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/ppp/ppp_mppe.c b/drivers/net/ppp/ppp_mppe.c index 692ee0f..05005c6 100644 --- a/drivers/net/ppp/ppp_mppe.c +++ b/drivers/net/ppp/ppp_mppe.c @@ -533,6 +533,13 @@ mppe_decompress(void *arg, unsigned char *ibuf, int isize, unsigned char *obuf, */ if (!state->stateful) { + /* Discard late packet */ + if ((ccount - state->ccount) % MPPE_CCOUNT_SPACE + > MPPE_CCOUNT_SPACE / 2) { + state->sanity_errors++; + goto sanity_error; + } + /* RFC 3078, sec 8.1. Rekey for every packet. */ while (state->ccount != ccount) { mppe_rekey(state, 0); -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/2] ppp: mppe: fixes MPPE desync on links which don't guarantee packet ordering
I am currently having an issue with PPP over L2TP (UDP) and MPPE in stateless mode (default mode), UDP does not guarantee packet ordering so we might get out of order packet. MPPE needs to be continuously synched so we should drop late UDP packet. I added a printk on the number of time we rekeyed in MPPE decompressor, this is what we currently have if we receive a slightly out of order UDP packet: [1731001.049206] mppe_decompress[1]: ccount 1559 [1731001.049216] mppe_decompress[1]: rekeyed 1 times [1731001.049228] mppe_decompress[1]: ccount 1560 [1731001.049232] mppe_decompress[1]: rekeyed 1 times [1731001.050170] mppe_decompress[1]: ccount 1562 [1731001.050182] mppe_decompress[1]: rekeyed 2 times [1731001.050191] mppe_decompress[1]: ccount 1561 [1731001.062576] mppe_decompress[1]: rekeyed 4095 times This is obviously wrong, we missed packet 1561 and we already rekeyed 2 times for 1562 we previously received, we can't recover the decryption key we need for 1561, we should drop it instead of rekeying 4095 times. This patch series drop any packet with are not within the 4096/2 forward window. Sylvain Rochet (2): ppp: mppe: sanity error path rework ppp: mppe: discard late packet in stateless mode drivers/net/ppp/ppp_mppe.c | 36 1 file changed, 20 insertions(+), 16 deletions(-) -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch net-next v4 RFC 00/15] introduce programable flow dissector and cls_flower
On Fri, Apr 24, 2015 at 6:51 PM, Jiri Pirko wrote: > Per Davem's request, I prepared this patchset which introduces programmable > flow dissector. For current users of flow_keys, there is a wrapper > skb_flow_dissect_flow_keys which maintains the previous behaviour. > For purposes of cls_flower, couple of new dissection keys were introduced. > > Note that this dissector can be also eventually used by openvswitch code. Hi Jiri, >From the subject line I conclude that this is the fifth version (V4), could you please point on the previous four (V0-3) posts? Or. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch net-next v4 RFC 00/15] introduce programable flow dissector and cls_flower
On Sun, Apr 26, 2015 at 10:55 PM, Or Gerlitz wrote: > On Fri, Apr 24, 2015 at 6:51 PM, Jiri Pirko wrote: >> Per Davem's request, I prepared this patchset which introduces programmable >> flow dissector. For current users of flow_keys, there is a wrapper >> skb_flow_dissect_flow_keys which maintains the previous behaviour. >> For purposes of cls_flower, couple of new dissection keys were introduced. > From the subject line I conclude that this is the fifth version (V4), > could you please point on the previous four (V0-3) posts? mmm, I see v3 now, it's just a single-patch sized series, which is what confused me (and we start to count from zero... for next time) Or. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH net-next v7] Add support of Cavium Liquidio ethernet adapters
From: Raghu Vatsavayi Date: Fri, 24 Apr 2015 17:34:16 -0700 > Following patch adds support for Cavium Liquidio ethernet adapter. > LiquidIO adapters are pci express based 10Gig server adapters. > > This patch v7 has changes based on the feedback from earlier patches: > > 1) Minor comments from v6 release regarding debug statements. > 2) Fix for large multicast lists. > 3) Fixed lockup issue if port initialization fails. > 4) Enabled MSI by default. > > Signed-off-by: Derek Chickles > Signed-off-by: Satanand Burla > Signed-off-by: Felix Manlunas > Signed-off-by: Raghu Vatsavayi It is extremely disappointing that you've defined your own debug logging macros, which use generic dev_*() printks, instead of using the proper netdev_*() printk logging interfaces to do this. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] pxa168: fix double deallocation of managed resources
From: Alexey Khoroshilov Date: Sat, 25 Apr 2015 04:07:03 +0300 > Commit 43d3ddf87a57 ("net: pxa168_eth: add device tree support") starts > to use managed resources by adding devm_clk_get() and > devm_ioremap_resource(), but it leaves explicit iounmap() and clock_put() > in pxa168_eth_remove() and in failure handling code of pxa168_eth_probe(). > As a result double free can happen. > > The patch removes explicit resource deallocation. Also it converts > clk_disable() to clk_disable_unprepare() to make it symmetrical with > clk_prepare_enable(). > > Found by Linux Driver Verification project (linuxtesting.org). > > Signed-off-by: Alexey Khoroshilov Applied and queued up for -stable, thanks. I find this patch _extremely_ amusing, as it shows that that these managed interfaces can be just as error prone to use as the non-managed ones. :-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3] altera tse: add support for fixed-links.
From: Andreas Oetken Date: Sat, 25 Apr 2015 18:07:52 +0200 > From: Andreas Oetken > > Add support for fixed-links in configurations without PHY. > (e.g. connection to a switch, SGMII point to point, SFPs) > > Check: Documentation/devicetree/bindings/net/fixed-link.txt. > Signed-off-by: Andreas Oetken Applied. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH net] net: rfs: fix crash in get_rps_cpus()
From: Eric Dumazet Date: Sat, 25 Apr 2015 09:35:24 -0700 > From: Eric Dumazet > > Commit 567e4b79731c ("net: rfs: add hash collision detection") had one > mistake : > > RPS_NO_CPU is no longer the marker for invalid cpu in set_rps_cpu() > and get_rps_cpu(), as @next_cpu was the result of an AND with > rps_cpu_mask > > This bug showed up on a host with 72 cpus : > next_cpu was 0x7f, and the code was trying to access percpu data of an > non existent cpu. > > In a follow up patch, we might get rid of compares against nr_cpu_ids, > if we init the tables with 0. This is silly to test for a very unlikely > condition that exists only shortly after table initialization, as > we got rid of rps_reset_sock_flow() and similar functions that were > writing this RPS_NO_CPU magic value at flow dismantle : When table is > old enough, it never contains this value anymore. > > Fixes: 567e4b79731c ("net: rfs: add hash collision detection") > Signed-off-by: Eric Dumazet > Cc: Tom Herbert > Cc: Ben Hutchings Applied and queued up for 4.0-stable, thanks Eric. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch net-next v4 RFC 00/15] introduce programable flow dissector and cls_flower
On Fri, Apr 24, 2015 at 8:51 AM, Jiri Pirko wrote: > Per Davem's request, I prepared this patchset which introduces programmable > flow dissector. For current users of flow_keys, there is a wrapper > skb_flow_dissect_flow_keys which maintains the previous behaviour. > For purposes of cls_flower, couple of new dissection keys were introduced. > > Note that this dissector can be also eventually used by openvswitch code. > > Also, I plan to get rid of *skb_flow_get_ports(export) and *__skb_get_poff as > their functionality can be now implemented by skb_flow_dissect as well. > > Ideas, comments? > HI Jiri, Looking a little more closely at your patches I'm not convinced this complexity is justified; it seems like this is moving flow_dissector to be more of a general packet parser rather than adhering to its original prinicples which was to extract just enough information from packet to create a good hash for the packet's flow. For improving packet hashing, I would rather judiciously extend the flow_keys structure to include full IPv6 address, add a *few* other fields such as VLAN and flow label, and then hash over the the whole structure especially eliminating use of xor which doesn't do squat in making a DOS resilient hash. We are potentially calling flow_dissector on every RX packets, and many TX packets via skb_hash-- this needs to be simple and efficient. Also, making something like IP address and ports optional to return doesn't seem like a lot of value to me-- why not just always return it to the caller in flow_keys and they can ignore any fields they want-- adding conditionals for IP address and ports inclusion will only slow down the common critical path use case. I imagine programmatic packet parser might have some interesting use cases, but maybe this should be spun off as a separate function. If we did that then the output wouldn't need to be limited to just the restricted flow identification fields, but could include whatever else in a packet might be interesting-- TOS, TTL, TCP flags, both inner and outer addresses, etc. btw, can you please split the cosmetic changes and material changes into two patch sets, this will make reviewing them a lot easier! Thanks, Tom > Jiri Pirko (15): > net: change name of flow_dissector header to match the .c file name > flow_dissector: remove unused function flow_get_hlen declaration > net: move *skb_get_poff declarations into correct header > flow_dissector: fix doc for __skb_get_hash and remove couple of empty > lines > net: move __skb_get_hash function declaration to flow_dissector.h > net: move __skb_tx_hash to skbuff.c > net: move netdev_pick_tx and dependencies to net/core/dev.c > flow_dissector: fix doc for skb_get_poff > flow_dissector: introduce programable flow_dissector > flow_dissect: use programable dissector in skb_flow_dissect and > friends > flow_dissector: add missing header includes > flow_dissector: introduce support for ipv6 addressses > flow_dissector: introduce support for Ethernet addresses > flow_dissector: change port array into src,dst tuple > tc: introduce Flower classifier > > drivers/net/bonding/bond_main.c| 20 +- > drivers/net/ethernet/cisco/enic/enic_clsf.c| 29 +- > drivers/net/ethernet/cisco/enic/enic_ethtool.c | 10 +- > drivers/net/hyperv/netvsc_drv.c| 8 +- > include/linux/skbuff.h | 11 +- > include/net/flow_dissector.h | 152 ++ > include/net/flow_keys.h| 45 -- > include/net/ip.h | 10 +- > include/net/ipv6.h | 10 +- > include/uapi/linux/pkt_cls.h | 31 ++ > net/core/dev.c | 78 +++ > net/core/filter.c | 1 + > net/core/flow_dissector.c | 376 -- > net/core/skbuff.c | 28 + > net/ethernet/eth.c | 7 +- > net/sched/Kconfig | 10 + > net/sched/Makefile | 1 + > net/sched/cls_flow.c | 22 +- > net/sched/cls_flower.c | 688 > + > net/sched/sch_choke.c | 6 +- > net/sched/sch_fq_codel.c | 10 +- > net/sched/sch_hhf.c| 10 +- > net/sched/sch_sfb.c| 22 +- > net/sched/sch_sfq.c| 10 +- > 24 files changed, 1292 insertions(+), 303 deletions(-) > create mode 100644 include/net/flow_dissector.h > delete mode 100644 include/net/flow_keys.h > create mode 100644 net/sched/cls_flower.c > > -- > 1.9.3 > > -- > To unsubscribe from this list: send the line "unsubscribe netdev" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majord
Re: [PATCH] ehea: Fix memory hook reference counting crashes
On Sat, 2015-04-25 at 14:43 -0400, David Miller wrote: > From: Michael Ellerman > Date: Fri, 24 Apr 2015 15:52:32 +1000 > > > The recent commit to only register the EHEA memory hotplug hooks on > > adapter probe has a few problems. > > > > Firstly the reference counting is wrong for multiple adapters, in that > > the hooks are registered multiple times. Secondly the check in the tear > > down path is backward. Finally the error path doesn't decrement the > > count. > > > > The multiple registration of the hooks is the biggest problem, as it > > leads to oopses when the system is rebooted, and/or errors during memory > > hotplug, eg: > ... > > Fixes: aa183323312d ("ehea: Register memory hotplug, reboot and crash hooks > > on adapter probe") > > Signed-off-by: Michael Ellerman > > Applied, but using an atomic counter for this is really inappropriate > and is what lead to this bug in the first place. > > You're not counting anything, because if you were, then you would be > decrementing this thing somewhere. > > Rather, it's purely a boolean state saying "I did X". So it should be > a boolean, and no atomicity nor other special considerations are > needed for setting it to true. Yeah I agree, it's a mess. We should be unregistering the hooks when the last adapter is removed, which is where we'd do the decrement. As it's written the hooks stay registered until the driver is removed. I'll try and find time, or someone else with time, to fix it up properly for 4.2. cheers -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH net-next 0/6] ipv6: netfilter - coding style improvements
On Sat, Apr 25, 2015 at 10:26:54AM +0100, Ian Morris wrote: > This series of patches removes some style issues in the ipv6 netfilter > code detected by checkpatch. There is no change to functionality and > no changes to the resultant object determined by objdiff. Please, Cc: netfilter-de...@vger.kernel.org for netfilter updates, thanks. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH net] net/bonding: Make DRV macros private
From: Or Gerlitz Date: Sun, 26 Apr 2015 15:55:57 +0300 > From: Matan Barak > > The bonding modules currently defines four macros with > general names that pollute the global namespace: > DRV_VERSION > DRV_RELDATE > DRV_NAME > DRV_DESCRIPTION > > Fixing that by defining a private bonding_priv.h > header files which includes those defines. > > Signed-off-by: Matan Barak > Signed-off-by: Or Gerlitz Applied, thanks. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 02/10] slab: add SLIB (Library memory allocator) for arch/lib
add SLIB allocator for arch/lib (CONFIG_LIB) to wrap kmalloc and co. This will bring user's own allocator of libos: malloc(3) etc. Signed-off-by: Hajime Tazaki --- include/linux/slab.h | 6 +- include/linux/slib_def.h | 21 + mm/Makefile | 1 + mm/slab.h| 4 + mm/slib.c| 205 +++ 5 files changed, 236 insertions(+), 1 deletion(-) create mode 100644 include/linux/slib_def.h create mode 100644 mm/slib.c diff --git a/include/linux/slab.h b/include/linux/slab.h index ffd24c8..0288cf8 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -191,7 +191,7 @@ size_t ksize(const void *); #endif #endif -#ifdef CONFIG_SLOB +#if defined(CONFIG_SLOB) || defined(CONFIG_SLIB) /* * SLOB passes all requests larger than one page to the page allocator. * No kmalloc array is necessary since objects of different sizes can @@ -356,6 +356,9 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order) } #endif +#ifdef CONFIG_SLIB +#include +#else static __always_inline void *kmalloc_large(size_t size, gfp_t flags) { unsigned int order = get_order(size); @@ -434,6 +437,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags) } return __kmalloc(size, flags); } +#endif /* CONFIG_SLIB */ /* * Determine size used for the nth kmalloc cache. diff --git a/include/linux/slib_def.h b/include/linux/slib_def.h new file mode 100644 index 000..d9fe7d5 --- /dev/null +++ b/include/linux/slib_def.h @@ -0,0 +1,21 @@ +#ifndef _LINUX_SLLB_DEF_H +#define _LINUX_SLLB_DEF_H + + +struct kmem_cache { + unsigned int object_size; + const char *name; + size_t size; + size_t align; + unsigned long flags; + void (*ctor)(void *); +}; + +void *__kmalloc(size_t size, gfp_t flags); +void *kmem_cache_alloc(struct kmem_cache *, gfp_t); +static __always_inline void *kmalloc(size_t size, gfp_t flags) +{ + return __kmalloc(size, flags); +} + +#endif /* _LINUX_SLLB_DEF_H */ diff --git a/mm/Makefile b/mm/Makefile index 98c4eae..7d8314f 100644 --- a/mm/Makefile +++ b/mm/Makefile @@ -46,6 +46,7 @@ obj-$(CONFIG_NUMA)+= mempolicy.o obj-$(CONFIG_SPARSEMEM)+= sparse.o obj-$(CONFIG_SPARSEMEM_VMEMMAP) += sparse-vmemmap.o obj-$(CONFIG_SLOB) += slob.o +obj-$(CONFIG_SLIB) += slib.o obj-$(CONFIG_MMU_NOTIFIER) += mmu_notifier.o obj-$(CONFIG_KSM) += ksm.o obj-$(CONFIG_PAGE_POISONING) += debug-pagealloc.o diff --git a/mm/slab.h b/mm/slab.h index 4c3ac12..2ea37c9 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -37,6 +37,10 @@ struct kmem_cache { #include #endif +#ifdef CONFIG_SLIB +#include +#endif + #include /* diff --git a/mm/slib.c b/mm/slib.c new file mode 100644 index 000..37596862 --- /dev/null +++ b/mm/slib.c @@ -0,0 +1,205 @@ +/* + * Library Slab Allocator (SLIB) + * + * Copyright (c) 2015 INRIA, Hajime Tazaki + * + * Author: Mathieu Lacage + * Hajime Tazaki + */ + +#include "sim.h" +#include "sim-assert.h" +#include +#include +#include +#include + +/* glues */ +struct kmem_cache *files_cachep; + +void kfree(const void *p) +{ + unsigned long start; + + if (p == 0) + return; + start = (unsigned long)p; + start -= sizeof(size_t); + lib_free((void *)start); +} +size_t ksize(const void *p) +{ + size_t *psize = (size_t *)p; + + psize--; + return *psize; +} +void *__kmalloc(size_t size, gfp_t flags) +{ + void *p = lib_malloc(size + sizeof(size)); + unsigned long start; + + if (!p) + return NULL; + + if (p != 0 && (flags & __GFP_ZERO)) + lib_memset(p, 0, size + sizeof(size)); + lib_memcpy(p, &size, sizeof(size)); + start = (unsigned long)p; + return (void *)(start + sizeof(size)); +} + +void *__kmalloc_track_caller(size_t size, gfp_t flags, unsigned long caller) +{ + return kmalloc(size, flags); +} + +void *krealloc(const void *p, size_t new_size, gfp_t flags) +{ + void *ret; + + if (!new_size) { + kfree(p); + return ZERO_SIZE_PTR; + } + + ret = __kmalloc(new_size, flags); + if (ret && p != ret) + kfree(p); + + return ret; +} + +struct kmem_cache * +kmem_cache_create(const char *name, size_t size, size_t align, + unsigned long flags, void (*ctor)(void *)) +{ + struct kmem_cache *cache = kmalloc(sizeof(struct kmem_cache), flags); + + if (!cache) + return NULL; + cache->name = name; + cache->size = size; + cache->align = align; + cache->flags = flags; + cache->ctor = ctor; + return cache; +} +void kmem_cache_destroy(struct kmem_cache *cache) +{ + kfree(cache); +} +int kmem_cache_shrink(struct kmem_cache *cache) +{ + return 1; +} +const char *kmem_cache_name(struct kmem_cache *cache) +{ + return cache->name; +} +voi
Re: [PATCH net 0/2] net/ethtool, mlx4_en: RSS hash function setting fixes
From: Amir Vadai Date: Sun, 26 Apr 2015 17:36:04 +0300 > Hash function is represented as an eight bit field, every bit represents a > function. Currently possible values are: 1 for Toeplitz and 2 for XOR. > This commit changes the representation from bit flags into a value. Because > only one hash function will be used at a time, there is no sense using bit > flags for it. If we ever want to add some kind of control attributes that might apply to any hash, we'll want flags again. You can just enforce that only one of these hash function bits can be set at one time, and be done with it. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 06/10] lib: sysctl handling (kernel glue code)
This interacts with fs/proc_fs.c for sysctl-like interface registed via lib_init() API. Signed-off-by: Hajime Tazaki --- arch/lib/sysctl.c | 270 ++ 1 file changed, 270 insertions(+) create mode 100644 arch/lib/sysctl.c diff --git a/arch/lib/sysctl.c b/arch/lib/sysctl.c new file mode 100644 index 000..5f08f9f --- /dev/null +++ b/arch/lib/sysctl.c @@ -0,0 +1,270 @@ +/* + * sysctl wrapper for library version of Linux kernel + * Copyright (c) 2015 INRIA, Hajime Tazaki + * + * Author: Mathieu Lacage + * Hajime Tazaki + */ + +#include +#include +#include +#include +#include +#include "sim-assert.h" +#include "sim-types.h" + +int drop_caches_sysctl_handler(struct ctl_table *table, int write, + void *buffer, size_t *length, loff_t *ppos) +{ + lib_assert(false); + return 0; +} +int lowmem_reserve_ratio_sysctl_handler(struct ctl_table *table, int write, + void *buffer, size_t *length, + loff_t *ppos) +{ + lib_assert(false); + return 0; +} +int min_free_kbytes_sysctl_handler(struct ctl_table *table, int write, + void *buffer, size_t *length, loff_t *ppos) +{ + lib_assert(false); + return 0; +} + +int percpu_pagelist_fraction_sysctl_handler(struct ctl_table *table, int write, + void *buffer, size_t *length, + loff_t *ppos) +{ + lib_assert(false); + return 0; +} +int dirty_background_ratio_handler(struct ctl_table *table, int write, + void *buffer, size_t *lenp, + loff_t *ppos) +{ + lib_assert(false); + return 0; +} +int dirty_background_bytes_handler(struct ctl_table *table, int write, + void *buffer, size_t *lenp, + loff_t *ppos) +{ + lib_assert(false); + return 0; +} +int dirty_ratio_handler(struct ctl_table *table, int write, + void *buffer, size_t *lenp, + loff_t *ppos) +{ + lib_assert(false); + return 0; +} +int dirty_bytes_handler(struct ctl_table *table, int write, + void *buffer, size_t *lenp, + loff_t *ppos) +{ + lib_assert(false); + return 0; +} +int dirty_writeback_centisecs_handler(struct ctl_table *table, int write, + void *buffer, size_t *length, + loff_t *ppos) +{ + lib_assert(false); + return 0; +} +int scan_unevictable_handler(struct ctl_table *table, int write, +void __user *buffer, +size_t *length, loff_t *ppos) +{ + lib_assert(false); + return 0; +} +int sched_rt_handler(struct ctl_table *table, int write, +void __user *buffer, size_t *lenp, +loff_t *ppos) +{ + lib_assert(false); + return 0; +} + +int sysctl_overcommit_memory = OVERCOMMIT_GUESS; +int sysctl_overcommit_ratio = 50; +int sysctl_panic_on_oom = 0; +int sysctl_oom_dump_tasks = 0; +int sysctl_oom_kill_allocating_task = 0; +int sysctl_nr_trim_pages = 0; +int sysctl_drop_caches = 0; +int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES - 1] = { 32 }; +unsigned int sysctl_sched_child_runs_first = 0; +unsigned int sysctl_sched_compat_yield = 0; +unsigned int sysctl_sched_rt_period = 100; +int sysctl_sched_rt_runtime = 95; + +int vm_highmem_is_dirtyable; +unsigned long vm_dirty_bytes = 0; +int vm_dirty_ratio = 20; +int dirty_background_ratio = 10; +unsigned int dirty_expire_interval = 30 * 100; +unsigned int dirty_writeback_interval = 5 * 100; +unsigned long dirty_background_bytes = 0; +int percpu_pagelist_fraction = 0; +int panic_timeout = 0; +int panic_on_oops = 0; +int printk_delay_msec = 0; +int panic_on_warn = 0; +DEFINE_RATELIMIT_STATE(printk_ratelimit_state, 5 * HZ, 10); + +#define RESERVED_PIDS 300 +int pid_max = PID_MAX_DEFAULT; +int pid_max_min = RESERVED_PIDS + 1; +int pid_max_max = PID_MAX_LIMIT; +int min_free_kbytes = 1024; +int max_threads = 100; +int laptop_mode = 0; + +#define DEFAULT_MESSAGE_LOGLEVEL 4 +#define MINIMUM_CONSOLE_LOGLEVEL 1 +#define DEFAULT_CONSOLE_LOGLEVEL 7 +int console_printk[4] = { + DEFAULT_CONSOLE_LOGLEVEL, /* console_loglevel */ + DEFAULT_MESSAGE_LOGLEVEL, /* default_message_loglevel */ + MINIMUM_CONSOLE_LOGLEVEL, /* minimum_console_loglevel */ + DEFAULT_CONSOLE_LOGLEVEL, /* default_console_loglevel */ +}; + +int print_fatal_signals = 0; +unsigned int core_pipe_limit = 0; +int core_uses_pid = 0; +int vm_swappiness = 60; +int nr_pdflush_threads = 0; +unsigned long scan_unevictable_pages = 0; +int suid_dumpable = 0; +int page_cluster = 0; +int block_dump = 0
[PATCH v4 07/10] lib: other kernel glue layer code
These files are used to provide the same function calls so that other network stack code keeps untouched. Signed-off-by: Hajime Tazaki Signed-off-by: Christoph Paasch --- arch/lib/capability.c | 25 + arch/lib/filemap.c| 32 ++ arch/lib/fs.c | 70 arch/lib/glue.c | 289 ++ arch/lib/modules.c| 36 +++ arch/lib/pid.c| 29 + arch/lib/print.c | 56 ++ arch/lib/proc.c | 34 ++ arch/lib/random.c | 53 + arch/lib/sysfs.c | 83 +++ arch/lib/vmscan.c | 26 + 11 files changed, 733 insertions(+) create mode 100644 arch/lib/capability.c create mode 100644 arch/lib/filemap.c create mode 100644 arch/lib/fs.c create mode 100644 arch/lib/glue.c create mode 100644 arch/lib/modules.c create mode 100644 arch/lib/pid.c create mode 100644 arch/lib/print.c create mode 100644 arch/lib/proc.c create mode 100644 arch/lib/random.c create mode 100644 arch/lib/sysfs.c create mode 100644 arch/lib/vmscan.c diff --git a/arch/lib/capability.c b/arch/lib/capability.c new file mode 100644 index 000..3a1f301 --- /dev/null +++ b/arch/lib/capability.c @@ -0,0 +1,25 @@ +/* + * glue code for library version of Linux kernel + * Copyright (c) 2015 INRIA, Hajime Tazaki + * + * Author: Mathieu Lacage + * Hajime Tazaki + */ + +#include "linux/capability.h" + +struct sock; +struct sk_buff; + +int file_caps_enabled = 0; + +int cap_netlink_send(struct sock *sk, struct sk_buff *skb) +{ + return 0; +} + +bool file_ns_capable(const struct file *file, struct user_namespace *ns, +int cap) +{ + return true; +} diff --git a/arch/lib/filemap.c b/arch/lib/filemap.c new file mode 100644 index 000..ce424ff --- /dev/null +++ b/arch/lib/filemap.c @@ -0,0 +1,32 @@ +/* + * glue code for library version of Linux kernel + * Copyright (c) 2015 INRIA, Hajime Tazaki + * + * Author: Mathieu Lacage + * Hajime Tazaki + * Frederic Urbani + */ + +#include "sim.h" +#include "sim-assert.h" +#include + + +ssize_t generic_file_aio_read(struct kiocb *a, const struct iovec *b, + unsigned long c, loff_t d) +{ + lib_assert(false); + + return 0; +} + +int generic_file_readonly_mmap(struct file *file, struct vm_area_struct *vma) +{ + return -ENOSYS; +} + +ssize_t +generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter) +{ + return 0; +} diff --git a/arch/lib/fs.c b/arch/lib/fs.c new file mode 100644 index 000..324e10b --- /dev/null +++ b/arch/lib/fs.c @@ -0,0 +1,70 @@ +/* + * glue code for library version of Linux kernel + * Copyright (c) 2015 INRIA, Hajime Tazaki + * + * Author: Mathieu Lacage + * Hajime Tazaki + * Frederic Urbani + */ + +#include + +#include "sim-assert.h" + +__cacheline_aligned_in_smp DEFINE_SEQLOCK(mount_lock); +unsigned int dirtytime_expire_interval; + +void __init mnt_init(void) +{ +} + +/* Implementation taken from vfs_kern_mount from linux/namespace.c */ +struct vfsmount *kern_mount_data(struct file_system_type *type, void *data) +{ + static struct mount local_mnt; + static int count = 0; + struct mount *mnt = &local_mnt; + struct dentry *root = 0; + + /* XXX */ + if (count != 0) return &local_mnt.mnt; + count++; + + memset(mnt, 0, sizeof(struct mount)); + if (!type) + return ERR_PTR(-ENODEV); + int flags = MS_KERNMOUNT; + char *name = (char *)type->name; + + if (flags & MS_KERNMOUNT) + mnt->mnt.mnt_flags = MNT_INTERNAL; + + root = type->mount(type, flags, name, data); + if (IS_ERR(root)) + return ERR_CAST(root); + + mnt->mnt.mnt_root = root; + mnt->mnt.mnt_sb = root->d_sb; + mnt->mnt_mountpoint = mnt->mnt.mnt_root; + mnt->mnt_parent = mnt; + /* DCE is monothreaded , so we do not care of lock here */ + list_add_tail(&mnt->mnt_instance, &root->d_sb->s_mounts); + + return &mnt->mnt; +} +void inode_wait_for_writeback(struct inode *inode) +{ +} +void truncate_inode_pages_final(struct address_space *mapping) +{ +} +int dirtytime_interval_handler(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + return -ENOSYS; +} + +unsigned int nr_free_buffer_pages(void) +{ + return 1024; +} diff --git a/arch/lib/glue.c b/arch/lib/glue.c new file mode 100644 index 000..93f72d1 --- /dev/null +++ b/arch/lib/glue.c @@ -0,0 +1,289 @@ +/* + * glue code for library version of Linux kernel + * Copyright (c) 2015 INRIA, Hajime Tazaki + * + * Author: Mathieu Lacage + * Hajime Tazaki + * Frederic Urbani + */ + +#include /* loff_t */ +#include /* ESPIPE */ +#include /* PAGE_CACHE_SIZE */ +#include/* NAME_MAX */ +#include/* struct kstatfs */ +#inclu
[PATCH v4 09/10] lib: libos build scripts and documentation
document and build scripts for libos architecture. Signed-off-by: Hajime Tazaki Signed-off-by: Ryo Nakamura --- Documentation/virtual/libos-howto.txt | 144 MAINTAINERS | 9 + arch/lib/.gitignore | 3 + arch/lib/Kconfig | 124 +++ arch/lib/Makefile | 224 arch/lib/Makefile.print | 45 +++ arch/lib/defconfig| 653 ++ arch/lib/generate-linker-script.py| 50 +++ 8 files changed, 1252 insertions(+) create mode 100644 Documentation/virtual/libos-howto.txt create mode 100644 arch/lib/.gitignore create mode 100644 arch/lib/Kconfig create mode 100644 arch/lib/Makefile create mode 100644 arch/lib/Makefile.print create mode 100644 arch/lib/defconfig create mode 100755 arch/lib/generate-linker-script.py diff --git a/Documentation/virtual/libos-howto.txt b/Documentation/virtual/libos-howto.txt new file mode 100644 index 000..fbf7946 --- /dev/null +++ b/Documentation/virtual/libos-howto.txt @@ -0,0 +1,144 @@ +Library operating system (libos) version of Linux += + +* Overview + +New hardware independent architecture 'arch/lib', configured by +CONFIG_LIB gives you two features. + +- network stack in userspace (NUSE) + NUSE will give you a personalized network stack for each application + without replacing host operating system. + +- network simulator integration, which is called Direct Code Execution (DCE) + DCE will give us a network simulation environment with Linux network stack + to investigate the detail behavior protocol implementation with a flexible + network configuration. This is also useful for the testing environment. + +(- more abstracted implementation of underlying platform will be a future + direction (e.g., rump hypercall)) + +In both features, Linux kernel network stack is running on top of +userspace application with a linked or dynamically loaded library. + +They have their own, isolated network stack from host operating system +so they are configured different IP addresses as other virtualization +methods do. + + +* How different with others ? + +- User-mode Linux (UML) + +UML is a way to execute Linux kernel code as a userspace +application. It is completely isolated from host kernel but can host +arbitrary userspace applications on top of UML. + +- namespace / container + +Container technologies with namespace brings a process-level isolation +to host multiple network entities but shares the kernel among +processes, which prevents to introduce new features implemented in +kernel space. + + +* How to build it ? + +configuration of arch/lib follows a standard configuration of kernel. + + make defconfig ARCH=lib + +or + + make menuconfig ARCH=lib + +then you can build a set of libraries for libos. + + make library ARCH=lib + +This will give you a shared library file liblinux-$(KERNELVERSION).so +in the top directory. + +* Hello world + +you may first need to configure a configuration file, named +'nuse.conf' so that the library version of network stack can know what +kind of IP configuration should be used. There is an example file +at arch/lib/nuse.conf.sample: you may copy and modify it for your purpose. + + sudo NUSECONF=nuse.conf ./nuse ping www.google.com + + + +* Example use cases +- regression test with Direct Code Execution (DCE) + +'make test' by DCE gives a test platform for networking code, with the +help of network simulator facilities like link delay/bandwidth/drop +configurations, large network topology with userspace routing protocol +daemons, etc. + +An interesting feature is the determinism of any test executions. A +test script always gives same results in every execution if there is +no modification on test target code. + +For the first step, you need to obtain network simulator +environment. 'make testbin' does all the stuff for the preparation. + +% make testbin -C tools/testing/libos + +Then, you can 'make test' for your code. + +% make test ARCH=lib + + PASS: TestSuite netlink-socket + PASS: TestSuite process-manager + PASS: TestSuite dce-cradle + PASS: TestSuite dce-mptcp + PASS: TestSuite dce-umip + PASS: TestSuite dce-quagga + PASS: Example dce-tcp-simple + PASS: Example dce-udp-simple + + +- userspace network stack (NUSE) + +an application can use its own network stack, distinct from host network stack +in order to personalize any network feature to the application specific one. +The 'nuse' wrapper script, based on LD_PRELOAD technique, carefully replaces +socket API and redirects system calls to the network stack library, provided by +this framework. + +the network stack can be used with any kind of raw-socket like +technologies such as Intel DPDK, netmap, etc. + + + +* Files / External Repository + +The kernel source tree (i.e., arch/lib) only contains a shared part of +applications (NUSE/DCE). Pure userspace part is m
[PATCH v4 08/10] lib: auxially files for auto-generated asm-generic files of libos
these files works as stubs in order to transparently run the other kernel part (e.g., net/) on libos environment. Signed-off-by: Hajime Tazaki --- arch/lib/include/asm/Kbuild | 57 +++ arch/lib/include/asm/atomic.h | 50 ++ arch/lib/include/asm/barrier.h| 8 + arch/lib/include/asm/bitsperlong.h| 16 ++ arch/lib/include/asm/current.h| 7 + arch/lib/include/asm/elf.h| 10 ++ arch/lib/include/asm/hardirq.h| 8 + arch/lib/include/asm/page.h | 14 + arch/lib/include/asm/pgtable.h| 30 ++ arch/lib/include/asm/processor.h | 19 arch/lib/include/asm/ptrace.h | 4 +++ arch/lib/include/asm/segment.h| 6 arch/lib/include/asm/sembuf.h | 4 +++ arch/lib/include/asm/shmbuf.h | 4 +++ arch/lib/include/asm/shmparam.h | 4 +++ arch/lib/include/asm/sigcontext.h | 6 arch/lib/include/asm/stat.h | 4 +++ arch/lib/include/asm/statfs.h | 4 +++ arch/lib/include/asm/swab.h | 7 + arch/lib/include/asm/thread_info.h| 36 ++ arch/lib/include/asm/uaccess.h| 14 + arch/lib/include/asm/unistd.h | 4 +++ arch/lib/include/uapi/asm/byteorder.h | 6 23 files changed, 322 insertions(+) create mode 100644 arch/lib/include/asm/Kbuild create mode 100644 arch/lib/include/asm/atomic.h create mode 100644 arch/lib/include/asm/barrier.h create mode 100644 arch/lib/include/asm/bitsperlong.h create mode 100644 arch/lib/include/asm/current.h create mode 100644 arch/lib/include/asm/elf.h create mode 100644 arch/lib/include/asm/hardirq.h create mode 100644 arch/lib/include/asm/page.h create mode 100644 arch/lib/include/asm/pgtable.h create mode 100644 arch/lib/include/asm/processor.h create mode 100644 arch/lib/include/asm/ptrace.h create mode 100644 arch/lib/include/asm/segment.h create mode 100644 arch/lib/include/asm/sembuf.h create mode 100644 arch/lib/include/asm/shmbuf.h create mode 100644 arch/lib/include/asm/shmparam.h create mode 100644 arch/lib/include/asm/sigcontext.h create mode 100644 arch/lib/include/asm/stat.h create mode 100644 arch/lib/include/asm/statfs.h create mode 100644 arch/lib/include/asm/swab.h create mode 100644 arch/lib/include/asm/thread_info.h create mode 100644 arch/lib/include/asm/uaccess.h create mode 100644 arch/lib/include/asm/unistd.h create mode 100644 arch/lib/include/uapi/asm/byteorder.h diff --git a/arch/lib/include/asm/Kbuild b/arch/lib/include/asm/Kbuild new file mode 100644 index 000..c647b1c --- /dev/null +++ b/arch/lib/include/asm/Kbuild @@ -0,0 +1,57 @@ +generic-y += auxvec.h +generic-y += bitops.h +generic-y += bug.h +generic-y += cache.h +generic-y += cacheflush.h +generic-y += checksum.h +generic-y += cputime.h +generic-y += cmpxchg.h +generic-y += delay.h +generic-y += device.h +generic-y += div64.h +generic-y += dma.h +generic-y += exec.h +generic-y += emergency-restart.h +generic-y += errno.h +generic-y += fcntl.h +generic-y += ftrace.h +generic-y += io.h +generic-y += ioctl.h +generic-y += ioctls.h +generic-y += ipcbuf.h +generic-y += irq.h +generic-y += irqflags.h +generic-y += irq_regs.h +generic-y += kdebug.h +generic-y += kmap_types.h +generic-y += linkage.h +generic-y += local.h +generic-y += mcs_spinlock.h +generic-y += mman.h +generic-y += mmu.h +generic-y += mmu_context.h +generic-y += module.h +generic-y += mutex.h +generic-y += param.h +generic-y += pci.h +generic-y += percpu.h +generic-y += poll.h +generic-y += posix_types.h +generic-y += preempt.h +generic-y += resource.h +generic-y += scatterlist.h +generic-y += sections.h +generic-y += setup.h +generic-y += signal.h +generic-y += siginfo.h +generic-y += socket.h +generic-y += sockios.h +generic-y += string.h +generic-y += termbits.h +generic-y += termios.h +generic-y += timex.h +generic-y += tlbflush.h +generic-y += types.h +generic-y += topology.h +generic-y += trace_clock.h +generic-y += unaligned.h diff --git a/arch/lib/include/asm/atomic.h b/arch/lib/include/asm/atomic.h new file mode 100644 index 000..41a49285 --- /dev/null +++ b/arch/lib/include/asm/atomic.h @@ -0,0 +1,50 @@ +#ifndef _ASM_SIM_ATOMIC_H +#define _ASM_SIM_ATOMIC_H + +#include + +#if !defined(CONFIG_64BIT) +typedef struct { + volatile long long counter; +} atomic64_t; +#endif + +#define ATOMIC64_INIT(i) { (i) } + +#define atomic64_read(v)(*(volatile long *)&(v)->counter) +void atomic64_add(long i, atomic64_t *v); +static inline void atomic64_sub(long i, atomic64_t *v) +{ + v->counter -= i; +} +static inline void atomic64_inc(atomic64_t *v) +{ + v->counter++; +} +int atomic64_sub_and_test(long i, atomic64_t *v); +#define atomic64_dec(v)atomic64_sub(1LL, (v)) +int atomic64_dec_and_test(atomic64_t *v); +int atomic64_inc_and_test(atomic64_t *
[PATCH v4 10/10] lib: tools used for test scripts
These auxiliary files are used for testing and debugging of net/ code with libos. a simple test is implemented with make test ARCH=lib. Signed-off-by: Hajime Tazaki --- tools/testing/libos/.gitignore | 6 + tools/testing/libos/Makefile | 38 +++ tools/testing/libos/README | 15 +++ tools/testing/libos/bisect.sh| 10 +++ tools/testing/libos/dce-test.sh | 23 tools/testing/libos/nuse-test.sh | 57 6 files changed, 149 insertions(+) create mode 100644 tools/testing/libos/.gitignore create mode 100644 tools/testing/libos/Makefile create mode 100644 tools/testing/libos/README create mode 100755 tools/testing/libos/bisect.sh create mode 100755 tools/testing/libos/dce-test.sh create mode 100755 tools/testing/libos/nuse-test.sh diff --git a/tools/testing/libos/.gitignore b/tools/testing/libos/.gitignore new file mode 100644 index 000..57a74a0 --- /dev/null +++ b/tools/testing/libos/.gitignore @@ -0,0 +1,6 @@ +*.pcap +files-* +bake +buildtop +core +exitprocs diff --git a/tools/testing/libos/Makefile b/tools/testing/libos/Makefile new file mode 100644 index 000..3da25429 --- /dev/null +++ b/tools/testing/libos/Makefile @@ -0,0 +1,38 @@ +ADD_PARAM?= + +all: test + +bake: + hg clone http://code.nsnam.org/bake + +check_pkgs: + @./bake/bake.py check | grep Bazaar | grep OK || (echo "bzr is missing" && ./bake/bake.py check) + @./bake/bake.py check | grep autoreconf | grep OK || (echo "autotools is missing" && ./bake/bake.py check && exit 1) + +testbin: bake check_pkgs + @cp ../../../arch/lib/tools/bakeconf-linux.xml bake/bakeconf.xml + @mkdir -p buildtop/build/bin_dce + cd buildtop ; \ + ../bake/bake.py configure -e dce-linux-inkernel $(BAKECONF_PARAMS) + cd buildtop ; \ + ../bake/bake.py show --enabledTree | grep -v -E "pygoocanvas|graphviz|python-dev" | grep Missing && (echo "required packages are missing") || echo "" + cd buildtop ; \ + ../bake/bake.py download ; \ + ../bake/bake.py update ; \ + ../bake/bake.py build + +test: + @./dce-test.sh ADD_PARAM=$(ADD_PARAM) + +test-valgrind: + @./dce-test.sh -g ADD_PARAM=$(ADD_PARAM) + +test-fault-injection: + @./dce-test.sh -f ADD_PARAM=$(ADD_PARAM) + +clean: +# @rm -rf buildtop + @rm -f *.pcap + @rm -rf files-* + @rm -f exitprocs + @rm -f core diff --git a/tools/testing/libos/README b/tools/testing/libos/README new file mode 100644 index 000..51ac5a5 --- /dev/null +++ b/tools/testing/libos/README @@ -0,0 +1,15 @@ + +- bisect.sh +a sample script to bisect an issue of network stack code with the help +of LibOS (and ns-3 network simulator). This was used to detect the issue +for the following patch. + +http://patchwork.ozlabs.org/patch/436351/ + +- dce-test.sh +a test script invoked by 'make test ARCH=lib'. The contents of test +scenario are implemented as test suites of ns-3 network simulator. + +- nuse-test.sh +a simple test script for Network Stack in Userspace (NUSE). + diff --git a/tools/testing/libos/bisect.sh b/tools/testing/libos/bisect.sh new file mode 100755 index 000..9377ac3 --- /dev/null +++ b/tools/testing/libos/bisect.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +git merge origin/nuse --no-commit +make clean ARCH=lib +make library ARCH=lib OPT=no +make test ARCH=lib ADD_PARAM=" -s dce-umip" +RET=$? +git reset --hard + +exit $RET diff --git a/tools/testing/libos/dce-test.sh b/tools/testing/libos/dce-test.sh new file mode 100755 index 000..e81e2d8 --- /dev/null +++ b/tools/testing/libos/dce-test.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e +#set -x +export LD_LOG=symbol-fail +#VERBOSE="-v" +VALGRIND="" +FAULT_INJECTION="" + +if [ "$1" = "-g" ] ; then + VALGRIND="-g" +# Not implemneted yet. +#elif [ "$1" = "-f" ] ; then +# FAULT_INJECTION="-f" +fi + +# FIXME +#export NS_ATTRIBUTE_DEFAULT='ns3::DceManagerHelper::LoaderFactory=ns3::\ +#DlmLoaderFactory[];ns3::TaskManager::FiberManagerType=UcontextFiberManager' + +cd buildtop/source/ns-3-dce +LD_LIBRARY_PATH=${srctree} ./test.py -n ${VALGRIND} ${FAULT_INJECTION}\ + ${VERBOSE} ${ADD_PARAM} diff --git a/tools/testing/libos/nuse-test.sh b/tools/testing/libos/nuse-test.sh new file mode 100755 index 000..198e7e4 --- /dev/null +++ b/tools/testing/libos/nuse-test.sh @@ -0,0 +1,57 @@ +#!/bin/bash -e + +LIBOS_TOOLS=arch/lib/tools + +IFNAME=`ip route |grep default | awk '{print $5}'` +GW=`ip route |grep default | awk '{print $3}'` +#XXX +IPADDR=`echo $GW | sed -r "s/([0-9]+\.[0-9]+\.[0-9]+\.)([0-9]+)$/\1\`expr \2 + 10\`/"` + +# ip route +# ip address +# ip link + +NUSE_CONF=/tmp/nuse.conf + +cat > ${NUSE_CONF} << ENDCONF + +interface ${IFNAME} + address ${IPADDR} + netmask 255.255.255.0 + macaddr 00:01:01:01:01:02 + viftype RAW + +route + network 0.0.0.0 + netmask 0.0.0.0 + gateway ${GW} + +ENDCONF + +cd ${LIBOS_TOOLS}
Re: [PATCH net-next V7 0/2] openvswitch: Add support for 802.1AD
net-next is not open at this time, please resubmit this when the net-next tree is open for submissions again, thanks. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 05/10] lib: context and scheduling functions (kernel glue code) for libos
contexnt primitives of kernel such as soft interupts, scheduling, tasklet are implemented for libos. these functions eventually call the functions registered by lib_init() API as well. Signed-off-by: Hajime Tazaki --- arch/lib/sched.c | 406 +++ arch/lib/softirq.c | 108 ++ arch/lib/tasklet.c | 76 ++ arch/lib/workqueue.c | 242 ++ 4 files changed, 832 insertions(+) create mode 100644 arch/lib/sched.c create mode 100644 arch/lib/softirq.c create mode 100644 arch/lib/tasklet.c create mode 100644 arch/lib/workqueue.c diff --git a/arch/lib/sched.c b/arch/lib/sched.c new file mode 100644 index 000..98a568a --- /dev/null +++ b/arch/lib/sched.c @@ -0,0 +1,406 @@ +/* + * glue code for library version of Linux kernel + * Copyright (c) 2015 INRIA, Hajime Tazaki + * + * Author: Mathieu Lacage + * Hajime Tazaki + */ + +#include +#include +#include +#include +#include +#include +#include "lib.h" +#include "sim.h" +#include "sim-assert.h" + +/** + called by wait_event macro: + - prepare_to_wait + - schedule + - finish_wait + */ + +struct SimTask *lib_task_create(void *private, unsigned long pid) +{ + struct SimTask *task = lib_malloc(sizeof(struct SimTask)); + struct cred *cred; + struct nsproxy *ns; + struct user_struct *user; + struct thread_info *info; + struct pid *kpid; + + if (!task) + return NULL; + memset(task, 0, sizeof(struct SimTask)); + cred = lib_malloc(sizeof(struct cred)); + if (!cred) + return NULL; + /* XXX: we could optimize away this allocation by sharing it + for all tasks */ + ns = lib_malloc(sizeof(struct nsproxy)); + if (!ns) + return NULL; + user = lib_malloc(sizeof(struct user_struct)); + if (!user) + return NULL; + info = alloc_thread_info(&task->kernel_task); + if (!info) + return NULL; + kpid = lib_malloc(sizeof(struct pid)); + if (!kpid) + return NULL; + kpid->numbers[0].nr = pid; + cred->fsuid = make_kuid(current_user_ns(), 0); + cred->fsgid = make_kgid(current_user_ns(), 0); + cred->user = user; + atomic_set(&cred->usage, 1); + info->task = &task->kernel_task; + info->preempt_count = 0; + info->flags = 0; + atomic_set(&ns->count, 1); + ns->uts_ns = 0; + ns->ipc_ns = 0; + ns->mnt_ns = 0; + ns->pid_ns_for_children = 0; + ns->net_ns = &init_net; + task->kernel_task.cred = cred; + task->kernel_task.pid = pid; + task->kernel_task.pids[PIDTYPE_PID].pid = kpid; + task->kernel_task.pids[PIDTYPE_PGID].pid = kpid; + task->kernel_task.pids[PIDTYPE_SID].pid = kpid; + task->kernel_task.nsproxy = ns; + task->kernel_task.stack = info; + /* this is a hack. */ + task->kernel_task.group_leader = &task->kernel_task; + task->private = private; + return task; +} +void lib_task_destroy(struct SimTask *task) +{ + lib_free((void *)task->kernel_task.nsproxy); + lib_free((void *)task->kernel_task.cred); + lib_free((void *)task->kernel_task.cred->user); + free_thread_info(task->kernel_task.stack); + lib_free(task); +} +void *lib_task_get_private(struct SimTask *task) +{ + return task->private; +} + +int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags) +{ + struct SimTask *task = lib_task_start((void (*)(void *))fn, arg); + + return task->kernel_task.pid; +} + +struct task_struct *get_current(void) +{ + struct SimTask *lib_task = lib_task_current(); + + return &lib_task->kernel_task; +} + +struct thread_info *current_thread_info(void) +{ + return task_thread_info(get_current()); +} +struct thread_info *alloc_thread_info(struct task_struct *task) +{ + return lib_malloc(sizeof(struct thread_info)); +} +void free_thread_info(struct thread_info *ti) +{ + lib_free(ti); +} + + +void __put_task_struct(struct task_struct *t) +{ + lib_free(t); +} + +void add_wait_queue(wait_queue_head_t *q, wait_queue_t *wait) +{ + wait->flags &= ~WQ_FLAG_EXCLUSIVE; + list_add(&wait->task_list, &q->task_list); +} +void add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t *wait) +{ + wait->flags |= WQ_FLAG_EXCLUSIVE; + list_add_tail(&wait->task_list, &q->task_list); +} +void remove_wait_queue(wait_queue_head_t *q, wait_queue_t *wait) +{ + if (wait->task_list.prev != LIST_POISON2) + list_del(&wait->task_list); +} +void +prepare_to_wait_exclusive(wait_queue_head_t *q, wait_queue_t *wait, int state) +{ + wait->flags |= WQ_FLAG_EXCLUSIVE; + if (list_empty(&wait->task_list)) + list_add_tail(&wait->task_list, &q->task_list); + set_current_state(state); +} +void prepare_to_wait(wai
[PATCH v4 01/10] sysctl: make some functions unstatic to access by arch/lib
libos (arch/lib) emulates a sysctl-like interface by a function call of userspace by enumerating sysctl tree from sysctl_table_root. It requires to be publicly accessible to this symbol and related functions. Signed-off-by: Hajime Tazaki --- fs/proc/proc_sysctl.c | 36 +++- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index fea2561..7c5924c 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -35,7 +35,7 @@ static struct ctl_table root_table[] = { }, { } }; -static struct ctl_table_root sysctl_table_root = { +struct ctl_table_root sysctl_table_root = { .default_set.dir.header = { {{.count = 1, .nreg = 1, @@ -77,8 +77,9 @@ static int namecmp(const char *name1, int len1, const char *name2, int len2) } /* Called under sysctl_lock */ -static struct ctl_table *find_entry(struct ctl_table_header **phead, - struct ctl_dir *dir, const char *name, int namelen) +struct ctl_table *ctl_table_find_entry(struct ctl_table_header **phead, + struct ctl_dir *dir, const char *name, + int namelen) { struct ctl_table_header *head; struct ctl_table *entry; @@ -300,7 +301,7 @@ static struct ctl_table *lookup_entry(struct ctl_table_header **phead, struct ctl_table *entry; spin_lock(&sysctl_lock); - entry = find_entry(&head, dir, name, namelen); + entry = ctl_table_find_entry(&head, dir, name, namelen); if (entry && use_table(head)) *phead = head; else @@ -321,7 +322,7 @@ static struct ctl_node *first_usable_entry(struct rb_node *node) return NULL; } -static void first_entry(struct ctl_dir *dir, +void ctl_table_first_entry(struct ctl_dir *dir, struct ctl_table_header **phead, struct ctl_table **pentry) { struct ctl_table_header *head = NULL; @@ -339,7 +340,7 @@ static void first_entry(struct ctl_dir *dir, *pentry = entry; } -static void next_entry(struct ctl_table_header **phead, struct ctl_table **pentry) +void ctl_table_next_entry(struct ctl_table_header **phead, struct ctl_table **pentry) { struct ctl_table_header *head = *phead; struct ctl_table *entry = *pentry; @@ -670,7 +671,8 @@ static int proc_sys_readdir(struct file *file, struct dir_context *ctx) pos = 2; - for (first_entry(ctl_dir, &h, &entry); h; next_entry(&h, &entry)) { + for (ctl_table_first_entry(ctl_dir, &h, &entry); h; +ctl_table_next_entry(&h, &entry)) { if (!scan(h, entry, &pos, file, ctx)) { sysctl_head_finish(h); break; @@ -828,7 +830,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir, struct ctl_table_header *head; struct ctl_table *entry; - entry = find_entry(&head, dir, name, namelen); + entry = ctl_table_find_entry(&head, dir, name, namelen); if (!entry) return ERR_PTR(-ENOENT); if (!S_ISDIR(entry->mode)) @@ -924,13 +926,13 @@ failed: return subdir; } -static struct ctl_dir *xlate_dir(struct ctl_table_set *set, struct ctl_dir *dir) +struct ctl_dir *ctl_table_xlate_dir(struct ctl_table_set *set, struct ctl_dir *dir) { struct ctl_dir *parent; const char *procname; if (!dir->header.parent) return &set->dir; - parent = xlate_dir(set, dir->header.parent); + parent = ctl_table_xlate_dir(set, dir->header.parent); if (IS_ERR(parent)) return parent; procname = dir->header.ctl_table[0].procname; @@ -951,13 +953,13 @@ static int sysctl_follow_link(struct ctl_table_header **phead, spin_lock(&sysctl_lock); root = (*pentry)->data; set = lookup_header_set(root, namespaces); - dir = xlate_dir(set, (*phead)->parent); + dir = ctl_table_xlate_dir(set, (*phead)->parent); if (IS_ERR(dir)) ret = PTR_ERR(dir); else { const char *procname = (*pentry)->procname; head = NULL; - entry = find_entry(&head, dir, procname, strlen(procname)); + entry = ctl_table_find_entry(&head, dir, procname, strlen(procname)); ret = -ENOENT; if (entry && use_table(head)) { unuse_table(*phead); @@ -1069,7 +1071,7 @@ static bool get_links(struct ctl_dir *dir, /* Are there links available for every entry in table? */ for (entry = table; entry->procname; entry++) { const char *procname = entry->procname; - link = find_entry(&head, dir, procname, strlen(procname)); + link = ctl_table_find_entry(&head, dir, procname, strlen(procname)); if (!link) return false;
[PATCH v4 00/10] an introduction of Linux library operating system (LibOS)
This is the 4th version of Linux LibOS patchset which reflects a couple of comments received from people. changes from v3: - Patch 09/10 ("lib: libos build scripts and documentation") 1) Remove RFC (now it's a proposal) 2) build environment cleanup (commented by Paul Bolle) - Overall 3) change based tree from arnd/asm-generic to torvalds/linux.git (commented by Richard Weinberger) 4) rebased to Linux 4.1-rc1 (b787f68c36d49bb1d9236f403813641efa74a031) 5) change the title of cover letter a bit changes from v2: - Patch 02/11 ("slab: add private memory allocator header for arch/lib") 1) add new allocator named SLIB (Library Allocator): Patch 04/11 is integrated to 02 (commented by Christoph Lameter) - Overall 2) rewrite commit log messages changes from v1: - Patch 01/11 ("sysctl: make some functions unstatic to access by arch/lib"): 1) add prefix ctl_table_ to newly publiced functions (commented by Joe Perches) - Patch 08/11 ("lib: other kernel glue layer code"): 2) significantly reduce glue codes (stubs) (commented by Richard Weinberger) - Others 3) adapt to linux-4.0.0 4) detect make dependency by Kbuild .cmd files patchset history - [v3] : https://lkml.org/lkml/2015/4/19/63 [v2] : https://lkml.org/lkml/2015/4/17/140 [v1] : https://lkml.org/lkml/2015/3/24/254 This is an introduction of Linux library operating system (LibOS). Our objective is to build the kernel network stack as a shared library that can be linked to by userspace programs to provide network stack personalization and testing facilities, and allow researchers to more easily simulate complex network topologies of linux routers/hosts. Although the architecture itself can virtualize various things, the current design only focuses on the network stack. You can benefit network stack feature such as TCP, UDP, SCTP, DCCP (IPv4 and IPv6), Mobie IPv6, Multipath TCP (IPv4/IPv6, out-of-tree at the present moment), and netlink with various userspace applications (quagga, iproute2, iperf, wget, and thttpd). == What is LibOS ? == The library exposes an entry point as API, which is lib_init(), in order to connect userspace applications to the (userspace-version) kernel network stack. The clock source, virtual struct net_device, and scheduler are provided by caller while kernel resource like system calls is provided by callee. Once the LibOS is initialized via the API, userspace applications with POSIX socket can use the system calls defined in LibOS by replacing from the original socket-related symbols to the LibOS-specific one. Then application can benefit the network stack of LibOS without involving the host network stack. Currently, there are two users of LibOS: Network Stack in Userspace (NUSE) and ns-3 network simulatior with Direct Code Execution (DCE). These codes are managed at an external repository(*1). == How to use it ? == to build the library, % make {defconfig,menuconfig} ARCH=lib then, build it. % make library ARCH=lib You will see liblinux-$(KERNELVERSION).so in the top directory. == More information == The crucial difference between UML (user-mode linux) and this approach is that we allow multiple network stack instances to co-exist within a single process with dlmopen(3) like linking for easy debugging. These patches are also available on this branch: git://github.com/libos-nuse/net-next-nuse.git for-linus-upstream-libos-v4 (based on the commit b787f68c36d49bb1d9236f403813641efa74a031 of torvalds/linux.git) For further information, here is a slideset presented at the last netdev0.1 conference. http://www.slideshare.net/hajimetazaki/library-operating-system-for-linux-netdev01 I would appreciate any kind of your feedback regarding to upstream this feature. *1 https://github.com/libos-nuse/linux-libos-tools Hajime Tazaki (10): sysctl: make some functions unstatic to access by arch/lib slab: add SLIB (Library memory allocator) for arch/lib lib: public headers and API implementations for userspace programs lib: time handling (kernel glue code) lib: context and scheduling functions (kernel glue code) for libos lib: sysctl handling (kernel glue code) lib: other kernel glue layer code lib: auxially files for auto-generated asm-generic files of libos lib: libos build scripts and documentation lib: tools used for test scripts Documentation/virtual/libos-howto.txt | 144 MAINTAINERS | 9 + arch/lib/.gitignore | 3 + arch/lib/Kconfig | 124 +++ arch/lib/Makefile | 224 arch/lib/Makefile.print | 45 +++ arch/lib/capability.c | 25 ++ arch/lib/defconfig| 653 ++ arch/lib/filemap.c| 32 ++ arch/lib/fs.c | 70 arch/lib/generate-linker-script.py| 50 +++ arch/lib/glue.c | 289 +++ arch/lib/hrtimer.c
[PATCH v4 04/10] lib: time handling (kernel glue code)
timer related (internal) functions such as add_timer(), do_gettimeofday() of kernel are trivially reimplemented for libos. these eventually call the functions registered by lib_init() API. Signed-off-by: Hajime Tazaki --- arch/lib/hrtimer.c | 122 +++ arch/lib/tasklet-hrtimer.c | 57 +++ arch/lib/time.c| 144 +++ arch/lib/timer.c | 238 + 4 files changed, 561 insertions(+) create mode 100644 arch/lib/hrtimer.c create mode 100644 arch/lib/tasklet-hrtimer.c create mode 100644 arch/lib/time.c create mode 100644 arch/lib/timer.c diff --git a/arch/lib/hrtimer.c b/arch/lib/hrtimer.c new file mode 100644 index 000..4565b59 --- /dev/null +++ b/arch/lib/hrtimer.c @@ -0,0 +1,122 @@ +/* + * glue code for library version of Linux kernel + * Copyright (c) 2015 INRIA, Hajime Tazaki + * + * Author: Mathieu Lacage + * Hajime Tazaki + */ + +#include +#include "sim-assert.h" +#include "sim.h" + +/** + * hrtimer_init - initialize a timer to the given clock + * @timer: the timer to be initialized + * @clock_id: the clock to be used + * @mode: timer mode abs/rel + */ +void hrtimer_init(struct hrtimer *timer, clockid_t clock_id, + enum hrtimer_mode mode) +{ + memset(timer, 0, sizeof(*timer)); +} +static void trampoline(void *context) +{ + struct hrtimer *timer = context; + enum hrtimer_restart restart = timer->function(timer); + + if (restart == HRTIMER_RESTART) { + void *event = + lib_event_schedule_ns(ktime_to_ns(timer->_softexpires), + &trampoline, timer); + timer->base = event; + } else { + /* mark as completed. */ + timer->base = 0; + } +} +/** + * hrtimer_start_range_ns - (re)start an hrtimer on the current CPU + * @timer: the timer to be added + * @tim:expiry time + * @delta_ns: "slack" range for the timer + * @mode: expiry mode: absolute (HRTIMER_ABS) or relative (HRTIMER_REL) + * + * Returns: + * 0 on success + * 1 when the timer was active + */ +int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, +unsigned long delta_ns, +const enum hrtimer_mode mode, +int wakeup) +{ + int ret = hrtimer_cancel(timer); + s64 ns = ktime_to_ns(tim); + void *event; + + if (mode == HRTIMER_MODE_ABS) + ns -= lib_current_ns(); + timer->_softexpires = ns_to_ktime(ns); + event = lib_event_schedule_ns(ns, &trampoline, timer); + timer->base = event; + return ret; +} +/** + * hrtimer_try_to_cancel - try to deactivate a timer + * @timer: hrtimer to stop + * + * Returns: + * 0 when the timer was not active + * 1 when the timer was active + * -1 when the timer is currently excuting the callback function and + *cannot be stopped + */ +int hrtimer_try_to_cancel(struct hrtimer *timer) +{ + /* Note: we cannot return -1 from this function. + see comment in hrtimer_cancel. */ + if (timer->base == 0) + /* timer was not active yet */ + return 1; + lib_event_cancel(timer->base); + timer->base = 0; + return 0; +} +/** + * hrtimer_cancel - cancel a timer and wait for the handler to finish. + * @timer: the timer to be cancelled + * + * Returns: + * 0 when the timer was not active + * 1 when the timer was active + */ +int hrtimer_cancel(struct hrtimer *timer) +{ + /* Note: because we assume a uniprocessor non-interruptible */ + /* system when running in the kernel, we know that the timer */ + /* is not running when we execute this code, so, know that */ + /* try_to_cancel cannot return -1 and we don't need to retry */ + /* the cancel later to wait for the handler to finish. */ + int ret = hrtimer_try_to_cancel(timer); + + lib_assert(ret >= 0); + return ret; +} +int +hrtimer_start(struct hrtimer *timer, ktime_t tim, const enum hrtimer_mode mode) +{ + return __hrtimer_start_range_ns(timer, tim, 0, mode, 1); +} +int hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, + unsigned long delta_ns, const enum hrtimer_mode mode) +{ + return __hrtimer_start_range_ns(timer, tim, delta_ns, mode, 1); +} + +int hrtimer_get_res(const clockid_t which_clock, struct timespec *tp) +{ + *tp = ns_to_timespec(1); + return 0; +} diff --git a/arch/lib/tasklet-hrtimer.c b/arch/lib/tasklet-hrtimer.c new file mode 100644 index 000..fef4902 --- /dev/null +++ b/arch/lib/tasklet-hrtimer.c @@ -0,0 +1,57 @@ +/* + * glue code for library version of Linux kernel + * Copyright (c) 2015 INRIA, Hajime Tazaki + * + * Author: Mathieu Lacage + * Hajime Tazaki + */ + +#include +#include "sim.h"
[PATCH v4 03/10] lib: public headers and API implementations for userspace programs
userspace programs which uses libos access via a public API, lib_init(), with passed arguments struct SimImported and struct SimExported. Signed-off-by: Hajime Tazaki Signed-off-by: Ryo Nakamura --- arch/lib/include/sim-assert.h | 23 +++ arch/lib/include/sim-init.h | 134 ++ arch/lib/include/sim-printf.h | 13 ++ arch/lib/include/sim-types.h | 53 ++ arch/lib/include/sim.h| 51 ++ arch/lib/lib-device.c | 187 +++ arch/lib/lib-socket.c | 410 ++ arch/lib/lib.c| 294 ++ arch/lib/lib.h| 21 +++ 9 files changed, 1186 insertions(+) create mode 100644 arch/lib/include/sim-assert.h create mode 100644 arch/lib/include/sim-init.h create mode 100644 arch/lib/include/sim-printf.h create mode 100644 arch/lib/include/sim-types.h create mode 100644 arch/lib/include/sim.h create mode 100644 arch/lib/lib-device.c create mode 100644 arch/lib/lib-socket.c create mode 100644 arch/lib/lib.c create mode 100644 arch/lib/lib.h diff --git a/arch/lib/include/sim-assert.h b/arch/lib/include/sim-assert.h new file mode 100644 index 000..974122c --- /dev/null +++ b/arch/lib/include/sim-assert.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2015 INRIA, Hajime Tazaki + * + * Author: Mathieu Lacage + * Hajime Tazaki + */ + +#ifndef SIM_ASSERT_H +#define SIM_ASSERT_H + +#include "sim-printf.h" + +#define lib_assert(v) { \ + while (!(v)) { \ + lib_printf("Assert failed %s:%u \"" #v "\"\n", \ + __FILE__, __LINE__);\ + char *p = 0;\ + *p = 1; \ + } \ + } + + +#endif /* SIM_ASSERT_H */ diff --git a/arch/lib/include/sim-init.h b/arch/lib/include/sim-init.h new file mode 100644 index 000..e871a59 --- /dev/null +++ b/arch/lib/include/sim-init.h @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2015 INRIA, Hajime Tazaki + * + * Author: Mathieu Lacage + * Hajime Tazaki + */ + +#ifndef SIM_INIT_H +#define SIM_INIT_H + +#include +#include "sim-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct _IO_FILE; +typedef struct _IO_FILE FILE; + +struct SimExported { + struct SimTask *(*task_create)(void *priv, unsigned long pid); + void (*task_destroy)(struct SimTask *task); + void *(*task_get_private)(struct SimTask *task); + + int (*sock_socket)(int domain, int type, int protocol, + struct SimSocket **socket); + int (*sock_close)(struct SimSocket *socket); + ssize_t (*sock_recvmsg)(struct SimSocket *socket, struct msghdr *msg, + int flags); + ssize_t (*sock_sendmsg)(struct SimSocket *socket, + const struct msghdr *msg, int flags); + int (*sock_getsockname)(struct SimSocket *socket, + struct sockaddr *name, int *namelen); + int (*sock_getpeername)(struct SimSocket *socket, + struct sockaddr *name, int *namelen); + int (*sock_bind)(struct SimSocket *socket, const struct sockaddr *name, + int namelen); + int (*sock_connect)(struct SimSocket *socket, + const struct sockaddr *name, int namelen, + int flags); + int (*sock_listen)(struct SimSocket *socket, int backlog); + int (*sock_shutdown)(struct SimSocket *socket, int how); + int (*sock_accept)(struct SimSocket *socket, + struct SimSocket **newSocket, int flags); + int (*sock_ioctl)(struct SimSocket *socket, int request, char *argp); + int (*sock_setsockopt)(struct SimSocket *socket, int level, + int optname, + const void *optval, int optlen); + int (*sock_getsockopt)(struct SimSocket *socket, int level, + int optname, + void *optval, int *optlen); + + void (*sock_poll)(struct SimSocket *socket, void *ret); + void (*sock_pollfreewait)(void *polltable); + + struct SimDevice *(*dev_create)(const char *ifname, void *priv, + enum SimDevFlags flags); + void (*dev_destroy)(struct SimDevice *dev); + void *(*dev_get_private)(struct SimDevice *task); + void (*dev_set_address)(struct SimDevice *dev, + unsigned char buffer[6]); + void (*dev_set_mtu)(struct SimDevice *dev, int mtu); + struct SimDevicePacket (*dev_create_packet)(struct SimDevice *dev, + int size); + void
Re: [PATCH 0/2] ppp: mppe: fixes MPPE desync on links which don't guarantee packet ordering
From: Sylvain Rochet Date: Sun, 26 Apr 2015 20:40:51 +0200 > I am currently having an issue with PPP over L2TP (UDP) and MPPE in > stateless mode (default mode), UDP does not guarantee packet ordering so > we might get out of order packet. MPPE needs to be continuously synched > so we should drop late UDP packet. > > I added a printk on the number of time we rekeyed in MPPE decompressor, > this is what we currently have if we receive a slightly out of order UDP > packet: ... > This is obviously wrong, we missed packet 1561 and we already rekeyed 2 > times for 1562 we previously received, we can't recover the decryption > key we need for 1561, we should drop it instead of rekeying 4095 times. > > This patch series drop any packet with are not within the 4096/2 forward > window. Series applied, thanks Sylvain. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] Bluetooth: Skip the shutdown routine if the interface is not up
Hi Gabriele, > Most likely, the shutdown routine requires the interface to be up. > This is the case for BTUSB_INTEL: the routine tries to send a command > to the interface, but since this one is down, it fails and exits once > HCI_INIT_TIMEOUT has expired. > > Signed-off-by: Gabriele Mazzotta > --- > net/bluetooth/hci_core.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c > index 476709b..4663c3d 100644 > --- a/net/bluetooth/hci_core.c > +++ b/net/bluetooth/hci_core.c > @@ -1557,7 +1557,8 @@ static int hci_dev_do_close(struct hci_dev *hdev) > { > BT_DBG("%s %p", hdev->name, hdev); > > - if (!hci_dev_test_flag(hdev, HCI_UNREGISTER)) { > + if (!hci_dev_test_flag(hdev, HCI_UNREGISTER) && > + test_bit(HCI_UP, &hdev->flags)) { > /* Execute vendor specific shutdown routine */ > if (hdev->shutdown) > hdev->shutdown(hdev); this is a good catch. Acked-by: Marcel Holtmann Cc: sta...@vger.kernel.org # 4.0.x Dave, do you want to take this patch straight into your stable tree? Regards Marcel -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2] brcmfmac: prohibit ACPI power management for brcmfmac driver
ACPI will manage WiFi chip's power state during suspend/resume process on some tablet platforms(such as ASUS T100TA). This is not supported by brcmfmac driver now, and the context of WiFi chip will be damaged after resume. This patch disconnects the relationship between WiFi chip and it's ACPI companion, and prohibit ACPI PM for it. Signed-off-by: Zhonghui Fu --- drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c index 9b508bd..fdf8feb 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c @@ -1114,6 +1114,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, int err; struct brcmf_sdio_dev *sdiodev; struct brcmf_bus *bus_if; + struct device *dev; brcmf_dbg(SDIO, "Enter\n"); brcmf_dbg(SDIO, "Class=%x\n", func->class); @@ -1121,6 +1122,10 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, brcmf_dbg(SDIO, "sdio device ID: 0x%04x\n", func->device); brcmf_dbg(SDIO, "Function#: %d\n", func->num); + /* prohibit ACPI power management for this device */ + dev = &func->dev; + dev->fwnode = NULL; + /* Consume func num 1 but dont do anything with it. */ if (func->num == 1) return 0; -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] Bluetooth: Skip the shutdown routine if the interface is not up
From: Marcel Holtmann Date: Sun, 26 Apr 2015 21:49:06 -0700 > Hi Gabriele, > >> Most likely, the shutdown routine requires the interface to be up. >> This is the case for BTUSB_INTEL: the routine tries to send a command >> to the interface, but since this one is down, it fails and exits once >> HCI_INIT_TIMEOUT has expired. >> >> Signed-off-by: Gabriele Mazzotta >> --- >> net/bluetooth/hci_core.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c >> index 476709b..4663c3d 100644 >> --- a/net/bluetooth/hci_core.c >> +++ b/net/bluetooth/hci_core.c >> @@ -1557,7 +1557,8 @@ static int hci_dev_do_close(struct hci_dev *hdev) >> { >> BT_DBG("%s %p", hdev->name, hdev); >> >> -if (!hci_dev_test_flag(hdev, HCI_UNREGISTER)) { >> +if (!hci_dev_test_flag(hdev, HCI_UNREGISTER) && >> +test_bit(HCI_UP, &hdev->flags)) { >> /* Execute vendor specific shutdown routine */ >> if (hdev->shutdown) >> hdev->shutdown(hdev); > > this is a good catch. > > Acked-by: Marcel Holtmann > Cc: sta...@vger.kernel.org # 4.0.x > > Dave, do you want to take this patch straight into your stable tree? Please handle this via the bluetooth tree, thanks. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2] brcmfmac: keep WiFi chip's power during system suspension
Need to keep the power supply for WiFi chip during system suspension. Otherwise, the context of WiFi chip will be lost. Signed-off-by: Zhonghui Fu --- drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c | 10 ++ 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c index fdf8feb..03d3671 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c @@ -1251,15 +1251,17 @@ static int brcmf_ops_sdio_suspend(struct device *dev) brcmf_sdiod_freezer_on(sdiodev); brcmf_sdio_wd_timer(sdiodev->bus, 0); + sdio_flags = MMC_PM_KEEP_POWER; if (sdiodev->wowl_enabled) { - sdio_flags = MMC_PM_KEEP_POWER; if (sdiodev->pdata->oob_irq_supported) enable_irq_wake(sdiodev->pdata->oob_irq_nr); else - sdio_flags = MMC_PM_WAKE_SDIO_IRQ; - if (sdio_set_host_pm_flags(sdiodev->func[1], sdio_flags)) - brcmf_err("Failed to set pm_flags %x\n", sdio_flags); + sdio_flags |= MMC_PM_WAKE_SDIO_IRQ; } + + if (sdio_set_host_pm_flags(sdiodev->func[1], sdio_flags)) + brcmf_err("Failed to set pm_flags %x\n", sdio_flags); + return 0; } -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html