Browse Source

Merge upstream version 24

Christoph Biedl 5 years ago
parent
commit
a344ba48ee
6 changed files with 35 additions and 17 deletions
  1. 7 0
      NEWS
  2. 2 0
      aoe.c
  3. 2 3
      dat.h
  4. 12 6
      freebsd.c
  5. 4 0
      linux.c
  6. 8 8
      vblade.8

+ 7 - 0
NEWS

@@ -1,4 +1,11 @@
 -*- change-log -*-
 -*- change-log -*-
+2018-08-25 Christoph Biedl <sourceforge.bnwi@manchmal.in-ulm.de>
+	Print helpful error and exit immediately for missing device
+	vblade-24
+
+2017-11-19 Catalin Salgau <csalgau@users.sourceforge.net>
+	On FreeBSD limit used MTU to address BPF limitation
+
 2015-06-14 Ed Cashin <ed.cashin@acm.org>
 2015-06-14 Ed Cashin <ed.cashin@acm.org>
 	Add convenience script for creating sparse files
 	Add convenience script for creating sparse files
 	vblade-23
 	vblade-23

+ 2 - 0
aoe.c

@@ -536,6 +536,8 @@ main(int argc, char **argv)
 	}
 	}
 	ifname = argv[2];
 	ifname = argv[2];
 	sfd = dial(ifname, bufcnt);
 	sfd = dial(ifname, bufcnt);
