* re: bonding: remove entries for master_ip and vlan_ip and query devices instead
From: Dan Carpenter @ 2012-10-25 12:29 UTC (permalink / raw)
To: andy; +Cc: netdev
[ Sort of old, but apparently I didn't email about this in March ].
Hello Andy Gospodarek,
This is a semi-automatic email about new static checker warnings.
The patch eaddcd76903c: "bonding: remove entries for master_ip and
vlan_ip and query devices instead" from Mar 22, 2012, leads to the
following Smatch complaint:
drivers/net/bonding/bond_main.c:2703 bond_arp_send_all()
warn: variable dereferenced before check 'vlan_dev' (see line 2697)
drivers/net/bonding/bond_main.c
2696 vlan_id = vlan->vlan_id;
^^^^^^^^^^
If vlan_id is non-zero it means we went hit this assignment.
2697 pr_debug("basa: vlan match on %s %d\n",
2698 vlan_dev->name, vlan_id);
^^^^^^^^^^
Old dereference.
2699 break;
2700 }
2701 }
2702
2703 if (vlan_id && vlan_dev) {
^^^^^^^^
New check.
2704 ip_rt_put(rt);
2705 addr = bond_confirm_addr(vlan_dev, targets[i], 0);
regards,
dan carpenter
^ permalink raw reply
* Re: [PATCH v2] sctp: Make hmac algorithm selection for cookie generation dynamic
From: Vlad Yasevich @ 2012-10-25 13:09 UTC (permalink / raw)
To: Neil Horman; +Cc: linux-sctp, David S. Miller, netdev
In-Reply-To: <1351106403-23375-1-git-send-email-nhorman@tuxdriver.com>
On 10/24/2012 03:20 PM, Neil Horman wrote:
> Currently sctp allows for the optional use of md5 of sha1 hmac algorithms to
> generate cookie values when establishing new connections via two build time
> config options. Theres no real reason to make this a static selection. We can
> add a sysctl that allows for the dynamic selection of these algorithms at run
> time, with the default value determined by the corresponding crypto library
> availability.
> This comes in handy when, for example running a system in FIPS mode, where use
> of md5 is disallowed, but SHA1 is permitted.
>
> Note: This new sysctl has no corresponding socket option to select the cookie
> hmac algorithm. I chose not to implement that intentionally, as RFC 6458
> contains no option for this value, and I opted not to pollute the socket option
> namespace.
>
> Change notes:
> v2)
> * Updated subject to have the proper sctp prefix as per Dave M.
> * Replaced deafult selection options with new options that allow
> developers to explicitly select available hmac algs at build time
> as per suggestion by Vlad Y.
>
Thanks Neil. That's much better.
Acked-by: Vlad Yasevich <vyasevich@gmail.com>
-vlad
> Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
> CC: Vlad Yasevich <vyasevich@gmail.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: netdev@vger.kernel.org
> ---
> Documentation/networking/ip-sysctl.txt | 14 ++++++++
> include/net/netns/sctp.h | 3 ++
> include/net/sctp/constants.h | 8 -----
> include/net/sctp/structs.h | 1 +
> net/sctp/Kconfig | 39 ++++++++--------------
> net/sctp/protocol.c | 9 ++++++
> net/sctp/socket.c | 11 ++++---
> net/sctp/sysctl.c | 59 ++++++++++++++++++++++++++++++++++
> 8 files changed, 106 insertions(+), 38 deletions(-)
>
> diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
> index c7fc107..98ac0d7 100644
> --- a/Documentation/networking/ip-sysctl.txt
> +++ b/Documentation/networking/ip-sysctl.txt
> @@ -1514,6 +1514,20 @@ cookie_preserve_enable - BOOLEAN
>
> Default: 1
>
> +cookie_hmac_alg - STRING
> + Select the hmac algorithm used when generating the cookie value sent by
> + a listening sctp socket to a connecting client in the INIT-ACK chunk.
> + Valid values are:
> + * md5
> + * sha1
> + * none
> + Ability to assign md5 or sha1 as the selected alg is predicated on the
> + configuarion of those algorithms at build time (CONFIG_CRYPTO_MD5 and
> + CONFIG_CRYPTO_SHA1).
> +
> + Default: Dependent on configuration. MD5 if available, else SHA1 if
> + available, else none.
> +
> rcvbuf_policy - INTEGER
> Determines if the receive buffer is attributed to the socket or to
> association. SCTP supports the capability to create multiple
> diff --git a/include/net/netns/sctp.h b/include/net/netns/sctp.h
> index 5e5eb1f..3573a81 100644
> --- a/include/net/netns/sctp.h
> +++ b/include/net/netns/sctp.h
> @@ -62,6 +62,9 @@ struct netns_sctp {
> /* Whether Cookie Preservative is enabled(1) or not(0) */
> int cookie_preserve_enable;
>
> + /* The namespace default hmac alg */
> + char *sctp_hmac_alg;
> +
> /* Valid.Cookie.Life - 60 seconds */
> unsigned int valid_cookie_life;
>
> diff --git a/include/net/sctp/constants.h b/include/net/sctp/constants.h
> index d053d2e..c29707d 100644
> --- a/include/net/sctp/constants.h
> +++ b/include/net/sctp/constants.h
> @@ -312,14 +312,6 @@ enum { SCTP_MAX_GABS = 16 };
> * functions simpler to write.
> */
>
> -#if defined (CONFIG_SCTP_HMAC_MD5)
> -#define SCTP_COOKIE_HMAC_ALG "hmac(md5)"
> -#elif defined (CONFIG_SCTP_HMAC_SHA1)
> -#define SCTP_COOKIE_HMAC_ALG "hmac(sha1)"
> -#else
> -#define SCTP_COOKIE_HMAC_ALG NULL
> -#endif
> -
> /* These return values describe the success or failure of a number of
> * routines which form the lower interface to SCTP_outqueue.
> */
> diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
> index 0fef00f..ce5f957 100644
> --- a/include/net/sctp/structs.h
> +++ b/include/net/sctp/structs.h
> @@ -177,6 +177,7 @@ struct sctp_sock {
>
> /* Access to HMAC transform. */
> struct crypto_hash *hmac;
> + char *sctp_hmac_alg;
>
> /* What is our base endpointer? */
> struct sctp_endpoint *ep;
> diff --git a/net/sctp/Kconfig b/net/sctp/Kconfig
> index 126b014..a9edd2e 100644
> --- a/net/sctp/Kconfig
> +++ b/net/sctp/Kconfig
> @@ -9,7 +9,6 @@ menuconfig IP_SCTP
> select CRYPTO
> select CRYPTO_HMAC
> select CRYPTO_SHA1
> - select CRYPTO_MD5 if SCTP_HMAC_MD5
> select LIBCRC32C
> ---help---
> Stream Control Transmission Protocol
> @@ -68,33 +67,21 @@ config SCTP_DBG_OBJCNT
>
> If unsure, say N
>
> -choice
> - prompt "SCTP: Cookie HMAC Algorithm"
> - default SCTP_HMAC_MD5
> +config SCTP_COOKIE_HMAC_MD5
> + bool "Enable optional MD5 hmac cookie generation"
> help
> - HMAC algorithm to be used during association initialization. It
> - is strongly recommended to use HMAC-SHA1 or HMAC-MD5. See
> - configuration for Cryptographic API and enable those algorithms
> - to make usable by SCTP.
> -
> -config SCTP_HMAC_NONE
> - bool "None"
> - help
> - Choosing this disables the use of an HMAC during association
> - establishment. It is advised to use either HMAC-MD5 or HMAC-SHA1.
> -
> -config SCTP_HMAC_SHA1
> - bool "HMAC-SHA1"
> - help
> - Enable the use of HMAC-SHA1 during association establishment. It
> - is advised to use either HMAC-MD5 or HMAC-SHA1.
> -
> -config SCTP_HMAC_MD5
> - bool "HMAC-MD5"
> + Enable optional MD5 hmac based SCTP cookie generation
> + default y
> + select CRYPTO_HMAC if SCTP_COOKIE_HMAC_MD5
> + select CRYPTO_MD5 if SCTP_COOKIE_HMAC_MD5
> +
> +config SCTP_COOKIE_HMAC_SHA1
> + bool "Enable optional SHA1 hmac cookie generation"
> help
> - Enable the use of HMAC-MD5 during association establishment. It is
> - advised to use either HMAC-MD5 or HMAC-SHA1.
> + Enable optional SHA1 hmac based SCTP cookie generation
> + default y
> + select CRYPTO_HMAC if SCTP_COOKIE_HMAC_SHA1
> + select CRYPTO_SHA1 if SCTP_COOKIE_HMAC_SHA1
>
> -endchoice
>
> endif # IP_SCTP
> diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
> index 2d51842..456bc3d 100644
> --- a/net/sctp/protocol.c
> +++ b/net/sctp/protocol.c
> @@ -1190,6 +1190,15 @@ static int sctp_net_init(struct net *net)
> /* Whether Cookie Preservative is enabled(1) or not(0) */
> net->sctp.cookie_preserve_enable = 1;
>
> + /* Default sctp sockets to use md5 as their hmac alg */
> +#if defined (CONFIG_CRYPTO_MD5)
> + net->sctp.sctp_hmac_alg = "md5";
> +#elif defined (CONFIG_CRYPTO_SHA1)
> + net->sctp.sctp_hmac_alg = "sha1";
> +#else
> + net->sctp.sctp_hmac_alg = NULL;
> +#endif
> +
> /* Max.Burst - 4 */
> net->sctp.max_burst = SCTP_DEFAULT_MAX_BURST;
>
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index d37d24f..c388262 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -109,7 +109,6 @@ static int sctp_do_bind(struct sock *, union sctp_addr *, int);
> static int sctp_autobind(struct sock *sk);
> static void sctp_sock_migrate(struct sock *, struct sock *,
> struct sctp_association *, sctp_socket_type_t);
> -static char *sctp_hmac_alg = SCTP_COOKIE_HMAC_ALG;
>
> extern struct kmem_cache *sctp_bucket_cachep;
> extern long sysctl_sctp_mem[3];
> @@ -3889,6 +3888,8 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
> sp->default_rcv_context = 0;
> sp->max_burst = net->sctp.max_burst;
>
> + sp->sctp_hmac_alg = net->sctp.sctp_hmac_alg;
> +
> /* Initialize default setup parameters. These parameters
> * can be modified with the SCTP_INITMSG socket option or
> * overridden by the SCTP_INIT CMSG.
> @@ -5966,13 +5967,15 @@ SCTP_STATIC int sctp_listen_start(struct sock *sk, int backlog)
> struct sctp_sock *sp = sctp_sk(sk);
> struct sctp_endpoint *ep = sp->ep;
> struct crypto_hash *tfm = NULL;
> + char alg[32];
>
> /* Allocate HMAC for generating cookie. */
> - if (!sctp_sk(sk)->hmac && sctp_hmac_alg) {
> - tfm = crypto_alloc_hash(sctp_hmac_alg, 0, CRYPTO_ALG_ASYNC);
> + if (!sp->hmac && sp->sctp_hmac_alg) {
> + sprintf(alg, "hmac(%s)", sp->sctp_hmac_alg);
> + tfm = crypto_alloc_hash(alg, 0, CRYPTO_ALG_ASYNC);
> if (IS_ERR(tfm)) {
> net_info_ratelimited("failed to load transform for %s: %ld\n",
> - sctp_hmac_alg, PTR_ERR(tfm));
> + sp->sctp_hmac_alg, PTR_ERR(tfm));
> return -ENOSYS;
> }
> sctp_sk(sk)->hmac = tfm;
> diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
> index 70e3ba5..043889a 100644
> --- a/net/sctp/sysctl.c
> +++ b/net/sctp/sysctl.c
> @@ -62,6 +62,11 @@ extern long sysctl_sctp_mem[3];
> extern int sysctl_sctp_rmem[3];
> extern int sysctl_sctp_wmem[3];
>
> +static int proc_sctp_do_hmac_alg(ctl_table *ctl,
> + int write,
> + void __user *buffer, size_t *lenp,
> +
> + loff_t *ppos);
> static ctl_table sctp_table[] = {
> {
> .procname = "sctp_mem",
> @@ -147,6 +152,12 @@ static ctl_table sctp_net_table[] = {
> .proc_handler = proc_dointvec,
> },
> {
> + .procname = "cookie_hmac_alg",
> + .maxlen = 8,
> + .mode = 0644,
> + .proc_handler = proc_sctp_do_hmac_alg,
> + },
> + {
> .procname = "valid_cookie_life",
> .data = &init_net.sctp.valid_cookie_life,
> .maxlen = sizeof(unsigned int),
> @@ -289,6 +300,54 @@ static ctl_table sctp_net_table[] = {
> { /* sentinel */ }
> };
>
> +static int proc_sctp_do_hmac_alg(ctl_table *ctl,
> + int write,
> + void __user *buffer, size_t *lenp,
> + loff_t *ppos)
> +{
> + struct net *net = current->nsproxy->net_ns;
> + char tmp[8];
> + ctl_table tbl;
> + int ret;
> + int changed = 0;
> + char *none = "none";
> +
> + memset(&tbl, 0, sizeof(struct ctl_table));
> +
> + if (write) {
> + tbl.data = tmp;
> + tbl.maxlen = 8;
> + } else {
> + tbl.data = net->sctp.sctp_hmac_alg ? : none;
> + tbl.maxlen = strlen(tbl.data);
> + }
> + ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
> +
> + if (write) {
> +#ifdef CONFIG_CRYPTO_MD5
> + if (!strncmp(tmp, "md5", 3)) {
> + net->sctp.sctp_hmac_alg = "md5";
> + changed = 1;
> + }
> +#endif
> +#ifdef CONFIG_CRYPTO_SHA1
> + if (!strncmp(tmp, "sha1", 4)) {
> + net->sctp.sctp_hmac_alg = "sha1";
> + changed = 1;
> + }
> +#endif
> + if (!strncmp(tmp, "none", 4)) {
> + net->sctp.sctp_hmac_alg = NULL;
> + changed = 1;
> + }
> +
> + if (!changed)
> + ret = -EINVAL;
> + }
> +
> + return ret;
> +}
> +
> int sctp_sysctl_net_register(struct net *net)
> {
> struct ctl_table *table;
>
^ permalink raw reply
* Re: [PATCH] MAINTAINERS: Add myself to list of SCTP maintainers
From: Vlad Yasevich @ 2012-10-25 13:10 UTC (permalink / raw)
To: Neil Horman; +Cc: netdev, David S. Miller, linux-sctp
In-Reply-To: <1351106811-23601-1-git-send-email-nhorman@tuxdriver.com>
On 10/24/2012 03:26 PM, Neil Horman wrote:
> I've been messing with the code for a bit, and I figured Vlad could use a hand
> as interest in the protocol has picked up over the last year or so. I've asked
> him, and he doesn't seem too upset over the idea :)
>
> Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
> CC: Vlad Yasevich <vyasevich@gmail.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: linux-sctp@vger.kernel.org
Acked-by: Vlad Yasevich <vyasevich@gmail.com>
> ---
> MAINTAINERS | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 5655bcc..2463a0a 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -6352,6 +6352,7 @@ F: drivers/scsi/st*
> SCTP PROTOCOL
> M: Vlad Yasevich <vyasevich@gmail.com>
> M: Sridhar Samudrala <sri@us.ibm.com>
> +M: Neil Horman <nhorman@tuxdriver.com>
> L: linux-sctp@vger.kernel.org
> W: http://lksctp.sourceforge.net
> S: Maintained
>
^ permalink raw reply
* [PATCH iproute2 0/5] Teach ss to show sockets' shutdown state
From: Pavel Emelyanov @ 2012-10-25 13:16 UTC (permalink / raw)
To: Stephen Hemminger, Linux Netdev List
In the net-next sits a patch which extends the sock-diag subsys to
show the sockets' shutdown state. I propose to teach the ss tool to
print this info when requested with -e|--extended key.
The output will look like arrows at the end of each line, like this:
ESTAB 0 0 127.0.0.1:41705 127.0.0.1:12345 ino:143321 sk:ffff88003a8cea00 -->
ESTAB 0 0 127.0.0.1:46925 127.0.0.1:12346 ino:143322 sk:ffff88003a8ce4c0 <--
ESTAB 0 0 127.0.0.1:51678 127.0.0.1:12347 ino:143323 sk:ffff88003a8cdf80 ---
ESTAB 0 0 127.0.0.1:46911 127.0.0.1:12348 ino:143324 sk:ffff88003b7f05c0 <->
for SHUT_RD, SHUT_WR, SHUT_RDWR and non-shutdown sockets respectively.
In order to do so, it's also required to implement support for the
newer sock-diag in tcp and udp netlink code. I did it before, but
broke compatibility with older kernels (those without sock-diag).
Now this is fixed (checked on 2.6.40 kernel).
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
^ permalink raw reply
* [PATCH 1/5] ss: Rename some tcp- names into inet-
From: Pavel Emelyanov @ 2012-10-25 13:18 UTC (permalink / raw)
To: Stephen Hemminger, Linux Netdev List
In-Reply-To: <50893BAF.7030500@parallels.com>
The sock-diag is capable to diag udp sockets as well. Prepare the
ss code for this by first renaming soon-to-be-generic tcp-s names
into inet-s.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
---
misc/ss.c | 21 ++++++++++++---------
1 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index d00d3e7..3bceedf 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -1431,7 +1431,7 @@ static void tcp_show_info(const struct nlmsghdr *nlh, struct inet_diag_msg *r)
}
}
-static int tcp_show_sock(struct nlmsghdr *nlh, struct filter *f)
+static int inet_show_sock(struct nlmsghdr *nlh, struct filter *f)
{
struct inet_diag_msg *r = NLMSG_DATA(nlh);
struct tcpstat s;
@@ -1495,7 +1495,7 @@ static int tcp_show_sock(struct nlmsghdr *nlh, struct filter *f)
return 0;
}
-static int tcp_show_netlink(struct filter *f, FILE *dump_fp, int socktype)
+static int inet_show_netlink(struct filter *f, FILE *dump_fp, int protocol)
{
int fd;
struct sockaddr_nl nladdr;
@@ -1517,7 +1517,10 @@ static int tcp_show_netlink(struct filter *f, FILE *dump_fp, int socktype)
nladdr.nl_family = AF_NETLINK;
req.nlh.nlmsg_len = sizeof(req);
- req.nlh.nlmsg_type = socktype;
+ if (protocol == IPPROTO_TCP)
+ req.nlh.nlmsg_type = TCPDIAG_GETSOCK;
+ else
+ req.nlh.nlmsg_type = DCCPDIAG_GETSOCK;
req.nlh.nlmsg_flags = NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST;
req.nlh.nlmsg_pid = 0;
req.nlh.nlmsg_seq = 123456;
@@ -1626,7 +1629,7 @@ static int tcp_show_netlink(struct filter *f, FILE *dump_fp, int socktype)
h = NLMSG_NEXT(h, status);
continue;
}
- err = tcp_show_sock(h, NULL);
+ err = inet_show_sock(h, NULL);
if (err < 0) {
close(fd);
return err;
@@ -1699,7 +1702,7 @@ static int tcp_show_netlink_file(struct filter *f)
return -1;
}
- err = tcp_show_sock(h, f);
+ err = inet_show_sock(h, f);
if (err < 0)
return err;
}
@@ -1717,7 +1720,7 @@ static int tcp_show(struct filter *f, int socktype)
return tcp_show_netlink_file(f);
if (!getenv("PROC_NET_TCP") && !getenv("PROC_ROOT")
- && tcp_show_netlink(f, NULL, socktype) == 0)
+ && inet_show_netlink(f, NULL, socktype) == 0)
return 0;
/* Sigh... We have to parse /proc/net/tcp... */
@@ -2980,7 +2983,7 @@ int main(int argc, char *argv[])
exit(-1);
}
}
- tcp_show_netlink(¤t_filter, dump_fp, TCPDIAG_GETSOCK);
+ inet_show_netlink(¤t_filter, dump_fp, IPPROTO_TCP);
fflush(dump_fp);
exit(0);
}
@@ -3048,8 +3051,8 @@ int main(int argc, char *argv[])
if (current_filter.dbs & (1<<UDP_DB))
udp_show(¤t_filter);
if (current_filter.dbs & (1<<TCP_DB))
- tcp_show(¤t_filter, TCPDIAG_GETSOCK);
+ tcp_show(¤t_filter, IPPROTO_TCP);
if (current_filter.dbs & (1<<DCCP_DB))
- tcp_show(¤t_filter, DCCPDIAG_GETSOCK);
+ tcp_show(¤t_filter, IPPROTO_DCCP);
return 0;
}
--
1.7.1
^ permalink raw reply related
* [PATCH 2/5] ss: Split inet_show_netlink into parts
From: Pavel Emelyanov @ 2012-10-25 13:21 UTC (permalink / raw)
To: Stephen Hemminger, Linux Netdev List
In-Reply-To: <50893BAF.7030500@parallels.com>
The existing function inet_show_netlink sends tcp-diag request and
then receives back the response and prints it on the screen.
The sock-diag and legacy tcp-diag have different request types, but
report sockets in the same format. In order to support both it's
convenient to split the code into sending and receiving parts.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
---
misc/ss.c | 27 +++++++++++++++++++++------
1 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index 3bceedf..27feeb8 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -1495,9 +1495,8 @@ static int inet_show_sock(struct nlmsghdr *nlh, struct filter *f)
return 0;
}
-static int inet_show_netlink(struct filter *f, FILE *dump_fp, int protocol)
+static int tcpdiag_send(int fd, int protocol, struct filter *f)
{
- int fd;
struct sockaddr_nl nladdr;
struct {
struct nlmsghdr nlh;
@@ -1507,12 +1506,8 @@ static int inet_show_netlink(struct filter *f, FILE *dump_fp, int protocol)
int bclen;
struct msghdr msg;
struct rtattr rta;
- char buf[8192];
struct iovec iov[3];
- if ((fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_INET_DIAG)) < 0)
- return -1;
-
memset(&nladdr, 0, sizeof(nladdr));
nladdr.nl_family = AF_NETLINK;
@@ -1563,6 +1558,26 @@ static int inet_show_netlink(struct filter *f, FILE *dump_fp, int protocol)
return -1;
}
+ return 0;
+}
+
+static int inet_show_netlink(struct filter *f, FILE *dump_fp, int protocol)
+{
+ int fd;
+ struct sockaddr_nl nladdr;
+ struct msghdr msg;
+ char buf[8192];
+ struct iovec iov[3];
+
+ if ((fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_INET_DIAG)) < 0)
+ return -1;
+
+ if (tcpdiag_send(fd, protocol, f))
+ return -1;
+
+ memset(&nladdr, 0, sizeof(nladdr));
+ nladdr.nl_family = AF_NETLINK;
+
iov[0] = (struct iovec){
.iov_base = buf,
.iov_len = sizeof(buf)
--
1.7.1
^ permalink raw reply related
* [PATCH 3/5] ss: Support sock-diag
From: Pavel Emelyanov @ 2012-10-25 13:23 UTC (permalink / raw)
To: Stephen Hemminger, Linux Netdev List
In-Reply-To: <50893BAF.7030500@parallels.com>
That is -- write the code, that sends diag request in new format. It's
mostly copied from tcp-diag code. Plus, sock-diag differentiates sockets
by families, thus we have to send two requests sequentially.
If we fail to submit new sock-diag request, try to fall-back and submit
the legacy tcp-diag one.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
---
misc/ss.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 87 insertions(+), 8 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index 27feeb8..1ceb026 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -1561,9 +1561,76 @@ static int tcpdiag_send(int fd, int protocol, struct filter *f)
return 0;
}
+static int sockdiag_send(int family, int fd, int protocol, struct filter *f)
+{
+ struct sockaddr_nl nladdr;
+ struct {
+ struct nlmsghdr nlh;
+ struct inet_diag_req_v2 r;
+ } req;
+ char *bc = NULL;
+ int bclen;
+ struct msghdr msg;
+ struct rtattr rta;
+ struct iovec iov[3];
+
+ if (family == PF_UNSPEC)
+ return tcpdiag_send(fd, protocol, f);
+
+ memset(&nladdr, 0, sizeof(nladdr));
+ nladdr.nl_family = AF_NETLINK;
+
+ req.nlh.nlmsg_len = sizeof(req);
+ req.nlh.nlmsg_type = SOCK_DIAG_BY_FAMILY;
+ req.nlh.nlmsg_flags = NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST;
+ req.nlh.nlmsg_pid = 0;
+ req.nlh.nlmsg_seq = 123456;
+ memset(&req.r, 0, sizeof(req.r));
+ req.r.sdiag_family = family;
+ req.r.sdiag_protocol = protocol;
+ req.r.idiag_states = f->states;
+ if (show_mem) {
+ req.r.idiag_ext |= (1<<(INET_DIAG_MEMINFO-1));
+ req.r.idiag_ext |= (1<<(INET_DIAG_SKMEMINFO-1));
+ }
+
+ if (show_tcpinfo) {
+ req.r.idiag_ext |= (1<<(INET_DIAG_INFO-1));
+ req.r.idiag_ext |= (1<<(INET_DIAG_VEGASINFO-1));
+ req.r.idiag_ext |= (1<<(INET_DIAG_CONG-1));
+ }
+
+ iov[0] = (struct iovec){
+ .iov_base = &req,
+ .iov_len = sizeof(req)
+ };
+ if (f->f) {
+ bclen = ssfilter_bytecompile(f->f, &bc);
+ rta.rta_type = INET_DIAG_REQ_BYTECODE;
+ rta.rta_len = RTA_LENGTH(bclen);
+ iov[1] = (struct iovec){ &rta, sizeof(rta) };
+ iov[2] = (struct iovec){ bc, bclen };
+ req.nlh.nlmsg_len += RTA_LENGTH(bclen);
+ }
+
+ msg = (struct msghdr) {
+ .msg_name = (void*)&nladdr,
+ .msg_namelen = sizeof(nladdr),
+ .msg_iov = iov,
+ .msg_iovlen = f->f ? 3 : 1,
+ };
+
+ if (sendmsg(fd, &msg, 0) < 0) {
+ close(fd);
+ return -1;
+ }
+
+ return 0;
+}
+
static int inet_show_netlink(struct filter *f, FILE *dump_fp, int protocol)
{
- int fd;
+ int fd, family;
struct sockaddr_nl nladdr;
struct msghdr msg;
char buf[8192];
@@ -1572,7 +1639,9 @@ static int inet_show_netlink(struct filter *f, FILE *dump_fp, int protocol)
if ((fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_INET_DIAG)) < 0)
return -1;
- if (tcpdiag_send(fd, protocol, f))
+ family = PF_INET;
+again:
+ if (sockdiag_send(family, fd, protocol, f))
return -1;
memset(&nladdr, 0, sizeof(nladdr));
@@ -1620,15 +1689,19 @@ static int inet_show_netlink(struct filter *f, FILE *dump_fp, int protocol)
h->nlmsg_seq != 123456)
goto skip_it;
- if (h->nlmsg_type == NLMSG_DONE) {
- close(fd);
- return 0;
- }
+ if (h->nlmsg_type == NLMSG_DONE)
+ goto done;
+
if (h->nlmsg_type == NLMSG_ERROR) {
struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(h);
if (h->nlmsg_len < NLMSG_LENGTH(sizeof(struct nlmsgerr))) {
fprintf(stderr, "ERROR truncated\n");
} else {
+ if (family != PF_UNSPEC) {
+ family = PF_UNSPEC;
+ goto again;
+ }
+
errno = -err->error;
if (errno == EOPNOTSUPP) {
close(fd);
@@ -1636,8 +1709,8 @@ static int inet_show_netlink(struct filter *f, FILE *dump_fp, int protocol)
}
perror("TCPDIAG answers");
}
- close(fd);
- return 0;
+
+ goto done;
}
if (!dump_fp) {
if (!(f->families & (1<<r->idiag_family))) {
@@ -1663,6 +1736,12 @@ skip_it:
exit(1);
}
}
+done:
+ if (family == PF_INET) {
+ family = PF_INET6;
+ goto again;
+ }
+
close(fd);
return 0;
}
--
1.7.1
^ permalink raw reply related
* [PATCH 4/5] ss: Get udp sockets info via sock-diag
From: Pavel Emelyanov @ 2012-10-25 13:24 UTC (permalink / raw)
To: Stephen Hemminger, Linux Netdev List
In-Reply-To: <50893BAF.7030500@parallels.com>
Now everything is prepared for it, so the patch is straightforward.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
---
misc/ss.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index 1ceb026..a0ab2e9 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -1508,6 +1508,9 @@ static int tcpdiag_send(int fd, int protocol, struct filter *f)
struct rtattr rta;
struct iovec iov[3];
+ if (protocol == IPPROTO_UDP)
+ return -1;
+
memset(&nladdr, 0, sizeof(nladdr));
nladdr.nl_family = AF_NETLINK;
@@ -1976,6 +1979,10 @@ int udp_show(struct filter *f)
{
FILE *fp = NULL;
+ if (!getenv("PROC_NET_UDP") && !getenv("PROC_ROOT")
+ && inet_show_netlink(f, NULL, IPPROTO_UDP) == 0)
+ return 0;
+
dg_proto = UDP_PROTO;
if (f->families&(1<<AF_INET)) {
--
1.7.1
^ permalink raw reply related
* [PATCH 5/5] ss: Show inet and unix sockets' shutdown state
From: Pavel Emelyanov @ 2012-10-25 13:26 UTC (permalink / raw)
To: Stephen Hemminger, Linux Netdev List
In-Reply-To: <50893BAF.7030500@parallels.com>
To see this we need kernel >=3.7 with _SHUTDOWN nlarrts in diag messages.
The output will look like arrows at the end of each line, like this:
ESTAB 0 0 127.0.0.1:41705 127.0.0.1:12345 ino:143321 sk:ffff88003a8cea00 -->
ESTAB 0 0 127.0.0.1:46925 127.0.0.1:12346 ino:143322 sk:ffff88003a8ce4c0 <--
ESTAB 0 0 127.0.0.1:51678 127.0.0.1:12347 ino:143323 sk:ffff88003a8cdf80 ---
ESTAB 0 0 127.0.0.1:46911 127.0.0.1:12348 ino:143324 sk:ffff88003b7f05c0 <->
for SHUT_RD, SHUT_WR, SHUT_RDWR and non-shutdown sockets respectively.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
---
include/linux/inet_diag.h | 3 ++-
include/linux/unix_diag.h | 1 +
misc/ss.c | 26 ++++++++++++++++++++------
3 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/include/linux/inet_diag.h b/include/linux/inet_diag.h
index 8c469af..bbde90f 100644
--- a/include/linux/inet_diag.h
+++ b/include/linux/inet_diag.h
@@ -109,9 +109,10 @@ enum {
INET_DIAG_TOS,
INET_DIAG_TCLASS,
INET_DIAG_SKMEMINFO,
+ INET_DIAG_SHUTDOWN,
};
-#define INET_DIAG_MAX INET_DIAG_SKMEMINFO
+#define INET_DIAG_MAX INET_DIAG_SHUTDOWN
/* INET_DIAG_MEM */
diff --git a/include/linux/unix_diag.h b/include/linux/unix_diag.h
index b1d2bf1..b8a2494 100644
--- a/include/linux/unix_diag.h
+++ b/include/linux/unix_diag.h
@@ -37,6 +37,7 @@ enum {
UNIX_DIAG_ICONS,
UNIX_DIAG_RQLEN,
UNIX_DIAG_MEMINFO,
+ UNIX_DIAG_SHUTDOWN,
UNIX_DIAG_MAX,
};
diff --git a/misc/ss.c b/misc/ss.c
index a0ab2e9..0b70ee6 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -1327,15 +1327,12 @@ static char *sprint_bw(char *buf, double bw)
return buf;
}
-static void tcp_show_info(const struct nlmsghdr *nlh, struct inet_diag_msg *r)
+static void tcp_show_info(const struct nlmsghdr *nlh, struct inet_diag_msg *r,
+ struct rtattr *tb[])
{
- struct rtattr * tb[INET_DIAG_MAX+1];
char b1[64];
double rtt = 0;
- parse_rtattr(tb, INET_DIAG_MAX, (struct rtattr*)(r+1),
- nlh->nlmsg_len - NLMSG_LENGTH(sizeof(*r)));
-
if (tb[INET_DIAG_SKMEMINFO]) {
const __u32 *skmeminfo = RTA_DATA(tb[INET_DIAG_SKMEMINFO]);
@@ -1435,6 +1432,10 @@ static int inet_show_sock(struct nlmsghdr *nlh, struct filter *f)
{
struct inet_diag_msg *r = NLMSG_DATA(nlh);
struct tcpstat s;
+ struct rtattr * tb[INET_DIAG_MAX+1];
+
+ parse_rtattr(tb, INET_DIAG_MAX, (struct rtattr*)(r+1),
+ nlh->nlmsg_len - NLMSG_LENGTH(sizeof(*r)));
s.state = r->idiag_state;
s.local.family = s.remote.family = r->idiag_family;
@@ -1484,10 +1485,15 @@ static int inet_show_sock(struct nlmsghdr *nlh, struct filter *f)
if (r->id.idiag_cookie[1] != 0)
printf("%08x", r->id.idiag_cookie[1]);
printf("%08x", r->id.idiag_cookie[0]);
+ if (tb[INET_DIAG_SHUTDOWN]) {
+ unsigned char mask;
+ mask = *(__u8 *)RTA_DATA(tb[INET_DIAG_SHUTDOWN]);
+ printf(" %c-%c", mask & 1 ? '-' : '<', mask & 2 ? '-' : '>');
+ }
}
if (show_mem || show_tcpinfo) {
printf("\n\t");
- tcp_show_info(nlh, r);
+ tcp_show_info(nlh, r, tb);
}
printf("\n");
@@ -2184,6 +2190,14 @@ static int unix_show_sock(struct nlmsghdr *nlh, struct filter *f)
printf(" users:(%s)", ubuf);
}
+ if (show_details) {
+ if (tb[UNIX_DIAG_SHUTDOWN]) {
+ unsigned char mask;
+ mask = *(__u8 *)RTA_DATA(tb[UNIX_DIAG_SHUTDOWN]);
+ printf(" %c-%c", mask & 1 ? '-' : '<', mask & 2 ? '-' : '>');
+ }
+ }
+
printf("\n");
return 0;
--
1.7.1
^ permalink raw reply related
* [PATCH v1 0/5] Rework net_cls update socket logic
From: Daniel Wagner @ 2012-10-25 14:16 UTC (permalink / raw)
To: netdev-u79uwXL29TY76Z2rM5mHXA, cgroups-u79uwXL29TY76Z2rM5mHXA
Cc: Daniel Wagner
From: Daniel Wagner <daniel.wagner-98C5kh4wR6ohFhg+JK9F0w@public.gmane.org>
Hi,
I updated this series according the feedback I got. I am not sure
if I did the 'revert' patch correctly (patch #3).
cheers,
daniel
orignal cover letter:
This series updates net_cls to use the same socket update logic as
net_prio. With this change sock_update_classid() is not called from
recvmsg, sendmsg and friends anymore. This seems to be a good idea.
Credit goes to John Fastabend for this work.
The patches are against net-next.
Daniel Wagner (5):
cgroup: net_prio: Mark local used function static
cgroup: net_cls: Fix local variable type decleration
cgroup: net_cls: Remove rcu_read_lock/unlock
cgroup: net_cls: Pass in task to sock_update_classid()
cgroup: net_cls: Rework update socket logic
drivers/net/tun.c | 3 ---
include/net/cls_cgroup.h | 4 ++--
net/core/netprio_cgroup.c | 2 +-
net/core/sock.c | 8 +++-----
net/sched/cls_cgroup.c | 24 ++++++++++++++++++++++++
net/socket.c | 8 --------
6 files changed, 30 insertions(+), 19 deletions(-)
--
1.8.0.rc0
^ permalink raw reply
* [PATCH v1 1/5] cgroup: net_prio: Mark local used function static
From: Daniel Wagner @ 2012-10-25 14:16 UTC (permalink / raw)
To: netdev-u79uwXL29TY76Z2rM5mHXA, cgroups-u79uwXL29TY76Z2rM5mHXA
Cc: Daniel Wagner, David S. Miller, John Fastabend, Li Zefan,
Neil Horman, Tejun Heo
In-Reply-To: <1351174619-5096-1-git-send-email-wagi-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
From: Daniel Wagner <daniel.wagner-98C5kh4wR6ohFhg+JK9F0w@public.gmane.org>
net_prio_attach() is only access via cgroup_subsys callbacks,
therefore we can reduce the visibility of this function.
Signed-off-by: Daniel Wagner <daniel.wagner-98C5kh4wR6ohFhg+JK9F0w@public.gmane.org>
Cc: "David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
Cc: John Fastabend <john.r.fastabend-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Cc: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
Cc: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: <netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Cc: <cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
---
net/core/netprio_cgroup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/netprio_cgroup.c b/net/core/netprio_cgroup.c
index 79285a3..847c02b 100644
--- a/net/core/netprio_cgroup.c
+++ b/net/core/netprio_cgroup.c
@@ -248,7 +248,7 @@ static int update_netprio(const void *v, struct file *file, unsigned n)
return 0;
}
-void net_prio_attach(struct cgroup *cgrp, struct cgroup_taskset *tset)
+static void net_prio_attach(struct cgroup *cgrp, struct cgroup_taskset *tset)
{
struct task_struct *p;
void *v;
--
1.8.0.rc0
^ permalink raw reply related
* [PATCH v1 4/5] cgroup: net_cls: Pass in task to sock_update_classid()
From: Daniel Wagner @ 2012-10-25 14:16 UTC (permalink / raw)
To: netdev-u79uwXL29TY76Z2rM5mHXA, cgroups-u79uwXL29TY76Z2rM5mHXA
Cc: Daniel Wagner, David S. Miller, Michael S. Tsirkin, Eric Dumazet,
Glauber Costa, Joe Perches, Neil Horman, Stanislav Kinsbursky,
Tejun Heo
In-Reply-To: <1351174619-5096-1-git-send-email-wagi-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
From: Daniel Wagner <daniel.wagner-98C5kh4wR6ohFhg+JK9F0w@public.gmane.org>
sock_update_classid() assumes that the update operation always are
applied on the current task. sock_update_classid() needs to know on
which tasks to work on in order to be able to migrate task between
cgroups using the struct cgroup_subsys attach() callback.
Signed-off-by: Daniel Wagner <daniel.wagner-98C5kh4wR6ohFhg+JK9F0w@public.gmane.org>
Cc: "David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
Cc: "Michael S. Tsirkin" <mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Eric Dumazet <edumazet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Cc: Glauber Costa <glommer-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
Cc: Joe Perches <joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
Cc: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
Cc: Stanislav Kinsbursky <skinsbursky-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
Cc: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: <netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Cc: <cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
---
drivers/net/tun.c | 2 +-
include/net/cls_cgroup.h | 2 +-
net/core/sock.c | 6 +++---
net/socket.c | 8 ++++----
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 0873cdc..e4858b2 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -587,7 +587,7 @@ static struct sk_buff *tun_alloc_skb(struct tun_struct *tun,
struct sk_buff *skb;
int err;
- sock_update_classid(sk);
+ sock_update_classid(sk, current);
/* Under a page? Don't bother with paged skb. */
if (prepad + len < PAGE_SIZE || !linear)
diff --git a/include/net/cls_cgroup.h b/include/net/cls_cgroup.h
index 0fee061..571de6e 100644
--- a/include/net/cls_cgroup.h
+++ b/include/net/cls_cgroup.h
@@ -24,7 +24,7 @@ struct cgroup_cls_state
u32 classid;
};
-extern void sock_update_classid(struct sock *sk);
+extern void sock_update_classid(struct sock *sk, struct task_struct *task);
#if IS_BUILTIN(CONFIG_NET_CLS_CGROUP)
static inline u32 task_cls_classid(struct task_struct *p)
diff --git a/net/core/sock.c b/net/core/sock.c
index 9fedbbf..0a023b8 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1217,11 +1217,11 @@ static void sk_prot_free(struct proto *prot, struct sock *sk)
#ifdef CONFIG_CGROUPS
#if IS_ENABLED(CONFIG_NET_CLS_CGROUP)
-void sock_update_classid(struct sock *sk)
+void sock_update_classid(struct sock *sk, struct task_struct *task)
{
u32 classid;
- classid = task_cls_classid(current);
+ classid = task_cls_classid(task);
if (classid != sk->sk_classid)
sk->sk_classid = classid;
}
@@ -1264,7 +1264,7 @@ struct sock *sk_alloc(struct net *net, int family, gfp_t priority,
sock_net_set(sk, get_net(net));
atomic_set(&sk->sk_wmem_alloc, 1);
- sock_update_classid(sk);
+ sock_update_classid(sk, current);
sock_update_netprioidx(sk, current);
}
diff --git a/net/socket.c b/net/socket.c
index d92c490..f1a481a 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -620,7 +620,7 @@ static inline int __sock_sendmsg_nosec(struct kiocb *iocb, struct socket *sock,
{
struct sock_iocb *si = kiocb_to_siocb(iocb);
- sock_update_classid(sock->sk);
+ sock_update_classid(sock->sk, current);
si->sock = sock;
si->scm = NULL;
@@ -784,7 +784,7 @@ static inline int __sock_recvmsg_nosec(struct kiocb *iocb, struct socket *sock,
{
struct sock_iocb *si = kiocb_to_siocb(iocb);
- sock_update_classid(sock->sk);
+ sock_update_classid(sock->sk, current);
si->sock = sock;
si->scm = NULL;
@@ -896,7 +896,7 @@ static ssize_t sock_splice_read(struct file *file, loff_t *ppos,
if (unlikely(!sock->ops->splice_read))
return -EINVAL;
- sock_update_classid(sock->sk);
+ sock_update_classid(sock->sk, current);
return sock->ops->splice_read(sock, ppos, pipe, len, flags);
}
@@ -3437,7 +3437,7 @@ EXPORT_SYMBOL(kernel_setsockopt);
int kernel_sendpage(struct socket *sock, struct page *page, int offset,
size_t size, int flags)
{
- sock_update_classid(sock->sk);
+ sock_update_classid(sock->sk, current);
if (sock->ops->sendpage)
return sock->ops->sendpage(sock, page, offset, size, flags);
--
1.8.0.rc0
^ permalink raw reply related
* [PATCH v1 2/5] cgroup: net_cls: Fix local variable type decleration
From: Daniel Wagner @ 2012-10-25 14:16 UTC (permalink / raw)
To: netdev, cgroups; +Cc: Daniel Wagner, David S. Miller, Li Zefan, Tejun Heo
In-Reply-To: <1351174619-5096-1-git-send-email-wagi@monom.org>
From: Daniel Wagner <daniel.wagner@bmw-carit.de>
The classid type used throughout the kernel is u32.
Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: <netdev@vger.kernel.org>
Cc: <cgroups@vger.kernel.org>
---
include/net/cls_cgroup.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/net/cls_cgroup.h b/include/net/cls_cgroup.h
index b6a6eeb..0fee061 100644
--- a/include/net/cls_cgroup.h
+++ b/include/net/cls_cgroup.h
@@ -29,7 +29,7 @@ extern void sock_update_classid(struct sock *sk);
#if IS_BUILTIN(CONFIG_NET_CLS_CGROUP)
static inline u32 task_cls_classid(struct task_struct *p)
{
- int classid;
+ u32 classid;
if (in_interrupt())
return 0;
--
1.8.0.rc0
^ permalink raw reply related
* [PATCH v1 3/5] cgroup: net_cls: Remove rcu_read_lock/unlock
From: Daniel Wagner @ 2012-10-25 14:16 UTC (permalink / raw)
To: netdev, cgroups
Cc: Daniel Wagner, David S. Miller, Eric Dumazet, Glauber Costa,
Li Zefan, Neil Horman, Paul E. McKenney, Tejun Heo
In-Reply-To: <1351174619-5096-1-git-send-email-wagi@monom.org>
From: Daniel Wagner <daniel.wagner@bmw-carit.de>
As Eric pointed out:
"Hey task_cls_classid() has its own rcu protection since commit
3fb5a991916091a908d (cls_cgroup: Fix rcu lockdep warning)
So we can safely revert Paul commit (1144182a8757f2a1)
(We no longer need rcu_read_lock/unlock here)"
Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Glauber Costa <glommer@parallels.com>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: netdev@vger.kernel.org
Cc: cgroups@vger.kernel.org
---
net/core/sock.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/net/core/sock.c b/net/core/sock.c
index c49412c..9fedbbf 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1221,9 +1221,7 @@ void sock_update_classid(struct sock *sk)
{
u32 classid;
- rcu_read_lock(); /* doing current task, which cannot vanish. */
classid = task_cls_classid(current);
- rcu_read_unlock();
if (classid != sk->sk_classid)
sk->sk_classid = classid;
}
--
1.8.0.rc0
^ permalink raw reply related
* [PATCH v1 5/5] cgroup: net_cls: Rework update socket logic
From: Daniel Wagner @ 2012-10-25 14:16 UTC (permalink / raw)
To: netdev, cgroups
Cc: Daniel Wagner, Li Zefan, David S. Miller, Michael S. Tsirkin,
Jamal Hadi Salim, Joe Perches, John Fastabend, Neil Horman,
Stanislav Kinsbursky, Tejun Heo
In-Reply-To: <1351174619-5096-1-git-send-email-wagi@monom.org>
From: Daniel Wagner <daniel.wagner@bmw-carit.de>
The cgroup logic part of net_cls is very similar as the one in
net_prio. Let's stream line the net_cls logic with the net_prio one.
The net_prio update logic was changed by following commit (note there
were some changes necessary later on)
commit 406a3c638ce8b17d9704052c07955490f732c2b8
Author: John Fastabend <john.r.fastabend@intel.com>
Date: Fri Jul 20 10:39:25 2012 +0000
net: netprio_cgroup: rework update socket logic
Instead of updating the sk_cgrp_prioidx struct field on every send
this only updates the field when a task is moved via cgroup
infrastructure.
This allows sockets that may be used by a kernel worker thread
to be managed. For example in the iscsi case today a user can
put iscsid in a netprio cgroup and control traffic will be sent
with the correct sk_cgrp_prioidx value set but as soon as data
is sent the kernel worker thread isssues a send and sk_cgrp_prioidx
is updated with the kernel worker threads value which is the
default case.
It seems more correct to only update the field when the user
explicitly sets it via control group infrastructure. This allows
the users to manage sockets that may be used with other threads.
Since classid is now updated when the task is moved between the
cgroups, we don't have to call sock_update_classid() from various
places to ensure we always using the latest classid value.
[v2: Use iterate_fd() instead of open coding]
Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
Cc: Li Zefan <lizefan@huawei.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Joe Perches <joe@perches.com>
Cc: John Fastabend <john.r.fastabend@intel.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: Stanislav Kinsbursky <skinsbursky@parallels.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: <netdev@vger.kernel.org>
Cc: <cgroups@vger.kernel.org>
---
drivers/net/tun.c | 3 ---
net/sched/cls_cgroup.c | 24 ++++++++++++++++++++++++
net/socket.c | 8 --------
3 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index e4858b2..3157519 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -68,7 +68,6 @@
#include <net/netns/generic.h>
#include <net/rtnetlink.h>
#include <net/sock.h>
-#include <net/cls_cgroup.h>
#include <asm/uaccess.h>
@@ -587,8 +586,6 @@ static struct sk_buff *tun_alloc_skb(struct tun_struct *tun,
struct sk_buff *skb;
int err;
- sock_update_classid(sk, current);
-
/* Under a page? Don't bother with paged skb. */
if (prepad + len < PAGE_SIZE || !linear)
linear = len;
diff --git a/net/sched/cls_cgroup.c b/net/sched/cls_cgroup.c
index 2ecde22..709b0fb 100644
--- a/net/sched/cls_cgroup.c
+++ b/net/sched/cls_cgroup.c
@@ -17,6 +17,7 @@
#include <linux/skbuff.h>
#include <linux/cgroup.h>
#include <linux/rcupdate.h>
+#include <linux/fdtable.h>
#include <net/rtnetlink.h>
#include <net/pkt_cls.h>
#include <net/sock.h>
@@ -53,6 +54,28 @@ static void cgrp_destroy(struct cgroup *cgrp)
kfree(cgrp_cls_state(cgrp));
}
+static int update_classid(const void *v, struct file *file, unsigned n)
+{
+ int err;
+ struct socket *sock = sock_from_file(file, &err);
+ if (sock)
+ sock->sk->sk_classid = (u32)(unsigned long)v;
+ return 0;
+}
+
+static void cgrp_attach(struct cgroup *cgrp, struct cgroup_taskset *tset)
+{
+ struct task_struct *p;
+ void *v;
+
+ cgroup_taskset_for_each(p, cgrp, tset) {
+ task_lock(p);
+ v = (void *)(unsigned long)task_cls_classid(p);
+ iterate_fd(p->files, 0, update_classid, v);
+ task_unlock(p);
+ }
+}
+
static u64 read_classid(struct cgroup *cgrp, struct cftype *cft)
{
return cgrp_cls_state(cgrp)->classid;
@@ -77,6 +100,7 @@ struct cgroup_subsys net_cls_subsys = {
.name = "net_cls",
.create = cgrp_create,
.destroy = cgrp_destroy,
+ .attach = cgrp_attach,
.subsys_id = net_cls_subsys_id,
.base_cftypes = ss_files,
.module = THIS_MODULE,
diff --git a/net/socket.c b/net/socket.c
index f1a481a..2ca51c7 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -620,8 +620,6 @@ static inline int __sock_sendmsg_nosec(struct kiocb *iocb, struct socket *sock,
{
struct sock_iocb *si = kiocb_to_siocb(iocb);
- sock_update_classid(sock->sk, current);
-
si->sock = sock;
si->scm = NULL;
si->msg = msg;
@@ -784,8 +782,6 @@ static inline int __sock_recvmsg_nosec(struct kiocb *iocb, struct socket *sock,
{
struct sock_iocb *si = kiocb_to_siocb(iocb);
- sock_update_classid(sock->sk, current);
-
si->sock = sock;
si->scm = NULL;
si->msg = msg;
@@ -896,8 +892,6 @@ static ssize_t sock_splice_read(struct file *file, loff_t *ppos,
if (unlikely(!sock->ops->splice_read))
return -EINVAL;
- sock_update_classid(sock->sk, current);
-
return sock->ops->splice_read(sock, ppos, pipe, len, flags);
}
@@ -3437,8 +3431,6 @@ EXPORT_SYMBOL(kernel_setsockopt);
int kernel_sendpage(struct socket *sock, struct page *page, int offset,
size_t size, int flags)
{
- sock_update_classid(sock->sk, current);
-
if (sock->ops->sendpage)
return sock->ops->sendpage(sock, page, offset, size, flags);
--
1.8.0.rc0
^ permalink raw reply related
* [PATCH] isdn: remove dead code
From: Alan Cox @ 2012-10-25 14:30 UTC (permalink / raw)
To: isdn, netdev
From: Alan Cox <alan@linux.intel.com>
multi is assigned to 0 and then acts as a constant. Remove the dead
code.
Signed-off-by: Alan Cox <alan@linux.intel.com>
---
drivers/isdn/mISDN/l1oip_core.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/isdn/mISDN/l1oip_core.c b/drivers/isdn/mISDN/l1oip_core.c
index db50f78..f8e405c 100644
--- a/drivers/isdn/mISDN/l1oip_core.c
+++ b/drivers/isdn/mISDN/l1oip_core.c
@@ -277,7 +277,6 @@ l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask,
u16 timebase, u8 *buf, int len)
{
u8 *p;
- int multi = 0;
u8 frame[len + 32];
struct socket *socket = NULL;
@@ -317,9 +316,7 @@ l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask,
*p++ = hc->id >> 8;
*p++ = hc->id;
}
- *p++ = (multi == 1) ? 0x80 : 0x00 + channel; /* m-flag, channel */
- if (multi == 1)
- *p++ = len; /* length */
+ *p++ = 0x00 + channel; /* m-flag, channel */
*p++ = timebase >> 8; /* time base */
*p++ = timebase;
^ permalink raw reply related
* Re: switching network namespace midway
From: Benjamin LaHaise @ 2012-10-25 14:38 UTC (permalink / raw)
To: Eric W. Biederman; +Cc: rsa, netdev
In-Reply-To: <87ip9zqqlv.fsf@xmission.com>
Hello Eric,
On Wed, Oct 24, 2012 at 06:37:16PM -0700, Eric W. Biederman wrote:
> Yes. Although L2TP is not an example of code I would copy. Any other
> tunnel would be better. I haven't looked closely at L2TP but it keeps
> popping up as a poster child for small little network namespace bugs
> that I don't want to think about.
Agreed.
> Last I looked to use L2TP it required a magic userspace that I couldn't
> find and I haven't cared enough to write. Ben would you be interested
> in helping flush out the network namespace bugs out of L2TP?
Sure, that I can do. To be entirely honest, I have not yet tried using
network namespaces with the in kernel L2TP stack, but rather with the
Babylon code. I have, however, put together changes to make the Babylon
userland code work with the in kernel L2TP over the past couple of months.
Since the network namespace support is already present in the userland
code, it shouldn't be too hard to adapt.
>From a quick read of the L2TP over UDP code paths, it looks like things
should work, as the ingress and egress lookups use the transport socket's
namespace. All the reference counting looks a bit heavy handed, though.
I also wrote a couple of test programs for setting up L2TP sockets and
devices which may be of use -- see http://www.kvack.org/~bcrl/pppol2tp/ .
-ben
--
"Thought is the essence of where you are now."
^ permalink raw reply
* Re: [PATCH net-next 00/15] 6lowpan: Some more bug fixes
From: Tony Cheneau @ 2012-10-25 14:49 UTC (permalink / raw)
To: Alexander Smirnov; +Cc: David S. Miller, netdev, linux-zigbee-devel, Alan Ott
In-Reply-To: <CAJmB2rDcdo7r-0xoNnrbXRB4KKWoKJmpu9OTk5HHuE1V5Py2qA@mail.gmail.com>
Hello Alexander,
Thank you for your comments. See my answer inline.
Le 25.10.2012 06:52, Alexander Smirnov a écrit :
> Hi,
>
[...]
> 1. The series is quite huge what makes it difficult for the review.
> It
> would be better to split it into one-two and submit separately (not
> simultaneously).
OK. Will do.
> 2. Could you also please provide some notes about how have you tested
> these changes (logs, plain text)? Do I need to check your changes
> locally on my desk? If so I need some instructions.
I'm not sure what you are asking here. There was some more debugging
printk, that I removed because they were too verbose. Mostly, I test my
patch with few userspace program, like ping6, iperf (both for TCP and
UDP) and ssh. I also wrote a TCP and a UDP echo server, so as to test
fragmentation in more details. For most functional patches, I usually
confirm through wireshark that the packets indeed look the way they
should (this, I've done it for patch 11 for example). But I don't have
any automated scripts to check for regression. I can provide you the
script I use to configure nodes if needed (but it pretty straighward and
should look like your own scripts).
I'm not sure that really answers your question.
> 3. Please DO NOT submit patches like: this patch fixes blablabla
> which
> isn't in the kernel yet (like patch 13,15). I have no clue what you
> have locally on your laptop and what you will send in some time. I'd
> like to see here the working code, not a references to TBD.
I'm OK with removing patch 13 (I'll introduce it alongside the serial
driver later on). I'm not so OK with removing patch 15, or at least, it
would require some more testing in other parts of the code. Basically,
the TBD are placeholder for when the Association Request/Response will
be reimplemented. I introduced it because otherwise, .assoc_req and
.assoc_resp entries of mac802154_mlme_wpan would go uninitialized and
would cause kernel crash when called. I could have modified the calling
code to deal with that, but I thought these primitives were meant to be
re-implemented soon anyway.
> 4. The reference to linux-zigbee project isn't an occasion for me to
> apply this code to this tree. I have no goal to merge all this fun to
> mainline due to several things in linux-zigbee kernel work NOT
> according to the standard (mostly it's a timing problems) and global
> refactoring needed.
I don't understand what you are talking about here. I would guess that
you are talking about patch 15. If so, my answer is the following, while
I understand your effort to refactor linux-zigbee code and fix things
along the way, some code went through net-next that cause crashes. My
pragmatic approach is to try to fix it before more people use it, even
through it might not always be the most elegant way to do it.
Regards,
Tony
^ permalink raw reply
* [PATCH] netfilter: remove silly double assignment
From: Alan Cox @ 2012-10-25 14:59 UTC (permalink / raw)
To: netdev
From: Alan Cox <alan@linux.intel.com>
I don't even want to think what the C spec says for this 8)
Signed-off-by: Alan Cox <alan@linux.intel.com>
---
net/netfilter/ipvs/ip_vs_nfct.c | 2 +-
net/netfilter/ipvs/ip_vs_xmit.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/net/netfilter/ipvs/ip_vs_nfct.c b/net/netfilter/ipvs/ip_vs_nfct.c
index 022e77e..c8beafd 100644
--- a/net/netfilter/ipvs/ip_vs_nfct.c
+++ b/net/netfilter/ipvs/ip_vs_nfct.c
@@ -82,7 +82,7 @@ void
ip_vs_update_conntrack(struct sk_buff *skb, struct ip_vs_conn *cp, int outin)
{
enum ip_conntrack_info ctinfo;
- struct nf_conn *ct = ct = nf_ct_get(skb, &ctinfo);
+ struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
struct nf_conntrack_tuple new_tuple;
if (ct == NULL || nf_ct_is_confirmed(ct) || nf_ct_is_untracked(ct) ||
diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
index cc4c809..d8ce87a 100644
--- a/net/netfilter/ipvs/ip_vs_xmit.c
+++ b/net/netfilter/ipvs/ip_vs_xmit.c
@@ -592,7 +592,7 @@ ip_vs_nat_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
#if IS_ENABLED(CONFIG_NF_CONNTRACK)
if (cp->flags & IP_VS_CONN_F_SYNC && local) {
enum ip_conntrack_info ctinfo;
- struct nf_conn *ct = ct = nf_ct_get(skb, &ctinfo);
+ struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
if (ct && !nf_ct_is_untracked(ct)) {
IP_VS_DBG_RL_PKT(10, AF_INET, pp, skb, 0,
@@ -709,7 +709,7 @@ ip_vs_nat_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
#if IS_ENABLED(CONFIG_NF_CONNTRACK)
if (cp->flags & IP_VS_CONN_F_SYNC && local) {
enum ip_conntrack_info ctinfo;
- struct nf_conn *ct = ct = nf_ct_get(skb, &ctinfo);
+ struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
if (ct && !nf_ct_is_untracked(ct)) {
IP_VS_DBG_RL_PKT(10, AF_INET6, pp, skb, 0,
@@ -1227,7 +1227,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
#if IS_ENABLED(CONFIG_NF_CONNTRACK)
if (cp->flags & IP_VS_CONN_F_SYNC && local) {
enum ip_conntrack_info ctinfo;
- struct nf_conn *ct = ct = nf_ct_get(skb, &ctinfo);
+ struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
if (ct && !nf_ct_is_untracked(ct)) {
IP_VS_DBG(10, "%s(): "
@@ -1347,7 +1347,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
#if IS_ENABLED(CONFIG_NF_CONNTRACK)
if (cp->flags & IP_VS_CONN_F_SYNC && local) {
enum ip_conntrack_info ctinfo;
- struct nf_conn *ct = ct = nf_ct_get(skb, &ctinfo);
+ struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
if (ct && !nf_ct_is_untracked(ct)) {
IP_VS_DBG(10, "%s(): "
^ permalink raw reply related
* [PATCH iproute2] iplink: Added support for the kernel IPoIB RTNL ops
From: Or Gerlitz @ 2012-10-25 14:57 UTC (permalink / raw)
To: shemminger; +Cc: netdev, Or Gerlitz, Patrick McHardy
Added support to ipoib rtnl ops through which one can create, configure,
query and delete IPoIB devices, for example
$ ip link add link ib0.8001 name ib0.8001 type ipoib pkey 0x8001
$ ip link add link ib0.1 name ib0.1 type ipoib mode connected
$ ip --details link show dev ib0.1
Cc: Patrick McHardy <kaber@trash.net>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
---
ip/Makefile | 2 +-
ip/iplink.c | 2 +-
ip/iplink_ipoib.c | 114 +++++++++++++++++++++++++++++++++++++++++++++++++
man/man8/ip-link.8.in | 5 ++-
4 files changed, 120 insertions(+), 3 deletions(-)
create mode 100644 ip/iplink_ipoib.c
diff --git a/ip/Makefile b/ip/Makefile
index dfe2e71..1676f0f 100644
--- a/ip/Makefile
+++ b/ip/Makefile
@@ -4,7 +4,7 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \
ipxfrm.o xfrm_state.o xfrm_policy.o xfrm_monitor.o \
iplink_vlan.o link_veth.o link_gre.o iplink_can.o \
iplink_macvlan.o iplink_macvtap.o ipl2tp.o link_vti.o \
- iplink_vxlan.o tcp_metrics.o
+ iplink_vxlan.o tcp_metrics.o iplink_ipoib.o
RTMONOBJ=rtmon.o
diff --git a/ip/iplink.c b/ip/iplink.c
index 4111871..7451aa0 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -83,7 +83,7 @@ void iplink_usage(void)
if (iplink_have_newlink()) {
fprintf(stderr, "\n");
- fprintf(stderr, "TYPE := { vlan | veth | vcan | dummy | ifb | macvlan | can | bridge }\n");
+ fprintf(stderr, "TYPE := { vlan | veth | vcan | dummy | ifb | macvlan | can | bridge | ipoib }\n");
}
exit(-1);
}
diff --git a/ip/iplink_ipoib.c b/ip/iplink_ipoib.c
new file mode 100644
index 0000000..ae372bc
--- /dev/null
+++ b/ip/iplink_ipoib.c
@@ -0,0 +1,114 @@
+/*
+ * iplink_ipoib.c IPoIB device support
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Authors: Or Gerlitz <ogerlitz@mellanox.com>
+ * copied iflink_vlan.c authored by Patrick McHardy <kaber@trash.net>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <linux/if_link.h>
+
+#include "rt_names.h"
+#include "utils.h"
+#include "ip_common.h"
+
+static void explain(void)
+{
+ fprintf(stderr,
+ "Usage: ... ipoib [pkey PKEY] [mode {datagram | connected}]"
+ "[umcast {0|1}]\n"
+ "\n"
+ "PKEY := 0x8001-0xffff\n"
+ );
+}
+
+
+static int mode_arg(void)
+{
+ fprintf(stderr, "Error: argument of \"mode\" must be \"datagram\""
+ "or \"connected\"\n");
+ return -1;
+}
+
+static int ipoib_parse_opt(struct link_util *lu, int argc, char **argv,
+ struct nlmsghdr *n)
+{
+ __u16 pkey, mode, umcast;
+
+ while (argc > 0) {
+ if (matches(*argv, "pkey") == 0) {
+ NEXT_ARG();
+ if (get_u16(&pkey, *argv, 0))
+ invarg("pkey is invalid", *argv);
+ addattr_l(n, 1024, IFLA_IPOIB_PKEY, &pkey, 2);
+ } else if (matches(*argv, "mode") == 0) {
+ NEXT_ARG();
+ if (strcmp(*argv, "datagram") == 0)
+ mode = IPOIB_MODE_DATAGRAM;
+ else if (strcmp(*argv, "connected") == 0)
+ mode = IPOIB_MODE_CONNECTED;
+ else
+ return mode_arg();
+ addattr_l(n, 1024, IFLA_IPOIB_MODE, &mode, 2);
+ } else if (matches(*argv, "umcast") == 0) {
+ NEXT_ARG();
+ if (get_u16(&umcast, *argv, 0))
+ invarg("umcast is invalid", *argv);
+ addattr_l(n, 1024, IFLA_IPOIB_UMCAST, &umcast, 2);
+ } else if (matches(*argv, "help") == 0) {
+ explain();
+ return -1;
+ } else {
+ fprintf(stderr, "ipoib: what is \"%s\"?\n", *argv);
+ explain();
+ return -1;
+ }
+ argc--, argv++;
+ }
+
+ return 0;
+}
+
+static void ipoib_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
+{
+ __u16 mode;
+
+ if (!tb)
+ return;
+
+ if (!tb[IFLA_IPOIB_PKEY] ||
+ RTA_PAYLOAD(tb[IFLA_IPOIB_PKEY]) < sizeof(__u16))
+ return;
+
+ fprintf(f, "pkey %#.4x ", rta_getattr_u16(tb[IFLA_IPOIB_PKEY]));
+
+ if (!tb[IFLA_IPOIB_MODE] ||
+ RTA_PAYLOAD(tb[IFLA_IPOIB_MODE]) < sizeof(__u16))
+ return;
+
+ mode = rta_getattr_u16(tb[IFLA_IPOIB_MODE]);
+ fprintf(f, "mode %s ",
+ mode == IPOIB_MODE_DATAGRAM ? "datagram" :
+ mode == IPOIB_MODE_CONNECTED ? "connected" :
+ "unknown");
+
+ if (!tb[IFLA_IPOIB_UMCAST] ||
+ RTA_PAYLOAD(tb[IFLA_IPOIB_UMCAST]) < sizeof(__u16))
+ return;
+
+ fprintf(f, "umcast %.4x ", rta_getattr_u16(tb[IFLA_IPOIB_UMCAST]));
+}
+
+struct link_util ipoib_link_util = {
+ .id = "ipoib",
+ .maxattr = IFLA_IPOIB_MAX,
+ .parse_opt = ipoib_parse_opt,
+ .print_opt = ipoib_print_opt,
+};
diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
index 8a24e51..c03a8d6 100644
--- a/man/man8/ip-link.8.in
+++ b/man/man8/ip-link.8.in
@@ -50,7 +50,7 @@ ip-link \- network device configuration
.ti -8
.IR TYPE " := [ "
-.BR vlan " | " veth " | " vcan " | " dummy " | " ifb " | " macvlan " | " can " | " bridge " ]"
+.BR vlan " | " veth " | " vcan " | " dummy " | " ifb " | " macvlan " | " can " | " bridge " | "ipoib" ]"
.ti -8
.BI "ip link delete " DEVICE
@@ -159,6 +159,9 @@ Link types:
.sp
.B bridge
- Ethernet Bridge device
+.sp
+.B ipoib
+- IP over Infiniband device
.in -8
.TP
--
1.7.1
^ permalink raw reply related
* Re: [PATCH net-next 00/15] 6lowpan: Some more bug fixes
From: Alan Ott @ 2012-10-25 15:10 UTC (permalink / raw)
To: Tony Cheneau
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, David S. Miller,
linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
In-Reply-To: <383f66ae460548de6f930b0f1c244e5a-jNfjcPZKvDhg9hUCZPvPmw@public.gmane.org>
On 10/25/2012 10:49 AM, Tony Cheneau wrote:
> I'm not so OK with removing patch 15, or at least, it would require
> some more testing in other parts of the code. Basically, the TBD are
> placeholder for when the Association Request/Response will be
> reimplemented. I introduced it because otherwise, .assoc_req and
> .assoc_resp entries of mac802154_mlme_wpan would go uninitialized and
> would cause kernel crash when called. I could have modified the
> calling code to deal with that, but I thought these primitives were
> meant to be re-implemented soon anyway.
I think just simply stating this in the commit message would fix the
issue here. Maybe something like "Fix crash where assoc_req() and
assoc_resp() were not defined."
This should probably get split into two patches, one for BSN and the
other for assoc.
Also, make the bsn functions static, and the convention is to put static
functions above where they are being used, so that you don't have to
forward declare them. It looks though, like this source file doesn't do
that for other functions, so maybe following the convention of this file
for now is ok.
Alan.
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
^ permalink raw reply
* Re: switching network namespace midway
From: rsa @ 2012-10-25 15:12 UTC (permalink / raw)
To: Benjamin LaHaise; +Cc: Eric W. Biederman, netdev
In-Reply-To: <20121024212116.GG15034@kvack.org>
Thanks Eric. That makes sense. I can remember both network namespaces
and switch to the other prior to route lookup if necessary.
Any gotchas on receiving tunneled packed on the tunnel interface? Looking at
the code there is no change necessary. Packet arrives on tunnel
interface which is
decapsulated and given to net_if_rx() for inner packet processing. Am I mssing
something?
thank you
rsa
On Wed, Oct 24, 2012 at 5:21 PM, Benjamin LaHaise <bcrl@kvack.org> wrote:
> On Wed, Oct 24, 2012 at 02:11:14PM -0700, Eric W. Biederman wrote:
>> rsa <ravi.mlists@gmail.com> writes:
>>
>> > Assuming I have a tunnel interface where two route lookups are done --
>> > one for innter
>> > packet and the other for outer -- do you see any issues in switching
>> > the network
>> > namespace prior to second route lookup (and restore to the original namespace
>> > after the second lookup is done)?
>> >
>> > If so, are there any other calls other than sk_change_net() needed?
>>
>> In general sk_change_net is a bad idea.
>>
>> Most likely what you want to do is simply memorize both struct net's
>> that you care about and perform the routing lookup as appropriate.
>>
>> Certainly you don't want to be calling sk_change_net for every packet
>> that goes through your tunnel.
>
> I've actually done this with L2TP. The packets coming into the system from
> the tunnel are received on one UDP socket in one "struct net", but the
> decapsulated packets are received on a "struct net_device" that is in a
> different "struct net". No special coding is required -- just move the
> tunnel's net_device into another namespace after creation and it works as
> expected. Using sk_change_net() would be full of races and is really not
> required for the vast majority of use cases.
>
> -ben
^ permalink raw reply
* [PATCH] l2tp: session is an array not a pointer
From: Alan Cox @ 2012-10-25 15:22 UTC (permalink / raw)
To: netdev
From: Alan Cox <alan@linux.intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
---
net/l2tp/l2tp_netlink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/l2tp/l2tp_netlink.c b/net/l2tp/l2tp_netlink.c
index 6c4cc12..bbba3a1 100644
--- a/net/l2tp/l2tp_netlink.c
+++ b/net/l2tp/l2tp_netlink.c
@@ -632,7 +632,7 @@ static int l2tp_nl_session_send(struct sk_buff *skb, u32 portid, u32 seq, int fl
nla_put_u16(skb, L2TP_ATTR_MRU, session->mru)))
goto nla_put_failure;
- if ((session->ifname && session->ifname[0] &&
+ if ((session->ifname[0] &&
nla_put_string(skb, L2TP_ATTR_IFNAME, session->ifname)) ||
(session->cookie_len &&
nla_put(skb, L2TP_ATTR_COOKIE, session->cookie_len,
^ permalink raw reply related
* Re: switching network namespace midway
From: rsa @ 2012-10-25 15:29 UTC (permalink / raw)
To: Benjamin LaHaise; +Cc: Eric W. Biederman, netdev
In-Reply-To: <20121024212116.GG15034@kvack.org>
Hi Ben
For L2TP that should work very well. But, with other tunnel types like GRE etc.
route lookups have to be done first in the inner and then outer. It
makes it easier
to keep keep the tunnel in the inner namespace in such cases. right?
thank you
rsa
On Wed, Oct 24, 2012 at 5:21 PM, Benjamin LaHaise <bcrl@kvack.org> wrote:
> On Wed, Oct 24, 2012 at 02:11:14PM -0700, Eric W. Biederman wrote:
>> rsa <ravi.mlists@gmail.com> writes:
>>
>> > Assuming I have a tunnel interface where two route lookups are done --
>> > one for innter
>> > packet and the other for outer -- do you see any issues in switching
>> > the network
>> > namespace prior to second route lookup (and restore to the original namespace
>> > after the second lookup is done)?
>> >
>> > If so, are there any other calls other than sk_change_net() needed?
>>
>> In general sk_change_net is a bad idea.
>>
>> Most likely what you want to do is simply memorize both struct net's
>> that you care about and perform the routing lookup as appropriate.
>>
>> Certainly you don't want to be calling sk_change_net for every packet
>> that goes through your tunnel.
>
> I've actually done this with L2TP. The packets coming into the system from
> the tunnel are received on one UDP socket in one "struct net", but the
> decapsulated packets are received on a "struct net_device" that is in a
> different "struct net". No special coding is required -- just move the
> tunnel's net_device into another namespace after creation and it works as
> expected. Using sk_change_net() would be full of races and is really not
> required for the vast majority of use cases.
>
> -ben
^ permalink raw reply
* Re: [PATCH 5/5] ss: Show inet and unix sockets' shutdown state
From: Stephen Hemminger @ 2012-10-25 15:52 UTC (permalink / raw)
To: Pavel Emelyanov; +Cc: Linux Netdev List
In-Reply-To: <50893E14.60001@parallels.com>
On Thu, 25 Oct 2012 17:26:44 +0400
Pavel Emelyanov <xemul@parallels.com> wrote:
> To see this we need kernel >=3.7 with _SHUTDOWN nlarrts in diag messages.
> The output will look like arrows at the end of each line, like this:
>
> ESTAB 0 0 127.0.0.1:41705 127.0.0.1:12345 ino:143321 sk:ffff88003a8cea00 -->
> ESTAB 0 0 127.0.0.1:46925 127.0.0.1:12346 ino:143322 sk:ffff88003a8ce4c0 <--
> ESTAB 0 0 127.0.0.1:51678 127.0.0.1:12347 ino:143323 sk:ffff88003a8cdf80 ---
> ESTAB 0 0 127.0.0.1:46911 127.0.0.1:12348 ino:143324 sk:ffff88003b7f05c0 <->
>
> for SHUT_RD, SHUT_WR, SHUT_RDWR and non-shutdown sockets respectively.
>
> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
>
> ---
> include/linux/inet_diag.h | 3 ++-
> include/linux/unix_diag.h | 1 +
> misc/ss.c | 26 ++++++++++++++++++++------
> 3 files changed, 23 insertions(+), 7 deletions(-)
>
> diff --git a/include/linux/inet_diag.h b/include/linux/inet_diag.h
> index 8c469af..bbde90f 100644
> --- a/include/linux/inet_diag.h
> +++ b/include/linux/inet_diag.h
> @@ -109,9 +109,10 @@ enum {
> INET_DIAG_TOS,
> INET_DIAG_TCLASS,
> INET_DIAG_SKMEMINFO,
> + INET_DIAG_SHUTDOWN,
> };
Since this requires 3.8 or later kernel, please resubmit this
patch during that merge window.
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox