Browse Source

Import upstream version 24

Ed Cashin 7 months ago
parent
commit
a2a0908195
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 -*-
+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>
 	Add convenience script for creating sparse files
 	vblade-23

+ 2 - 0
aoe.c

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

+ 2 - 3
dat.h

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

+ 12 - 6
freebsd.c

@@ -25,7 +25,7 @@
 #include <sys/types.h>
 #include <net/if.h>
 #include <sys/stat.h>
-#include <sys/disklabel.h>
+#include <sys/disk.h>
 #include <sys/select.h>
 #include <sys/sysctl.h>
 
@@ -262,7 +262,7 @@ int
 getmtu(int fd, char *name)
 {
 	struct ifreq xx;
-	int s, n;
+	int s, n, p;
 
 	s = socket(AF_INET, SOCK_RAW, 0);
 	if (s == -1) {
@@ -271,26 +271,32 @@ getmtu(int fd, char *name)
 	}
 	xx.ifr_addr.sa_family = AF_INET;
 	snprintf(xx.ifr_name, sizeof xx.ifr_name, "%s", name);
-	n = ioctl(s,SIOCGIFMTU, &xx);
+	n = ioctl(s, SIOCGIFMTU, &xx);
 	if (n == -1) {
 		perror("Can't get mtu");
 		return 1500;
 	}
 	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;
 }
 
 vlong
 getsize(int fd)
 {
+	off_t media_size;
 	vlong size;
 	struct stat s;
 	int n;
-	struct disklabel lab;
 
 	// 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 {
 		// must not be a block special dev
 		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;
 	}
 	i = getindx(s, eth);
+	if (i < 0) {
+		perror(eth);
+		return -1;
+	}
 	sa.sll_family = AF_PACKET;
 	sa.sll_protocol = htons(0x88a2);
 	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
 .TP
 \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
 processing.
 .TP
 \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.
 .TP
 \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
 client.
 .TP
 \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
 \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
 or lower case, with or without colons.
 .TP
 \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).
 .TP
 \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.
 .SH EXAMPLE
 In this example, the root user on a host named
 .I nai
 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
 would have resulted in the process running as a daemon in the
 background.