i.e.
./ut listall i eth1
I have managed to get it work on my laptop however I haven't been able
to test it anywhere else. Could someone check it out and test it to see
if it work. I have attached the patch above.
Thanks
--
John Tindell
http://www.yeticode.co.uk
That capability was already present but you disabled it to add it
again with non-standard command line option?
Just use (the existing) -d INTERFACE?
--Iain
> Index: /home/linal/workspace/sc101-nbd/psan.c
> ===================================================================
> --- /home/linal/workspace/sc101-nbd/psan.c (revision 41)
> +++ /home/linal/workspace/sc101-nbd/psan.c (working copy)
> @@ -47,14 +47,23 @@
>
> if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on)) != 0)
> err(EXIT_FAILURE, "setsockopt(fd, SOL_SOCKET, SO_BROADCAST)");
> -
> +/*
> if (dev && (setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, dev, strlen(dev)+1) < 0))
> err(EXIT_FAILURE, "setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, %s)", dev);
> -
> +*/
> if (bind(sock, (struct sockaddr *)&(struct sockaddr_in){ .sin_family=AF_INET, .sin_port=htons(20001) }, sizeof(struct sockaddr_in)) < 0 && errno != EADDRINUSE)
> warn("bind(fd, {sa_family=AF_INET, sin_port=htons(20001)})");
> +
> }
>
> +void psan_iface(char *device)
> +{
> + //char device[5] = {'e','t','h','1'};
> + fprintf(stdout,"Interface: '%-4s\n",device);
> + if (setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, device, strlen(device)+1) == -1)
> + err(EXIT_FAILURE, "setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE)");
> +}
> +
> void psan_cleanup(void)
> {
> if (sock)
> Index: /home/linal/workspace/sc101-nbd/psan.h
> ===================================================================
> --- /home/linal/workspace/sc101-nbd/psan.h (revision 41)
> +++ /home/linal/workspace/sc101-nbd/psan.h (working copy)
> @@ -61,6 +61,7 @@
> };
>
> void psan_init(char *dev);
> +void psan_iface(char * device);
> void psan_cleanup(void);
>
> struct disks_t *psan_find_disks(void);
> Index: /home/linal/workspace/sc101-nbd/ut.c
> ===================================================================
> --- /home/linal/workspace/sc101-nbd/ut.c (revision 41)
> +++ /home/linal/workspace/sc101-nbd/ut.c (working copy)
> @@ -115,7 +115,9 @@
>
> void usage(void)
> {
> - fprintf(stderr, "usage: ut OPTIONS\n");
> + fprintf(stderr, "usage: ut [OPTIONS] [i (interface)]\n");
> + fprintf(stderr, "\ti network interface, default eth0\n");
> + fprintf(stderr, "\t ie: \"ut listall i eth1\"\n");
>
> exit(1);
> }
> @@ -560,33 +562,47 @@
>
> int main(int argc, char *argv[])
> {
> +
> char *dev = NULL;
> char *cmd = NULL;
> int ch;
> -
> +
> while ((ch = getopt(argc, argv, "d:D")) != -1)
> {
> - switch (ch) {
> - case 'd':
> - dev = optarg;
> - break;
> - case 'D':
> - debug = 1;
> - break;
> - case '?':
> - default:
> - usage();
> - }
> + switch (ch) {
> + break;
> + case 'd':
> + dev = optarg;
> + break;
> + case 'D':
> + debug = 1;
> + break;
> + case '?':
> + default:
> + usage();
> + }
> }
> -
> +
> psan_init(dev);
> +
> + //check to see if we need to set the interface to a differnet one first
> + if(!strcmp(argv[argc -2], "i"))
> + {
> + //take the last param and pass it to the psan_iface
> + psan_iface(argv[argc -1]);
> + //drop the end args so that don't have to change more code, lazyness rules
> + argc = argc - 2;
> + }
> +
> +
>
> #define args (argc - optind)
> if (args < 1)
> usage();
>
> +
> cmd = argv[optind++];
> -
> +
> if (!strcmp(cmd, "listall") && !args)
> psan_listall();
> else if (!strcmp(cmd, "resolve") && args == 1)
> Index: /home/linal/workspace/sc101-nbd/Makefile
> ===================================================================
> --- /home/linal/workspace/sc101-nbd/Makefile (revision 41)
> +++ /home/linal/workspace/sc101-nbd/Makefile (working copy)
> @@ -20,9 +20,8 @@
> sysconfdir = /etc
> sbindir = /sbin
> man8dir = /usr/share/man/man8
> +make: ut
>
> -all: ut
> -
> ut: $(OBJS)
>
> include .depend
>
>
Can you send the output of 'strace ut -d ethX listall' and/or a
tcpdump from the interface with the sc101 when you run the command?
Are your firewalls open enough to allow the traffic?
iptables -I INPUT -p udp --sport 20001 -j ACCEPT
> I am curious, if I can actually get ut listall to show all partitions,
> by specifying the interface, how will this actually allow me
> mkfs.gfs2 /dev/nbd0?
ut listall will just show devices available on the LAN.
you will then need to attach one of the discovered devices using the
UUID in the ut listall output: 'ut -d ethX attach UUID /dev/nbd0'
--Iain