+	if (sfd < 0)
+		return 1;
 	getea(sfd, ifname, mac);
 	getea(sfd, ifname, mac);
 	printf("pid %ld: e%d.%d, %lld sectors %s\n",
 	printf("pid %ld: e%d.%d, %lld sectors %s\n",
 		(long) getpid(), shelf, slot, size,
 		(long) getpid(), shelf, slot, size,

+ 2 - 3
dat.h

@@ -6,7 +6,7 @@
  */
  */
 
 
 enum {
 enum {
-	VBLADE_VERSION		= 22,
+	VBLADE_VERSION		= 24,
 
 
 	// Firmware version
 	// Firmware version
 	FWV			= 0x4000 + VBLADE_VERSION,
 	FWV			= 0x4000 + VBLADE_VERSION,
@@ -140,7 +140,7 @@ enum {
 	Bufcount = 16,
 	Bufcount = 16,
 
 
 	/* mask commands */
 	/* mask commands */
-	Mread= 0,	
+	Mread= 0,
 	Medit,
 	Medit,
 
 
 	/* mask directives */
 	/* mask directives */
@@ -172,4 +172,3 @@ vlong	size;		// size of vblade
 vlong	offset;
 vlong	offset;
 char	*progname;
 char	*progname;
 char	serial[Nserial+1];
 char	serial[Nserial+1];
-

+ 12 - 6
freebsd.c

@@ -25,7 +25,7 @@
 #include <sys/types.h>
 #include <sys/types.h>
 #include <net/if.h>
 #include <net/if.h>
 #include <sys/stat.h>
 #include <sys/stat.h>
-#include <sys/disklabel.h>
+#include <sys/disk.h>
 #include <sys/select.h>
 #include <sys/select.h>
 #include <sys/sysctl.h>
 #include <sys/sysctl.h>
 
 
@@ -262,7 +262,7 @@ int
 getmtu(int fd, char *name)
 getmtu(int fd, char *name)
 {
 {
 	struct ifreq xx;
 	struct ifreq xx;
-	int s, n;
+	int s, n, p;
 
 
 	s = socket(AF_INET, SOCK_RAW, 0);
 	s = socket(AF_INET, SOCK_RAW, 0);
 	if (s == -1) {
 	if (s == -1) {
@@ -271,26 +271,32 @@ getmtu(int fd, char *name)
 	}
 	}
 	xx.ifr_addr.sa_family = AF_INET;
 	xx.ifr_addr.sa_family = AF_INET;
 	snprintf(xx.ifr_name, sizeof xx.ifr_name, "%s", name);
 	snprintf(xx.ifr_name, sizeof xx.ifr_name, "%s", name);
-	n = ioctl(s,SIOCGIFMTU, &xx);
+	n = ioctl(s, SIOCGIFMTU, &xx);
 	if (n == -1) {
 	if (n == -1) {
 		perror("Can't get mtu");
 		perror("Can't get mtu");
 		return 1500;
 		return 1500;
 	}
 	}
 	close(s);
 	close(s);
+	// FreeBSD bpf writes are capped at one PAGESIZE'd mbuf. As such we must
+	// limit our sector count. See FreeBSD PR 205164, OpenAoE/vblade #7.
+	p = getpagesize();
+	if (xx.ifr_mtu > p) {
+		return p;
+	}
 	return xx.ifr_mtu;
 	return xx.ifr_mtu;
 }
 }
 
 
 vlong
 vlong
 getsize(int fd)
 getsize(int fd)
 {
 {
+	off_t media_size;
 	vlong size;
 	vlong size;
 	struct stat s;
 	struct stat s;
 	int n;
 	int n;
-	struct disklabel lab;
 
 
 	// Try getting disklabel from block dev
 	// Try getting disklabel from block dev
-	if ((n = ioctl(fd, DIOCGDINFO, lab)) != -1) {  
-		size = lab.d_secsize * lab.d_secperunit;
+	if ((n = ioctl(fd, DIOCGMEDIASIZE, &media_size)) != -1) {
+		size = media_size;
 	} else {
 	} else {
 		// must not be a block special dev
 		// must not be a block special dev
 		if (fstat(fd, &s) == -1) {
 		if (fstat(fd, &s) == -1) {

+ 4 - 0
linux.c

@@ -47,6 +47,10 @@ dial(char *eth, int bufcnt)		// get us a raw connection to an interface
 		return -1;
 		return -1;
 	}
 	}
 	i = getindx(s, eth);
 	i = getindx(s, eth);
+	if (i < 0) {
+		perror(eth);
+		return -1;
+	}
 	sa.sll_family = AF_PACKET;
 	sa.sll_family = AF_PACKET;
 	sa.sll_protocol = htons(0x88a2);
 	sa.sll_protocol = htons(0x88a2);
 	sa.sll_ifindex = i;
 	sa.sll_ifindex = i;

+ 8 - 8
vblade.8

@@ -35,39 +35,39 @@ The name of the regular file or block device to export.
 .SS Options
 .SS Options
 .TP
 .TP
 \fB-b\fP
 \fB-b\fP
-The -b flag takes an argument, the advertised buffer count, specifying
+The \-b flag takes an argument, the advertised buffer count, specifying
 the maximum number of outstanding messages the server can queue for
 the maximum number of outstanding messages the server can queue for
 processing.
 processing.
 .TP
 .TP
 \fB-d\fP
 \fB-d\fP
-The -d flag selects O_DIRECT mode for accessing the underlying block
+The \-d flag selects O_DIRECT mode for accessing the underlying block
 device.
 device.
 .TP
 .TP
 \fB-s\fP
 \fB-s\fP
-The -s flag selects O_SYNC mode for accessing the underlying block
+The \-s flag selects O_SYNC mode for accessing the underlying block
 device, so all writes are committed to disk before returning to the
 device, so all writes are committed to disk before returning to the
 client.
 client.
 .TP
 .TP
 \fB-r\fP
 \fB-r\fP
-The -r flag restricts the export of the device to be read-only.
+The \-r flag restricts the export of the device to be read-only.
 .TP
 .TP
 \fB-m\fP
 \fB-m\fP
-The -m flag takes an argument, a comma separated list of MAC addresses
+The \-m flag takes an argument, a comma separated list of MAC addresses
 permitted access to the vblade.  A MAC address can be specified in upper
 permitted access to the vblade.  A MAC address can be specified in upper
 or lower case, with or without colons.
 or lower case, with or without colons.
 .TP
 .TP
 \fB-o\fP
 \fB-o\fP
-The -o flag takes an argument, the number of sectors at the beginning
+The \-o flag takes an argument, the number of sectors at the beginning
 of the exported file that are excluded from AoE export (default zero).
 of the exported file that are excluded from AoE export (default zero).
 .TP
 .TP
 \fB-l\fP
 \fB-l\fP
-The -l flag takes an argument, the number of sectors to export.
+The \-l flag takes an argument, the number of sectors to export.
 Defaults to the file size in sectors minus the offset.
 Defaults to the file size in sectors minus the offset.
 .SH EXAMPLE
 .SH EXAMPLE
 In this example, the root user on a host named
 In this example, the root user on a host named
 .I nai
 .I nai
 exports a file named "3TB" to the LAN on eth0 using AoE shelf address 11
 exports a file named "3TB" to the LAN on eth0 using AoE shelf address 11
-and slot address 1.  The process runs in the foreground.  Using 
+and slot address 1.  The process runs in the foreground.  Using
 .I vbladed
 .I vbladed
 would have resulted in the process running as a daemon in the
 would have resulted in the process running as a daemon in the
 background.
 background.