* [PATCH iproute2-3.8 4/6] iproute2: Make "ip netns delete" more likely to succeed
From: Eric W. Biederman @ 2013-01-18 0:47 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, Serge E. Hallyn, Ben Hutchings
In-Reply-To: <87622v5ngt.fsf_-_@xmission.com>
Sometimes "ip netns delete" fails because it can not delete the file a
network namespace was mounted on. If this only happened when a
network namespace was really in use this would be fine, but today it
is possible to pin all network namespaces by simply having a long
running process started with "ip netns exec".
Every mount is copied when a network namespace is created so it is
impossible to prevent the mounts from getting into other mount
namespaces. Modify all mounts in the files and subdirectories of
/var/run/netns to be shared mount points so that unmount events can
propogate, making it unlikely that "ip netns delete" will fail because
a directory is mounted in another mount namespace.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
ip/ipnetns.c | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index 4fce379..33765b5 100644
--- a/ip/ipnetns.c
+++ b/ip/ipnetns.c
@@ -208,6 +208,7 @@ static int netns_add(int argc, char **argv)
char netns_path[MAXPATHLEN];
const char *name;
int fd;
+ int made_netns_run_dir_mount = 0;
if (argc < 1) {
fprintf(stderr, "No netns name specified\n");
@@ -220,6 +221,29 @@ static int netns_add(int argc, char **argv)
/* Create the base netns directory if it doesn't exist */
mkdir(NETNS_RUN_DIR, S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH);
+ /* Make it possible for network namespace mounts to propogate between
+ * mount namespaces. This makes it likely that a unmounting a network
+ * namespace file in one namespace will unmount the network namespace
+ * file in all namespaces allowing the network namespace to be freed
+ * sooner.
+ */
+ while (mount("", NETNS_RUN_DIR, "none", MS_SHARED | MS_REC, NULL)) {
+ /* Fail unless we need to make the mount point */
+ if (errno != EINVAL || made_netns_run_dir_mount) {
+ fprintf(stderr, "mount --make-shared %s failed: %s\n",
+ NETNS_RUN_DIR, strerror(errno));
+ return EXIT_FAILURE;
+ }
+
+ /* Upgrade NETNS_RUN_DIR to a mount point */
+ if (mount(NETNS_RUN_DIR, NETNS_RUN_DIR, "none", MS_BIND, NULL)) {
+ fprintf(stderr, "mount --bind %s %s failed: %s\n",
+ NETNS_RUN_DIR, NETNS_RUN_DIR, strerror(errno));
+ return EXIT_FAILURE;
+ }
+ made_netns_run_dir_mount = 1;
+ }
+
/* Create the filesystem state */
fd = open(netns_path, O_RDONLY|O_CREAT|O_EXCL, 0);
if (fd < 0) {
--
1.7.5.4
^ permalink raw reply related
* [PATCH iproute2-3.8 5/6] iproute2: Fill in the ip-netns.8 manpage
From: Eric W. Biederman @ 2013-01-18 0:47 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, Serge E. Hallyn, Ben Hutchings
In-Reply-To: <87622v5ngt.fsf_-_@xmission.com>
Document ip netns monitor.
Add a few senteces describing each command. The manpage was looking
very scrawny.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
man/man8/ip-netns.8 | 46 +++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 45 insertions(+), 1 deletions(-)
diff --git a/man/man8/ip-netns.8 b/man/man8/ip-netns.8
index 349ee7e..ff08232 100644
--- a/man/man8/ip-netns.8
+++ b/man/man8/ip-netns.8
@@ -1,4 +1,4 @@
-.TH IP\-NETNS 8 "20 Dec 2011" "iproute2" "Linux"
+.TH IP\-NETNS 8 "16 Jan 2013" "iproute2" "Linux"
.SH NAME
ip-netns \- process network namespace management
.SH SYNOPSIS
@@ -23,6 +23,9 @@ ip-netns \- process network namespace management
.BR "ip netns exec "
.I NETNSNAME command ...
+.ti -8
+.BR "ip netns monitor"
+
.SH DESCRIPTION
A network namespace is logically another copy of the network stack,
with its own routes, firewall rules, and network devices.
@@ -54,11 +57,52 @@ bind mounting all of the per network namespace configure files into
their traditional location in /etc.
.SS ip netns list - show all of the named network namespaces
+
+This command displays all of the network namespaces in /var/run/netns
+
.SS ip netns add NAME - create a new named network namespace
+
+If NAME is available in /var/run/netns/ this command creates a new
+network namespace and assigns NAME.
+
.SS ip netns delete NAME - delete the name of a network namespace
+
+If NAME is present in /var/run/netns it is umounted and the mount
+point is removed. If this is the last user of the network namespace the
+network namespace will be freed, otherwise the network namespace
+persists until it has no more users. ip netns delete may fail if
+the mount point is in use in another mount namespace.
+
.SS ip netns exec NAME cmd ... - Run cmd in the named network namespace
+This command allows applications that are network namespace unaware
+to be run in something other than the default network namespace with
+all of the configuration for the specified network namespace appearing
+in the customary global locations. A network namespace and bind mounts
+are used to move files from their network namespace specific location
+to their default locations without affecting other processes.
+
+.SS ip netns monitor - Report as network namespace names are added and deleted
+
+This command watches network namespace name addition and deletion events
+and prints a line for each event it sees.
+
.SH EXAMPLES
+.PP
+ip netns list
+.RS
+Shows the list of current named network namespaces
+.RE
+.PP
+ip netns add vpn
+.RS
+Creates a network namespace and names it vpn
+.RE
+.PP
+ip netns exec vpn ip link set lo up
+.RS
+Bring up the loopback interface in the vpn network namespace.
+.RE
.SH SEE ALSO
.br
--
1.7.5.4
^ permalink raw reply related
* [PATCH iproute2-3.8 6/6] iproute2: Add "ip netns pids" and "ip netns identify"
From: Eric W. Biederman @ 2013-01-18 0:48 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, Serge E. Hallyn, Ben Hutchings
In-Reply-To: <87622v5ngt.fsf_-_@xmission.com>
Add command that go between network namespace names and process
identifiers. The code builds and runs agains older kernels but
only works on Linux 3.8+ kernels where I have fixed stat to work
properly.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
ip/ipnetns.c | 148 +++++++++++++++++++++++++++++++++++++++++++++++++++
man/man8/ip-netns.8 | 18 ++++++
2 files changed, 166 insertions(+), 0 deletions(-)
diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index 33765b5..51b1c5e 100644
--- a/ip/ipnetns.c
+++ b/ip/ipnetns.c
@@ -13,6 +13,7 @@
#include <dirent.h>
#include <errno.h>
#include <unistd.h>
+#include <ctype.h>
#include "utils.h"
#include "ip_common.h"
@@ -45,6 +46,8 @@ static int usage(void)
fprintf(stderr, "Usage: ip netns list\n");
fprintf(stderr, " ip netns add NAME\n");
fprintf(stderr, " ip netns delete NAME\n");
+ fprintf(stderr, " ip netns identify PID\n");
+ fprintf(stderr, " ip netns pids NAME\n");
fprintf(stderr, " ip netns exec NAME cmd ...\n");
fprintf(stderr, " ip netns monitor\n");
return EXIT_FAILURE;
@@ -174,6 +177,145 @@ static int netns_exec(int argc, char **argv)
return EXIT_FAILURE;
}
+static int is_pid(const char *str)
+{
+ int ch;
+ for (; (ch = *str); str++) {
+ if (!isdigit(ch))
+ return 0;
+ }
+ return 1;
+}
+
+static int netns_pids(int argc, char **argv)
+{
+ const char *name;
+ char net_path[MAXPATHLEN];
+ int netns;
+ struct stat netst;
+ DIR *dir;
+ struct dirent *entry;
+
+ if (argc < 1) {
+ fprintf(stderr, "No netns name specified\n");
+ return EXIT_FAILURE;
+ }
+ if (argc > 1) {
+ fprintf(stderr, "extra arguments specified\n");
+ return EXIT_FAILURE;
+ }
+
+ name = argv[0];
+ snprintf(net_path, sizeof(net_path), "%s/%s", NETNS_RUN_DIR, name);
+ netns = open(net_path, O_RDONLY);
+ if (netns < 0) {
+ fprintf(stderr, "Cannot open network namespace: %s\n",
+ strerror(errno));
+ return EXIT_FAILURE;
+ }
+ if (fstat(netns, &netst) < 0) {
+ fprintf(stderr, "Stat of netns failed: %s\n",
+ strerror(errno));
+ return EXIT_FAILURE;
+ }
+ dir = opendir("/proc/");
+ if (!dir) {
+ fprintf(stderr, "Open of /proc failed: %s\n",
+ strerror(errno));
+ return EXIT_FAILURE;
+ }
+ while((entry = readdir(dir))) {
+ char pid_net_path[MAXPATHLEN];
+ struct stat st;
+ if (!is_pid(entry->d_name))
+ continue;
+ snprintf(pid_net_path, sizeof(pid_net_path), "/proc/%s/ns/net",
+ entry->d_name);
+ if (stat(pid_net_path, &st) != 0)
+ continue;
+ if ((st.st_dev == netst.st_dev) &&
+ (st.st_ino == netst.st_ino)) {
+ printf("%s\n", entry->d_name);
+ }
+ }
+ closedir(dir);
+ return EXIT_SUCCESS;
+
+}
+
+static int netns_identify(int argc, char **argv)
+{
+ const char *pidstr;
+ char net_path[MAXPATHLEN];
+ int netns;
+ struct stat netst;
+ DIR *dir;
+ struct dirent *entry;
+
+ if (argc < 1) {
+ fprintf(stderr, "No pid specified\n");
+ return EXIT_FAILURE;
+ }
+ if (argc > 1) {
+ fprintf(stderr, "extra arguments specified\n");
+ return EXIT_FAILURE;
+ }
+ pidstr = argv[0];
+
+ if (!is_pid(pidstr)) {
+ fprintf(stderr, "Specified string '%s' is not a pid\n",
+ pidstr);
+ return EXIT_FAILURE;
+ }
+
+ snprintf(net_path, sizeof(net_path), "/proc/%s/ns/net", pidstr);
+ netns = open(net_path, O_RDONLY);
+ if (netns < 0) {
+ fprintf(stderr, "Cannot open network namespace: %s\n",
+ strerror(errno));
+ return EXIT_FAILURE;
+ }
+ if (fstat(netns, &netst) < 0) {
+ fprintf(stderr, "Stat of netns failed: %s\n",
+ strerror(errno));
+ return EXIT_FAILURE;
+ }
+ dir = opendir(NETNS_RUN_DIR);
+ if (!dir) {
+ /* Succeed treat a missing directory as an empty directory */
+ if (errno == ENOENT)
+ return EXIT_SUCCESS;
+
+ fprintf(stderr, "Failed to open directory %s:%s\n",
+ NETNS_RUN_DIR, strerror(errno));
+ return EXIT_FAILURE;
+ }
+
+ while((entry = readdir(dir))) {
+ char name_path[MAXPATHLEN];
+ struct stat st;
+
+ if (strcmp(entry->d_name, ".") == 0)
+ continue;
+ if (strcmp(entry->d_name, "..") == 0)
+ continue;
+
+ snprintf(name_path, sizeof(name_path), "%s/%s", NETNS_RUN_DIR,
+ entry->d_name);
+
+ if (stat(name_path, &st) != 0)
+ continue;
+
+ if ((st.st_dev == netst.st_dev) &&
+ (st.st_ino == netst.st_ino)) {
+ printf("%s\n", entry->d_name);
+ }
+ }
+ closedir(dir);
+ return EXIT_SUCCESS;
+
+}
+
static int netns_delete(int argc, char **argv)
{
const char *name;
@@ -324,6 +466,12 @@ int do_netns(int argc, char **argv)
if (matches(*argv, "delete") == 0)
return netns_delete(argc-1, argv+1);
+ if (matches(*argv, "identify") == 0)
+ return netns_identify(argc-1, argv+1);
+
+ if (matches(*argv, "pids") == 0)
+ return netns_pids(argc-1, argv+1);
+
if (matches(*argv, "exec") == 0)
return netns_exec(argc-1, argv+1);
diff --git a/man/man8/ip-netns.8 b/man/man8/ip-netns.8
index ff08232..f5b025e 100644
--- a/man/man8/ip-netns.8
+++ b/man/man8/ip-netns.8
@@ -20,6 +20,14 @@ ip-netns \- process network namespace management
.I NETNSNAME
.ti -8
+.BR "ip netns identify"
+.I PID
+
+.ti -8
+.BR "ip netns pids"
+.I NETNSNAME
+
+.ti -8
.BR "ip netns exec "
.I NETNSNAME command ...
@@ -73,6 +81,16 @@ network namespace will be freed, otherwise the network namespace
persists until it has no more users. ip netns delete may fail if
the mount point is in use in another mount namespace.
+.SS ip netns identify PID - Report network namespaces names for process
+
+This command walks through /var/run/netns and finds all the network
+namespace names for network namespace of the specified process.
+
+.SS ip netns pids NAME - Report processes in the named network namespace
+
+This command walks through proc and finds all of the process who have
+the named network namespace as their primary network namespace.
+
.SS ip netns exec NAME cmd ... - Run cmd in the named network namespace
This command allows applications that are network namespace unaware
--
1.7.5.4
^ permalink raw reply related
* Re: [PATCH for 3.8] iproute2: Add "ip netns pids" and "ip netns identify"
From: Ben Hutchings @ 2013-01-18 1:00 UTC (permalink / raw)
To: Eric W. Biederman; +Cc: Stephen Hemminger, netdev, Serge E. Hallyn
In-Reply-To: <87a9s772zw.fsf@xmission.com>
On Thu, 2013-01-17 at 16:23 -0800, Eric W. Biederman wrote:
> Ben Hutchings <bhutchings@solarflare.com> writes:
>
> > On Mon, 2012-11-26 at 17:16 -0600, Eric W. Biederman wrote:
[...]
> >> --- a/ip/ipnetns.c
> >> +++ b/ip/ipnetns.c
[...]
> >> +static int is_pid(const char *str)
> >> +{
> >> + int ch;
> >> + for (; (ch = *str); str++) {
> >> + if (!isdigit(ch))
> >
> > ch must be cast to unsigned char before passing to isdigit().
>
> isdigit is defined to take an int. A legacy of the implicit casts in
> the K&R C days. Casting to unsigned char would be pointless and silly.
[...]
It's not pointless. This is explained in the very first line of the
description in the manual page...
Ben.
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply
* Re: [patch net-next v2] doc: add nf_conntrack sysctl api documentation
From: Pablo Neira Ayuso @ 2013-01-18 1:12 UTC (permalink / raw)
To: Jiri Pirko
Cc: netdev, davem, rob, linux-doc, kuznet, jmorris, yoshfuji,
netfilter-devel, netfilter, coreteam, fw
In-Reply-To: <1358348193-2201-1-git-send-email-jiri@resnulli.us>
Hi Jiri,
Thanks for working on this, some comments and suggestions.
On Wed, Jan 16, 2013 at 03:56:33PM +0100, Jiri Pirko wrote:
> I grepped through the code and picked bits about nf_conntrack sysctl api
> and put that into one documentation file.
>
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
> ---
>
> v1->v2:
> processed in changes suggested by Florian Westphal
>
> Documentation/networking/nf_conntrack-sysctl.txt | 172 +++++++++++++++++++++++
> 1 file changed, 172 insertions(+)
> create mode 100644 Documentation/networking/nf_conntrack-sysctl.txt
>
> diff --git a/Documentation/networking/nf_conntrack-sysctl.txt b/Documentation/networking/nf_conntrack-sysctl.txt
> new file mode 100644
> index 0000000..61b66e6
> --- /dev/null
> +++ b/Documentation/networking/nf_conntrack-sysctl.txt
> @@ -0,0 +1,172 @@
> +/proc/sys/net/netfilter/nf_conntrack_* Variables:
> +
> +nf_conntrack_acct - BOOLEAN
> + 0 - disabled (default)
> + not 0 - enabled
> +
> + Enable connection tracking flow accounting.
You can probably these add 64-bits byte and packet counters per flow.
> +
> +nf_conntrack_buckets - INTEGER (read-only)
> + Size of hash table. Value is computed in nf_conntrack_init_init_net()
> + and it basically depends on total memory size.
Instead of pointing to the function, you can say that we "use 1/16384
of memory. On i386: 32MB machine has 512 buckets. >= 1GB machines have
16384 as default" (extracted from comment on the source code).
> +
> +nf_conntrack_checksum - BOOLEAN
> + 0 - disabled
> + not 0 - enabled (default)
> +
> + Verify checksum of incoming packets. Packets with bad checksum
> + will not be considered for connection tracking, i.e. such packets
> + will be in INVALID state.
> +
> +nf_conntrack_count - INTEGER (read-only)
> + Number of currently allocated conntracks.
Probably use `flow entries' or simply `flows' instead of conntracks?
I'm familiar with the conntrack term, but the reader may be not.
> +
> +nf_conntrack_events - BOOLEAN
> + 0 - disabled
> + not 0 - enabled (default)
> +
> + If this option is enabled, the connection tracking code will
> + provide userspace with connection tracking events via ctnetlink.
> +
> +nf_conntrack_events_retry_timeout - INTEGER (seconds)
> + default 15
> +
> + This option is only relevant when "reliable connection tracking
> + events" are used. Normally, ctnetlink is "lossy", i.e. when
> + userspace listeners can't keep up, events are dropped.
> +
> + Userspace can request "reliable event mode". When this mode is
> + active, the conntrack will only be destroyed after the event was
> + delivered. If event delivery fails, the kernel periodically
> + re-tries to send the event to userspace.
> +
> + This is the maximum interval the kernel should use when re-trying
> + to deliver the destroy event.
> +
> + Higher number means less delivery re-tries (but it will then take
> + longer for a backlog to be processed).
> +
> +nf_conntrack_expect_max - INTEGER
> + Maximum size of expectation table. Default value is computed in
> + nf_conntrack_expect_init() and depends on nf_conntrack_buckets value.
> +
> +nf_conntrack_frag6_high_thresh - INTEGER
> + default 262144
> +
> + Maximum memory used to reassemble IPv6 fragments. When
> + nf_conntrack_frag6_high_thresh bytes of memory is allocated for this
> + purpose, the fragment handler will toss packets until
> + nf_conntrack_frag6_low_thresh is reached.
> +
> +nf_conntrack_frag6_low_thresh - INTEGER
> + default 196608
> +
> + See nf_conntrack_frag6_low_thresh
> +
> +nf_conntrack_frag6_timeout - INTEGER (seconds)
> + default 60
> +
> + Time to keep an IPv6 fragment in memory.
> +
> +nf_conntrack_generic_timeout - INTEGER (seconds)
> + default 600
> +
> + Default for generic timeout.
You can add here "this refers to layer 4 unknown/unsupported
protocols"
> +
> +nf_conntrack_helper - BOOLEAN
> + 0 - disabled
> + not 0 - enabled (default)
> +
> + Enable automatic conntrack helper assignment.
> +
> +nf_conntrack_icmp_timeout - INTEGER (seconds)
> + default 30
> +
> + Default for ICMP timeout.
> +
> +nf_conntrack_icmpv6_timeout - INTEGER (seconds)
> + default 30
> +
> + Default for ICMP6 timeout.
> +
> +nf_conntrack_log_invalid - INTEGER
> + 0 - disable (default)
> + 1 - log ICMP packets
> + 6 - log TCP packets
> + 17 - log UDP packets
> + 33 - log DCCP packets
> + 41 - log ICMPv6 packets
> + 136 - log UDPLITE packets
> + 255 - log packets of any protocol
> +
> + Log invalid packets of a type specified by value.
> +
> +nf_conntrack_max - INTEGER
> + Size of connection tracking table. Default value is computed in
> + nf_conntrack_init_init_net() and depends on nf_conntrack_buckets value.
By default is 4 * number of buckets in the hashtable.
> +
> +nf_conntrack_tcp_be_liberal - BOOLEAN
> + 0 - disabled (default)
> + not 0 - enabled
> +
> + Be conservative in what you do, be liberal in what you accept from others.
> + If it's non-zero, we mark only out of window RST segments as INVALID.
> +
> +nf_conntrack_tcp_loose - BOOLEAN
> + 0 - disabled
> + not 0 - enabled (default)
> +
> + If it is set to zero, we disable picking up already established
> + connections.
> +
> +nf_conntrack_tcp_max_retrans - INTEGER
> + default 3
> +
> + Max number of the retransmitted packets without receiving an
> + (acceptable) ACK from the destination. If this number is reached,
> + a shorter timer will be started.
> +
> +nf_conntrack_tcp_timeout_close - INTEGER (seconds)
> + default 10
> +
> +nf_conntrack_tcp_timeout_close_wait - INTEGER (seconds)
> + default 60
> +
> +nf_conntrack_tcp_timeout_established - INTEGER (seconds)
> + default 432000 (5 days)
> +
> +nf_conntrack_tcp_timeout_fin_wait - INTEGER (seconds)
> + default 120
> +
> +nf_conntrack_tcp_timeout_last_ack - INTEGER (seconds)
> + default 30
> +
> +nf_conntrack_tcp_timeout_max_retrans - INTEGER (seconds)
> + default 300
> +
> +nf_conntrack_tcp_timeout_syn_recv - INTEGER (seconds)
> + default 60
> +
> +nf_conntrack_tcp_timeout_syn_sent - INTEGER (seconds)
> + default 120
> +
> +nf_conntrack_tcp_timeout_time_wait - INTEGER (seconds)
> + default 120
> +
> +nf_conntrack_tcp_timeout_unacknowledged - INTEGER (seconds)
> + default 300
> +
> +nf_conntrack_timestamp - BOOLEAN
> + 0 - disabled (default)
> + not 0 - enabled
> +
> + Enable connection tracking flow timestamping.
> +
> +nf_conntrack_udp_timeout - INTEGER (seconds)
> + default 30
> +
> +nf_conntrack_udp_timeout_stream2 - INTEGER (seconds)
> + default 180
> +
> + This extended timeout will be used in case there is an UDP stream
> + detected.
> --
> 1.8.1
>
^ permalink raw reply
* RE: [net-next 04/14] e1000e: add support for IEEE-1588 PTP
From: Allan, Bruce W @ 2013-01-18 1:13 UTC (permalink / raw)
To: Richard Cochran, Kirsher, Jeffrey T
Cc: davem@davemloft.net, netdev@vger.kernel.org, gospo@redhat.com,
sassmann@redhat.com
In-Reply-To: <20130117153535.GA2937@netboy.at.omicron.at>
> -----Original Message-----
> From: Richard Cochran [mailto:richardcochran@gmail.com]
> Sent: Thursday, January 17, 2013 7:36 AM
> To: Kirsher, Jeffrey T
> Cc: davem@davemloft.net; Allan, Bruce W; netdev@vger.kernel.org;
> gospo@redhat.com; sassmann@redhat.com
> Subject: Re: [net-next 04/14] e1000e: add support for IEEE-1588 PTP
>
> On Thu, Jan 17, 2013 at 03:35:09AM -0800, Jeff Kirsher wrote:
>
> > +static struct ptp_clock_info e1000e_ptp_clock_info = {
> > + .owner = THIS_MODULE,
>
> small nit: better to use a static string for .name here than ...
>
> > + .n_alarm = 0,
> > + .n_ext_ts = 0,
> > + .n_per_out = 0,
> > + .pps = 0,
> > + .adjfreq = e1000e_phc_adjfreq,
> > + .adjtime = e1000e_phc_adjtime,
> > + .gettime = e1000e_phc_gettime,
> > + .settime = e1000e_phc_settime,
> > + .enable = e1000e_phc_enable,
> > +};
> > +
> > +/**
> > + * e1000e_ptp_init - initialize PTP for devices which support it
> > + * @adapter: board private structure
> > + *
> > + * This function performs the required steps for enabling PTP support.
> > + * If PTP support has already been loaded it simply calls the cyclecounter
> > + * init routine and exits.
> > + **/
> > +void e1000e_ptp_init(struct e1000_adapter *adapter)
> > +{
> > + struct e1000_hw *hw = &adapter->hw;
> > +
> > + adapter->ptp_clock = NULL;
> > +
> > + if (!(adapter->flags & FLAG_HAS_HW_TIMESTAMP))
> > + return;
> > +
> > + adapter->ptp_clock_info = e1000e_ptp_clock_info;
> > +
> > + snprintf(adapter->ptp_clock_info.name,
> > + sizeof(adapter->ptp_clock_info.name), "%pm",
> > + adapter->netdev->perm_addr);
>
> ... putting any kind of address here. After some back and forth,
> discussing what the 'name' field should be, we decided on
>
> * @name: A short "friendly name" to identify the clock and to
> * help distinguish PHY based devices from MAC based ones.
> * The string is not meant to be a unique id.
>
> and most other drivers put the name of the driver here.
>
> Other than that, this new driver looks good to me. I'll try it out
> soon.
>
> Acked-by: Richard Cochran <richardcochran@gmail.com>
Thanks for the review Richard.
^ permalink raw reply
* RE: [net-next 04/14] e1000e: add support for IEEE-1588 PTP
From: Allan, Bruce W @ 2013-01-18 1:13 UTC (permalink / raw)
To: Stephen Hemminger, Kirsher, Jeffrey T
Cc: davem@davemloft.net, netdev@vger.kernel.org, gospo@redhat.com,
sassmann@redhat.com, Richard Cochran
In-Reply-To: <20130117075626.40eb1500@nehalam.linuxnetplumber.net>
> -----Original Message-----
> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Thursday, January 17, 2013 7:56 AM
> To: Kirsher, Jeffrey T
> Cc: davem@davemloft.net; Allan, Bruce W; netdev@vger.kernel.org;
> gospo@redhat.com; sassmann@redhat.com; Richard Cochran
> Subject: Re: [net-next 04/14] e1000e: add support for IEEE-1588 PTP
>
> On Thu, 17 Jan 2013 03:35:09 -0800
> Jeff Kirsher <jeffrey.t.kirsher@intel.com> wrote:
>
> > +static struct ptp_clock_info e1000e_ptp_clock_info = {
>
> Should be static const since it is immutable and contains function pointers.
Nice catch! Thanks for the review Stephen. I'll submit a follow-on patch to change this
if that is alright with you. Btw, did you catch that through inspection or did you use a
static analysis tool?
Bruce.
^ permalink raw reply
* Re: [PATCH for 3.8] iproute2: Add "ip netns pids" and "ip netns identify"
From: Eric W. Biederman @ 2013-01-18 1:27 UTC (permalink / raw)
To: Ben Hutchings; +Cc: Stephen Hemminger, netdev, Serge E. Hallyn
In-Reply-To: <1358470823.15692.156.camel@deadeye.wl.decadent.org.uk>
Ben Hutchings <bhutchings@solarflare.com> writes:
> On Thu, 2013-01-17 at 16:23 -0800, Eric W. Biederman wrote:
>> Ben Hutchings <bhutchings@solarflare.com> writes:
>>
>> > On Mon, 2012-11-26 at 17:16 -0600, Eric W. Biederman wrote:
> [...]
>> >> --- a/ip/ipnetns.c
>> >> +++ b/ip/ipnetns.c
> [...]
>> >> +static int is_pid(const char *str)
>> >> +{
>> >> + int ch;
>> >> + for (; (ch = *str); str++) {
>> >> + if (!isdigit(ch))
>> >
>> > ch must be cast to unsigned char before passing to isdigit().
>>
>> isdigit is defined to take an int. A legacy of the implicit casts in
>> the K&R C days. Casting to unsigned char would be pointless and silly.
> [...]
>
> It's not pointless. This is explained in the very first line of the
> description in the manual page...
If it's not pointless it is an implementation bug. The conversion to of
char to int happens implicitly whenever you pass a char. It is
absolutely broken to have a function that takes a char converted to int
and reject the automatic conversion of char to int.
I suspect much more strongly that it is a case of poor documentation.
If isdigit can't deal with what I have passed it I will be much more
interested in writing a patch for isdigit.
That said I just dobule checked with the code below. Negative character
values work correctly and don't cause any runtime errors.
It looks like it is time to update the manpage to remove that
confusing/wrong sentence.
Eric
#include <ctype.h>
#include <limits.h>
#include <stdio.h>
int main(int argc, char **argv)
{
char c;
for (c = CHAR_MIN; c < CHAR_MAX; c++) {
printf("c: %d isdigit: %d\n",
c, isdigit(c));
}
return 0;
}
^ permalink raw reply
* Re: [PATCH net-next V6 02/14] bridge: Add vlan filtering infrastructure
From: Michał Mirosław @ 2013-01-18 1:57 UTC (permalink / raw)
To: Vlad Yasevich; +Cc: netdev, bridge, davem, shemminger, mst, shmulik.ladkani
In-Reply-To: <1358360289-23249-3-git-send-email-vyasevic@redhat.com>
2013/1/16 Vlad Yasevich <vyasevic@redhat.com>:
[...]
> --- /dev/null
> +++ b/net/bridge/br_vlan.c
[...]
> +struct net_port_vlan *nbp_vlan_find(const struct net_port_vlans *v, u16 vid)
> +{
> + struct net_port_vlan *pve;
> +
> + /* Must be done either in rcu critical section or with RTNL held */
> + WARN_ON_ONCE(!rcu_read_lock_held() && !rtnl_is_locked());
> +
> + list_for_each_entry_rcu(pve, &v->vlan_list, list) {
> + if (pve->vid == vid)
> + return pve;
> + }
> +
> + return NULL;
> +}
This looks expensive - it's O(n) with n = number of configured VLANs on a port.
And this is called for every packet. The bridge already has a hash of VLAN
structures found by br_vlan_find(). You could add a second bitmap there
(eg. ingres_ports[]) and check port's bit instead of walking the list.
You would use a bit more memory (64 bytes minus the removed list-head)
per configured VLAN but save some cycles in hot path.
Best Regards,
Michał Mirosław
^ permalink raw reply
* Re: [PATCH] ipv6: check if dereference of ipv6 header is safe
From: Hannes Frederic Sowa @ 2013-01-18 2:06 UTC (permalink / raw)
To: netdev
In-Reply-To: <20130117035652.GB23782@order.stressinduktion.org>
On Thu, Jan 17, 2013 at 04:56:52AM +0100, Hannes Frederic Sowa wrote:
> When ipip6_rcv gets called we are sure that we have a full blown
> ipv4 packet header in the linear skb buffer (this is checked by
> xfrm4_mode_tunnel_input). Because we dereference fields of the inner
> ipv6 header we should actually check for the length of the sum of the
> ipv4 and ipv6 header.
>
> If the skb is too short this packet could very well be destined for
> another tunnel. So we should notify the caller accordingly (albeit
> currently xfrm4_mode_tunnel_input does not care; this could need another
> patch).
While grepping for xfrm_tunnel and handler I studied the wrong
call stack. ipip6_rcv is not called by xfrm_mode_tunnel_input but by
tunnel64_rcv. This function already ensures that we can safely dereference
the ipv6 header. I got confused by xfrm_mode_tunnel only checking for
the size of an ipv4 header and assumed that the data section of the
skb had not been rolled forward. This patch brings ipip6_rcv in line
with ipip_rcv.
This patch superseds the old one:
[PATCH] ipv6: remove unneeded check to pskb_may_pull
This is already checked by the caller (tunnel64_rcv) and brings ipip6_rcv
in line with ipip_rcv.
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
net/ipv6/sit.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index cfba99b..98fe536 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -592,15 +592,10 @@ out:
static int ipip6_rcv(struct sk_buff *skb)
{
- const struct iphdr *iph;
+ const struct iphdr *iph = ip_hdr(skb);
struct ip_tunnel *tunnel;
int err;
- if (!pskb_may_pull(skb, sizeof(struct ipv6hdr)))
- goto out;
-
- iph = ip_hdr(skb);
-
tunnel = ipip6_tunnel_lookup(dev_net(skb->dev), skb->dev,
iph->saddr, iph->daddr);
if (tunnel != NULL) {
--
1.7.11.7
^ permalink raw reply related
* Re: [PATCH] ipv6: check if dereference of ipv6 header is safe
From: David Miller @ 2013-01-18 2:08 UTC (permalink / raw)
To: hannes; +Cc: netdev
In-Reply-To: <20130118020612.GA14833@order.stressinduktion.org>
From: Hannes Frederic Sowa <hannes@stressinduktion.org>
Date: Fri, 18 Jan 2013 03:06:12 +0100
> On Thu, Jan 17, 2013 at 04:56:52AM +0100, Hannes Frederic Sowa wrote:
>> When ipip6_rcv gets called we are sure that we have a full blown
>> ipv4 packet header in the linear skb buffer (this is checked by
>> xfrm4_mode_tunnel_input). Because we dereference fields of the inner
>> ipv6 header we should actually check for the length of the sum of the
>> ipv4 and ipv6 header.
>>
>> If the skb is too short this packet could very well be destined for
>> another tunnel. So we should notify the caller accordingly (albeit
>> currently xfrm4_mode_tunnel_input does not care; this could need another
>> patch).
>
> While grepping for xfrm_tunnel and handler I studied the wrong
> call stack. ipip6_rcv is not called by xfrm_mode_tunnel_input but by
> tunnel64_rcv. This function already ensures that we can safely dereference
> the ipv6 header. I got confused by xfrm_mode_tunnel only checking for
> the size of an ipv4 header and assumed that the data section of the
> skb had not been rolled forward. This patch brings ipip6_rcv in line
> with ipip_rcv.
>
> This patch superseds the old one:
Don't post new patches using replies to old threads. Create entirely
new patch postings.
> [PATCH] ipv6: remove unneeded check to pskb_may_pull
This is an ambiguous commit header line, it doesn't say that you're
modifying the SIT tunnel driver at all. Please fix this.
Thanks.
^ permalink raw reply
* [PATCH] net: fix wrong length of mac address
From: Amos Kong @ 2013-01-18 2:15 UTC (permalink / raw)
To: netdev, davem; +Cc: devel, Amos Kong
Replace hardcode 14 with defined ETN_ALEN.
Signed-off-by: Amos Kong <kongjianjun@gmail.com>
---
drivers/net/hyperv/netvsc_drv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index f825a62..8264f0e 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -349,7 +349,7 @@ static int netvsc_set_mac_addr(struct net_device *ndev, void *p)
struct net_device_context *ndevctx = netdev_priv(ndev);
struct hv_device *hdev = ndevctx->device_ctx;
struct sockaddr *addr = p;
- char save_adr[14];
+ char save_adr[ETH_ALEN];
unsigned char save_aatype;
int err;
--
1.7.11.7
^ permalink raw reply related
* Re: [PATCH] ipv6: check if dereference of ipv6 header is safe
From: Eric Dumazet @ 2013-01-18 2:21 UTC (permalink / raw)
To: Hannes Frederic Sowa; +Cc: netdev
In-Reply-To: <20130118020612.GA14833@order.stressinduktion.org>
On Fri, 2013-01-18 at 03:06 +0100, Hannes Frederic Sowa wrote:
> [PATCH] ipv6: remove unneeded check to pskb_may_pull
>
> This is already checked by the caller (tunnel64_rcv) and brings ipip6_rcv
> in line with ipip_rcv.
>
> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
> ---
> net/ipv6/sit.c | 7 +------
> 1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
> index cfba99b..98fe536 100644
> --- a/net/ipv6/sit.c
> +++ b/net/ipv6/sit.c
> @@ -592,15 +592,10 @@ out:
>
> static int ipip6_rcv(struct sk_buff *skb)
> {
> - const struct iphdr *iph;
> + const struct iphdr *iph = ip_hdr(skb);
> struct ip_tunnel *tunnel;
> int err;
>
> - if (!pskb_may_pull(skb, sizeof(struct ipv6hdr)))
> - goto out;
> -
> - iph = ip_hdr(skb);
> -
> tunnel = ipip6_tunnel_lookup(dev_net(skb->dev), skb->dev,
> iph->saddr, iph->daddr);
> if (tunnel != NULL) {
But we use a 'struct iphdr' here, not a ipv6hdr
So we basically implicitely rely on sizeof(struct iphdr) <=
sizeof(struct ipv6hdr)
I would leave the pskb_may_pull() call and fix it, even if not really
needed.
^ permalink raw reply
* [PATCH] [iproute] ipxfrm: simplify algo code a bit
From: Mike Frysinger @ 2013-01-18 2:39 UTC (permalink / raw)
To: stephen.hemminger, netdev
The current code sets up a structure with xfrm_algo embedded in it, but
doesn't use the supplemental key field. Drop it.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
note: i don't have a system where this code runs (probably missing options in
my kernel). i checked xfrm_aead_print a bit but couldn't quite figure it out.
it doesn't seem like it needs that trailing space.
ip/ipxfrm.c | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/ip/ipxfrm.c b/ip/ipxfrm.c
index c7b3420..bd313e6 100644
--- a/ip/ipxfrm.c
+++ b/ip/ipxfrm.c
@@ -555,16 +555,13 @@ static inline void xfrm_algo_print(struct xfrm_algo *algo, int type, int len,
static void xfrm_aead_print(struct xfrm_algo_aead *algo, int len,
FILE *fp, const char *prefix)
{
- struct {
- struct xfrm_algo algo;
- char key[algo->alg_key_len / 8];
- } base;
+ struct xfrm_algo base_algo;
- memcpy(base.algo.alg_name, algo->alg_name, sizeof(base.algo.alg_name));
- base.algo.alg_key_len = algo->alg_key_len;
- memcpy(base.algo.alg_key, algo->alg_key, algo->alg_key_len / 8);
+ memcpy(base_algo.alg_name, algo->alg_name, sizeof(base_algo.alg_name));
+ base_algo.alg_key_len = algo->alg_key_len;
+ memcpy(base_algo.alg_key, algo->alg_key, algo->alg_key_len / 8);
- __xfrm_algo_print(&base.algo, XFRMA_ALG_AEAD, len, fp, prefix, 0);
+ __xfrm_algo_print(&base_algo, XFRMA_ALG_AEAD, len, fp, prefix, 0);
fprintf(fp, " %d", algo->alg_icv_len);
@@ -574,16 +571,13 @@ static void xfrm_aead_print(struct xfrm_algo_aead *algo, int len,
static void xfrm_auth_trunc_print(struct xfrm_algo_auth *algo, int len,
FILE *fp, const char *prefix)
{
- struct {
- struct xfrm_algo algo;
- char key[algo->alg_key_len / 8];
- } base;
+ struct xfrm_algo base_algo;
- memcpy(base.algo.alg_name, algo->alg_name, sizeof(base.algo.alg_name));
- base.algo.alg_key_len = algo->alg_key_len;
- memcpy(base.algo.alg_key, algo->alg_key, algo->alg_key_len / 8);
+ memcpy(base_algo.alg_name, algo->alg_name, sizeof(base_algo.alg_name));
+ base_algo.alg_key_len = algo->alg_key_len;
+ memcpy(base_algo.alg_key, algo->alg_key, algo->alg_key_len / 8);
- __xfrm_algo_print(&base.algo, XFRMA_ALG_AUTH_TRUNC, len, fp, prefix, 0);
+ __xfrm_algo_print(&base_algo, XFRMA_ALG_AUTH_TRUNC, len, fp, prefix, 0);
fprintf(fp, " %d", algo->alg_trunc_len);
--
1.8.0.2
^ permalink raw reply related
* Re: Wake on LAN for USB ethernet?
From: Ming Lei @ 2013-01-18 2:39 UTC (permalink / raw)
To: Sarah Sharp
Cc: linux-usb, netdev, Petko Manolov, Alan Stern, Greg KH,
Oliver Neukum
In-Reply-To: <20130118001214.GA21137@xanatos>
On Fri, Jan 18, 2013 at 8:12 AM, Sarah Sharp
<sarah.a.sharp@linux.intel.com> wrote:
> Is it reasonable to expect that Wake on LAN works if the target box is
> connected via a USB-to-ethernet adapter?
It is surely reasonable, and seems SMSC75xx or SMSC95xx can
bring system out of suspend.
>
> One of my validation testers has a USB ethernet device that successfully
> wakes up Windows from hibernate (S4), but it doesn't work under Linux.
> Wake on LAN works fine with the hardwired ethernet port. USB remote
> wakeup from S3/S4 works fine with a USB keyboard.
>
> So I need to figure out if it's an issue with the kernel, their test
> suite, or the USB host controller.
>
>
> I've experimented with USB ethernet devices with the pegasus driver with
> no success. Here's what I've tried:
>
> 1. Connect the USB to ethernet adapter to the rootport under the xHCI
> (USB 3.0) host controller. (lsusb for the two devices I've tried is
> attached)
>
> 2. Enable remote wakeup for all devices (including the PCI host) by
> echoing 'enabled' to power/wakeup. (script for that attached)
>
> 3. Use ethtool to turn on WOL:
> sudo ethtool -s ethX wol g
Could you check here if the attribute 'power/wakeup' of the USB device
has been enabled? If so, and step 6 still can't wakeup system, the
problem may be in the set_wol stetting on hardware of the driver since
your USB wakeup works.
Also, the wakeup enabling is missed in the pegasus_set_wol(), and
the below patch is needed:
diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c
index a0b5807..d5304f1 100644
--- a/drivers/net/usb/pegasus.c
+++ b/drivers/net/usb/pegasus.c
@@ -1096,6 +1096,7 @@ pegasus_set_wol(struct net_device *dev, struct
ethtool_wolinfo *wol)
{
pegasus_t *pegasus = netdev_priv(dev);
u8 reg78 = 0x04;
+ int ret;
if (wol->wolopts & ~WOL_SUPPORTED)
return -EINVAL;
@@ -1110,7 +1111,11 @@ pegasus_set_wol(struct net_device *dev, struct
ethtool_wolinfo *wol)
else
pegasus->eth_regs[0] &= ~0x10;
pegasus->wolopts = wol->wolopts;
- return set_register(pegasus, WakeupControl, reg78);
+
+ ret = set_register(pegasus, WakeupControl, reg78);
+ if (!ret)
+ ret = device_set_wakeup_enable(&pegasus->usb->dev, 1);
+ return ret;
}
static inline void pegasus_reset_wol(struct net_device *dev)
>
> 4. Find the MAC address by running ifconfig and looking at the HWaddr
> field.
>
> 5. Verify with wireshark that I can see the Magic WOL packet when I run
> this command on another machine:
> sudo etherwake -i ethX macaddr
>
> 6. Suspend or hibernate the target machine, and then send the Magic WOL
> packet from a second machine.
>
>
> Am I missing any steps in testing this? Does WOL just not work for USB
> ethernet devices under Linux? Perhaps just the pegasus driver doesn't
> support WOL?
Probably the set_wol of pegasus is broken if wakeup has been enabled
on the USB device.
Thanks,
--
Ming Lei
^ permalink raw reply related
* Re: [PATCH] ipv6: check if dereference of ipv6 header is safe
From: Hannes Frederic Sowa @ 2013-01-18 3:08 UTC (permalink / raw)
To: Eric Dumazet; +Cc: netdev
In-Reply-To: <1358475697.11051.9.camel@edumazet-glaptop>
On Thu, Jan 17, 2013 at 06:21:37PM -0800, Eric Dumazet wrote:
> But we use a 'struct iphdr' here, not a ipv6hdr
>
> So we basically implicitely rely on sizeof(struct iphdr) <=
> sizeof(struct ipv6hdr)
>
> I would leave the pskb_may_pull() call and fix it, even if not really
> needed.
Please correct me if I am wrong:
The callstack as captured in ipip6_rcv:
ipip6_rcv+0xcd/0x680 [sit]
tunnel64_rcv+0x4a/0x174 [tunnel4]
ip_local_deliver+0x152/0x470
? ip_local_deliver+0x75/0x470
ip_rcv+0x36d/0x650
ip_rcv does first check if the ipv4 header is complete (inclusive options) and
passes control to ip_local_deliver which calls __skb_pull(skb,
ip_hdrlen(skb)). So ->data is forwarded behind the ipv4 header. The next
pskb_may_pull check would check if the necessary amount of data behind the
ipv4 header is available hence I assume the check in tunnel64_rcv is enough:
109 static int tunnel64_rcv(struct sk_buff *skb)
110 {
111 struct xfrm_tunnel *handler;
112
113 if (!pskb_may_pull(skb, sizeof(struct ipv6hdr)))
114 goto drop;
115
116 for_each_tunnel_rcu(tunnel64_handlers, handler)
117 if (!handler->handler(skb))
118 return 0;
Thanks,
Hannes
^ permalink raw reply
* [PATCH] smsc: smc911x: Fix sparse warnings
From: Fabio Estevam @ 2013-01-18 2:46 UTC (permalink / raw)
To: davem; +Cc: netdev, Fabio Estevam
From: Fabio Estevam <fabio.estevam@freescale.com>
ioremap returns 'void __iomem *' type.
Fix the following build warnings:
drivers/net/ethernet/smsc/smc911x.c:2079:14: warning: incorrect type in assignment (different address spaces)
drivers/net/ethernet/smsc/smc911x.c:2079:14: expected unsigned int *addr
drivers/net/ethernet/smsc/smc911x.c:2079:14: got void [noderef] <asn:2>*
drivers/net/ethernet/smsc/smc911x.c:2086:18: warning: incorrect type in assignment (different address spaces)
drivers/net/ethernet/smsc/smc911x.c:2086:18: expected void [noderef] <asn:2>*base
drivers/net/ethernet/smsc/smc911x.c:2086:18: got unsigned int *addr
drivers/net/ethernet/smsc/smc911x.c:2091:25: warning: incorrect type in argument 1 (different address spaces)
drivers/net/ethernet/smsc/smc911x.c:2091:25: expected void volatile [noderef] <asn:2>*addr
drivers/net/ethernet/smsc/smc911x.c:2091:25: got unsigned int *addr
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
drivers/net/ethernet/smsc/smc911x.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/smsc/smc911x.c b/drivers/net/ethernet/smsc/smc911x.c
index 1538d54..9dd842d 100644
--- a/drivers/net/ethernet/smsc/smc911x.c
+++ b/drivers/net/ethernet/smsc/smc911x.c
@@ -2036,7 +2036,7 @@ static int smc911x_drv_probe(struct platform_device *pdev)
struct net_device *ndev;
struct resource *res;
struct smc911x_local *lp;
- unsigned int *addr;
+ void __iomem *addr;
int ret;
DBG(SMC_DEBUG_FUNC, "--> %s\n", __func__);
--
1.7.9.5
^ permalink raw reply related
* Re: [PATCH v6 1/2] PCI-Express Non-Transparent Bridge Support
From: Greg KH @ 2013-01-18 3:14 UTC (permalink / raw)
To: Jon Mason; +Cc: linux-kernel, linux-pci, netdev, Dave Jiang, Nicholas Bellinger
In-Reply-To: <1353119233-32752-2-git-send-email-jon.mason@intel.com>
On Fri, Nov 16, 2012 at 07:27:12PM -0700, Jon Mason wrote:
> A PCI-Express non-transparent bridge (NTB) is a point-to-point PCIe bus
> connecting 2 systems, providing electrical isolation between the two subsystems.
> A non-transparent bridge is functionally similar to a transparent bridge except
> that both sides of the bridge have their own independent address domains. The
> host on one side of the bridge will not have the visibility of the complete
> memory or I/O space on the other side of the bridge. To communicate across the
> non-transparent bridge, each NTB endpoint has one (or more) apertures exposed to
> the local system. Writes to these apertures are mirrored to memory on the
> remote system. Communications can also occur through the use of doorbell
> registers that initiate interrupts to the alternate domain, and scratch-pad
> registers accessible from both sides.
>
> The NTB device driver is needed to configure these memory windows, doorbell, and
> scratch-pad registers as well as use them in such a way as they can be turned
> into a viable communication channel to the remote system. ntb_hw.[ch]
> determines the usage model (NTB to NTB or NTB to Root Port) and abstracts away
> the underlying hardware to provide access and a common interface to the doorbell
> registers, scratch pads, and memory windows. These hardware interfaces are
> exported so that other, non-mainlined kernel drivers can access these.
> ntb_transport.[ch] also uses the exported interfaces in ntb_hw.[ch] to setup a
> communication channel(s) and provide a reliable way of transferring data from
> one side to the other, which it then exports so that "client" drivers can access
> them. These client drivers are used to provide a standard kernel interface
> (i.e., Ethernet device) to NTB, such that Linux can transfer data from one
> system to the other in a standard way.
>
> Signed-off-by: Jon Mason <jon.mason@intel.com>
> Reviewed-by: Nicholas Bellinger <nab@linux-iscsi.org>
Sorry for the very long delay, I've now applied these two patches,
thanks for the cleanups and changes from the original versions.
But, I now get the following build warning, so can you send a follow-on
patch that fixes it up before you start getting angry emails from the
0-day build bot?
drivers/ntb/ntb_transport.c: In function ‘ntb_transport_rx’:
drivers/ntb/ntb_transport.c:895:7: warning: ‘offset’ may be used uninitialized in this function [-Wuninitialized]
drivers/ntb/ntb_transport.c:891:8: note: ‘offset’ was declared here
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH] [iproute] ipxfrm: simplify algo code a bit
From: David Miller @ 2013-01-18 3:26 UTC (permalink / raw)
To: vapier; +Cc: stephen.hemminger, netdev
In-Reply-To: <1358476746-10810-1-git-send-email-vapier@gentoo.org>
From: Mike Frysinger <vapier@gentoo.org>
Date: Thu, 17 Jan 2013 21:39:06 -0500
> The current code sets up a structure with xfrm_algo embedded in it, but
> doesn't use the supplemental key field. Drop it.
>
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
It's for the storage of the zero length array at the end of
xfrm_algo.
Don't change code you don't understand.
^ permalink raw reply
* Re: [PATCH] [iproute] ipxfrm: simplify algo code a bit
From: Mike Frysinger @ 2013-01-18 4:00 UTC (permalink / raw)
To: David Miller; +Cc: stephen.hemminger, netdev
In-Reply-To: <20130117.222646.675735349628953028.davem@davemloft.net>
[-- Attachment #1: Type: Text/Plain, Size: 529 bytes --]
On Thursday 17 January 2013 22:26:46 David Miller wrote:
> From: Mike Frysinger <vapier@gentoo.org>
> Date: Thu, 17 Jan 2013 21:39:06 -0500
> > The current code sets up a structure with xfrm_algo embedded in it, but
> > doesn't use the supplemental key field. Drop it.
>
> It's for the storage of the zero length array at the end of
> xfrm_algo.
ok, so we can use alloca instead
> Don't change code you don't understand.
so you're just going to be pointlessly hostile everywhere ? stop wasting
time.
-mike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply
* [PATCH v2] [iproute] ipxfrm: use alloca to allocate stack space
From: Mike Frysinger @ 2013-01-18 4:00 UTC (permalink / raw)
To: stephen.hemminger, netdev
In-Reply-To: <1358476746-10810-1-git-send-email-vapier@gentoo.org>
Clang doesn't support the gcc extension for embeddeding flexible arrays
inside of structures. Use the slightly more portable alloca().
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
v2
- use alloca rather than flexible arrays in structures
ip/ipxfrm.c | 27 +++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)
diff --git a/ip/ipxfrm.c b/ip/ipxfrm.c
index c7b3420..dda4a7a 100644
--- a/ip/ipxfrm.c
+++ b/ip/ipxfrm.c
@@ -25,6 +25,7 @@
* Masahide NAKAMURA @USAGI
*/
+#include <alloca.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -555,16 +556,13 @@ static inline void xfrm_algo_print(struct xfrm_algo *algo, int type, int len,
static void xfrm_aead_print(struct xfrm_algo_aead *algo, int len,
FILE *fp, const char *prefix)
{
- struct {
- struct xfrm_algo algo;
- char key[algo->alg_key_len / 8];
- } base;
+ struct xfrm_algo *base_algo = alloca(sizeof(*base_algo) + algo->alg_key_len / 8);
- memcpy(base.algo.alg_name, algo->alg_name, sizeof(base.algo.alg_name));
- base.algo.alg_key_len = algo->alg_key_len;
- memcpy(base.algo.alg_key, algo->alg_key, algo->alg_key_len / 8);
+ memcpy(base_algo->alg_name, algo->alg_name, sizeof(base_algo->alg_name));
+ base_algo->alg_key_len = algo->alg_key_len;
+ memcpy(base_algo->alg_key, algo->alg_key, algo->alg_key_len / 8);
- __xfrm_algo_print(&base.algo, XFRMA_ALG_AEAD, len, fp, prefix, 0);
+ __xfrm_algo_print(base_algo, XFRMA_ALG_AEAD, len, fp, prefix, 0);
fprintf(fp, " %d", algo->alg_icv_len);
@@ -574,16 +572,13 @@ static void xfrm_aead_print(struct xfrm_algo_aead *algo, int len,
static void xfrm_auth_trunc_print(struct xfrm_algo_auth *algo, int len,
FILE *fp, const char *prefix)
{
- struct {
- struct xfrm_algo algo;
- char key[algo->alg_key_len / 8];
- } base;
+ struct xfrm_algo *base_algo = alloca(sizeof(*base_algo) + algo->alg_key_len / 8);
- memcpy(base.algo.alg_name, algo->alg_name, sizeof(base.algo.alg_name));
- base.algo.alg_key_len = algo->alg_key_len;
- memcpy(base.algo.alg_key, algo->alg_key, algo->alg_key_len / 8);
+ memcpy(base_algo->alg_name, algo->alg_name, sizeof(base_algo->alg_name));
+ base_algo->alg_key_len = algo->alg_key_len;
+ memcpy(base_algo->alg_key, algo->alg_key, algo->alg_key_len / 8);
- __xfrm_algo_print(&base.algo, XFRMA_ALG_AUTH_TRUNC, len, fp, prefix, 0);
+ __xfrm_algo_print(base_algo, XFRMA_ALG_AUTH_TRUNC, len, fp, prefix, 0);
fprintf(fp, " %d", algo->alg_trunc_len);
--
1.8.0.2
^ permalink raw reply related
* Re: IPV4 TCP connection reset using iperf
From: Madhvapathi Sriram @ 2013-01-18 4:13 UTC (permalink / raw)
To: Rick Jones; +Cc: netdev
In-Reply-To: <50EC59D8.9000701@hp.com>
Hi,
I was looking into the driver code and found that the problem was with
merging the code and had messed up with skb_put in the receive path. I
have corrected that and everything works fine.
Thanks for the help.
Regards,
Madhvapathi Sriram
On Tue, Jan 8, 2013 at 11:09 PM, Rick Jones <rick.jones2@hp.com> wrote:
> On 01/08/2013 06:41 AM, Madhvapathi Sriram wrote:
>>
>> Hi,
>>
>> I have recently migrated to kernel version 3.6.10 from 3.2.1. I was
>> running iperf to routinely measure TCP throughput and I have been
>> facing problems eversince. I am using a wireless interface.
>>
>> wireless client: iperf -s -i 1 -w 1024K
>> wireless server: iperf -c 192.168.1.1 -i -1 -w 1024 -t 600
>>
>> While, the connection is maintained for sometime and the perf logs
>> keep going. Randomly, the connection breaks with the server side
>> resetting the connection. The tcp dump on the client shows RST sent by
>> the server. Switching back to 3.2.1 works. This issue starts from
>> kernel version 3.5 onnwards.
>>
>> I have tried to probe along some points to take a look at the air
>> logs, tcpdump on either sides but to no clue - everything seems normal
>> like, the tcp window values, very less/negligible retransmissions and
>> so on. The RST is set abruptly and randomly (no definite time - may
>> happen randomly).
>>
>> I am looking for some suggestions or pointers towards analyzing the issue.
>
>
> I cannot imagine that iperf bulk transfer would look all that much different
> from netperf bulk transfer, but I suppose you could see if a netperf
> TCP_STREAM test with similar configuration settings encounters the same RST
> issues. Or, for that matter, an equally long-lived FTP or scp transfer.
>
> rick jones
>
^ permalink raw reply
* Re: Redefinition of struct in6_addr in <netinet/in.h> and <linux/in6.h>
From: Carlos O'Donell @ 2013-01-18 4:13 UTC (permalink / raw)
To: YOSHIFUJI Hideaki
Cc: David Miller, vapier, libc-alpha, bhutchings, amwang, tmb, eblake,
netdev, linux-kernel, libvirt-list, tgraf, schwab
In-Reply-To: <50F76E87.6020606@linux-ipv6.org>
On 01/16/2013 10:22 PM, YOSHIFUJI Hideaki wrote:
> Carlos O'Donell wrote:
>> diff --git a/include/uapi/linux/in6.h b/include/uapi/linux/in6.h
>> index f79c372..a2b16a5 100644
>> --- a/include/uapi/linux/in6.h
>> +++ b/include/uapi/linux/in6.h
>> @@ -23,6 +23,13 @@
>>
>> #include <linux/types.h>
>>
>> +/* If a glibc-based userspace has already included in.h, then we will not
>> + * define in6_addr (nor the defines), sockaddr_in6, or ipv6_mreq. The
>> + * ABI used by the kernel and by glibc match exactly. Neither the kernel
>> + * nor glibc should break this ABI without coordination.
>> + */
>> +#ifndef _NETINET_IN_H
>> +
>> /*
>> * IPv6 address structure
>> */
>
> This should be
> #if !defined(__GLIBC__) || !defined(_NETINET_IN_H)
Correct. If it's non-glibc we want these defines to be used
even if a non-glibc defined _NETINET_IN_H.
>> @@ -30,12 +37,20 @@
>> struct in6_addr {
>> union {
>> __u8 u6_addr8[16];
>> +#if !defined(__GLIBC__) \
>> + || (defined(__GLIBC__) && (defined(__USE_MISC) || defined(__USE_GNU))) \
>> + || defined(__KERNEL__)
>> __be16 u6_addr16[8];
>> __be32 u6_addr32[4];
>> +#endif
>> } in6_u;
>> +#if !defined(__GLIBC__) \
>> + || (defined(__GLIBC__) && (defined(__USE_MISC) || defined(__USE_GNU))) \
>> + || defined(__KERNEL__)
>> #define s6_addr in6_u.u6_addr8
>> #define s6_addr16 in6_u.u6_addr16
>> #define s6_addr32 in6_u.u6_addr32
>> +#endif
>> };
>
> 2nd "if" be after s6_addr?
Correct. We want to unconditinally define s6_addr in this case.
I've fixed both of those cases in the next version of the patch. Thanks.
Cheers,
Carlos.
^ permalink raw reply
* Re: Redefinition of struct in6_addr in <netinet/in.h> and <linux/in6.h>
From: Mike Frysinger @ 2013-01-18 4:14 UTC (permalink / raw)
To: libc-alpha
Cc: David Miller, bhutchings, yoshfuji, amwang, tmb, eblake, netdev,
linux-kernel, libvirt-list, tgraf, schwab, carlos
In-Reply-To: <20130116.164511.2027039182184636075.davem@davemloft.net>
[-- Attachment #1: Type: Text/Plain, Size: 1034 bytes --]
On Wednesday 16 January 2013 16:45:11 David Miller wrote:
> What would be really nice is if GCC treated multiple identical
> definitions of structures the same way it handles multiple identical
> definitions of CPP defines. Which is to silently accept them.
>
> But that's not the case, so we need a different solution.
>
> Another thing to do is to use a new structure for in6_addr in kernel
> headers exported to userland.
the kernel already exports many types with a __kernel_ prefix. i changed the
kernel headers in Gentoo for a few releases (2.6.28 - 2.6.34) to do the same
thing to pretty much all the networking headers. a few packages broke, but
the number was low, and trivial to fix (a sed would do it most of the time).
it's also trivial for userland packages to detect that they need to do this
sort of thing in a local header by using linux/version.h and a set of defines
to redirect the new structure name back to the old one.
would be a lot cleaner to just break it and be done.
-mike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply
* Re: Redefinition of struct in6_addr in <netinet/in.h> and <linux/in6.h>
From: Mike Frysinger @ 2013-01-18 4:20 UTC (permalink / raw)
To: David Miller
Cc: carlos, libc-alpha, bhutchings, yoshfuji, amwang, tmb, eblake,
netdev, linux-kernel, libvirt-list, tgraf, schwab
In-Reply-To: <20130116.221538.1756411165313441486.davem@davemloft.net>
[-- Attachment #1: Type: Text/Plain, Size: 1012 bytes --]
On Wednesday 16 January 2013 22:15:38 David Miller wrote:
> From: Carlos O'Donell <carlos@systemhalted.org>
> Date: Wed, 16 Jan 2013 21:15:03 -0500
>
> > +/* If a glibc-based userspace has already included in.h, then we will
> > not + * define in6_addr (nor the defines), sockaddr_in6, or ipv6_mreq.
> > The + * ABI used by the kernel and by glibc match exactly. Neither the
> > kernel + * nor glibc should break this ABI without coordination.
> > + */
> > +#ifndef _NETINET_IN_H
> > +
>
> I think we should shoot for a non-glibc-centric solution.
>
> I can't imagine that other libc's won't have the same exact problem
> with their netinet/in.h conflicting with the kernel's, redefining
> structures like in6_addr, that we'd want to provide a protection
> scheme for here as well.
yes, the kernel's use of __GLIBC__ in exported headers has already caused
problems in the past. fortunately, it's been reduced down to just one case
now (stat.h). let's not balloon it back up.
-mike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ 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