Re: [Linux-ha-dev] [PATCH] IPv6addr: removing libnet dependency
On Tue, Aug 10, 2010 at 12:17:05AM +0200, Lars Marowsky-Bree wrote: On 2010-07-30T16:12:24, Simon Horman ho...@verge.net.au wrote: This change looks good to me. I have applied the change. http://hg.linux-ha.org/agents/rev/612e2966f372 I've had to commit a small revision, because on IA64, the memory on the stack is not aligned properly for the cast to struct nd_neighbor_advert * - http://hg.linux-ha.org/agents/rev/d206bc8f1303 I apologize for the uglyness; it was the only way I could make gcc shutup and get the alignment right. If someone can make the alignment properly on the stack, I'm all ears ... You are right, that is a bit ugly. But I have no better ideas at this time :-( ___ Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/
Re: [Linux-ha-dev] [PATCH] IPv6addr: removing libnet dependency
2010/8/11 Simon Horman ho...@verge.net.au: http://hg.linux-ha.org/agents/rev/612e2966f372 I've had to commit a small revision, because on IA64, the memory on the stack is not aligned properly for the cast to struct nd_neighbor_advert * - http://hg.linux-ha.org/agents/rev/d206bc8f1303 I apologize for the uglyness; it was the only way I could make gcc shutup and get the alignment right. If someone can make the alignment properly on the stack, I'm all ears ... You are right, that is a bit ugly. But I have no better ideas at this time :-( How about this patch or along this line? It assumes GCC but ICC should have a similar feature if you want to support it. Alternatively, having an union with an u_int8_t array and a struct should make an alignment correctly, I think. -- Keisuke MORI # HG changeset patch # User Keisuke MORI kskm...@intellilink.co.jp # Date 1281491442 -32400 # Node ID b12ca86af66197498cbf537ccc7ad4ff56cdf63b # Parent d206bc8f13039b332e76a93a86e8e550b67781da [mq]: ipv6addr-alignment.patch diff -r d206bc8f1303 -r b12ca86af661 heartbeat/IPv6addr.c --- a/heartbeat/IPv6addr.c Mon Aug 09 21:51:19 2010 +0200 +++ b/heartbeat/IPv6addr.c Wed Aug 11 10:50:42 2010 +0900 @@ -89,7 +89,6 @@ #include stdio.h #include stdlib.h -#include malloc.h #include unistd.h #include sys/types.h #include sys/socket.h @@ -424,10 +423,17 @@ int ifindex; int hop; struct ifreq ifr; - u_int8_t *payload; - intpayload_size; - struct nd_neighbor_advert *na; - struct nd_opt_hdr *opt; + + /* GCC is assumed. + * If you want to port to other than GCC, make sure that + * the packet is packed correctly. + */ + struct neighbor_advert { + struct nd_neighbor_advert na; + struct nd_opt_hdr opt; + u_int8_t hwaddr[HWADDR_LEN]; + } __attribute__ ((packed)) payload; + struct sockaddr_in6 src_sin6; struct sockaddr_in6 dst_sin6; @@ -473,39 +479,27 @@ } /* build a neighbor advertisement message */ - payload_size = sizeof(struct nd_neighbor_advert) - + sizeof(struct nd_opt_hdr) + HWADDR_LEN; - payload = memalign(sysconf(_SC_PAGESIZE), payload_size); - if (!payload) { - cl_log(LOG_ERR, malloc for payload failed); - goto err; - } - memset(payload, 0, payload_size); + memset((void *)payload, 0, sizeof(payload)); - /* Ugly typecast from ia64 hell! */ - na = (struct nd_neighbor_advert *)((void *)payload); - na-nd_na_type = ND_NEIGHBOR_ADVERT; - na-nd_na_code = 0; - na-nd_na_cksum = 0; /* calculated by kernel */ - na-nd_na_flags_reserved = ND_NA_FLAG_OVERRIDE; - na-nd_na_target = *src_ip; + payload.na.nd_na_type = ND_NEIGHBOR_ADVERT; + payload.na.nd_na_code = 0; + payload.na.nd_na_cksum = 0; /* calculated by kernel */ + payload.na.nd_na_flags_reserved = ND_NA_FLAG_OVERRIDE; + payload.na.nd_na_target = *src_ip; /* options field; set the target link-layer address */ - opt = (struct nd_opt_hdr *)(payload + sizeof(struct nd_neighbor_advert)); - opt-nd_opt_type = ND_OPT_TARGET_LINKADDR; - opt-nd_opt_len = 1; /* The length of the option in units of 8 octets */ - memcpy(payload + sizeof(struct nd_neighbor_advert) - + sizeof(struct nd_opt_hdr), - ifr.ifr_hwaddr.sa_data, HWADDR_LEN); + payload.opt.nd_opt_type = ND_OPT_TARGET_LINKADDR; + payload.opt.nd_opt_len = 1; /* The length of the option in units of 8 octets */ + memcpy(payload.hwaddr, ifr.ifr_hwaddr.sa_data, HWADDR_LEN); /* sending an unsolicited neighbor advertisement to all */ memset(dst_sin6, 0, sizeof(dst_sin6)); dst_sin6.sin6_family = AF_INET6; inet_pton(AF_INET6, BCAST_ADDR, dst_sin6.sin6_addr); /* should not fail */ - if (sendto(fd, payload, payload_size, 0, + if (sendto(fd, (void *)payload, sizeof(payload), 0, (struct sockaddr *)dst_sin6, sizeof(dst_sin6)) - != payload_size) { + != sizeof(payload)) { cl_log(LOG_ERR, sendto(%s) failed: %s, if_name, strerror(errno)); goto err; @@ -515,7 +509,6 @@ err: close(fd); - free(payload); return status; } ___ Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/
Re: [Linux-ha-dev] [PATCH] IPv6addr: removing libnet dependency
On 2010-07-30T16:12:24, Simon Horman ho...@verge.net.au wrote: This change looks good to me. I have applied the change. http://hg.linux-ha.org/agents/rev/612e2966f372 I've had to commit a small revision, because on IA64, the memory on the stack is not aligned properly for the cast to struct nd_neighbor_advert * - http://hg.linux-ha.org/agents/rev/d206bc8f1303 I apologize for the uglyness; it was the only way I could make gcc shutup and get the alignment right. If someone can make the alignment properly on the stack, I'm all ears ... Regards, Lars -- Architect Storage/HA, OPS Engineering, Novell, Inc. SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg) Experience is the name everyone gives to their mistakes. -- Oscar Wilde ___ Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/
Re: [Linux-ha-dev] [PATCH] IPv6addr: removing libnet dependency
On Mon, Jul 26, 2010 at 08:39:48PM +0900, Simon Horman wrote: On Mon, Jul 26, 2010 at 06:39:50PM +0900, Keisuke MORI wrote: Hi, 2010/7/23 Lars Ellenberg lars.ellenb...@linbit.com: On Fri, Jul 23, 2010 at 03:04:20PM +0200, Andrew Beekhof wrote: On Fri, Jul 23, 2010 at 5:09 AM, Simon Horman ho...@verge.net.au wrote: Hi Mori-san, I will add that libnet seems to be more or less unmaintained. Someone recently picked it up again, but I'm in favor of the patch for the reasons Mori-san already stated. You seem to make using libnet optional, is there a reason not to just remove it? portability? Agreed, lets just drop it. Ack. Thanks to Simon, Andrew and Lars for all of your constructive comments. This change looks good to me. I have applied the change. http://hg.linux-ha.org/agents/rev/612e2966f372 ___ Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/
Re: [Linux-ha-dev] [PATCH] IPv6addr: removing libnet dependency
2010/7/27 Andrew Beekhof and...@beekhof.net: On Tue, Jul 27, 2010 at 8:44 AM, Keisuke MORI keisuke.mori...@gmail.com wrote: For heartbeat, I personally like pacemaker on in ha.cf :) One thing thats coming in 1.1.3 is an mcp (master control process) and associated init script for pacemaker. This means that Pacemaker is started/stopped independently of the messaging layer. Currently this is only written for corosync[1], but I've been toying with the idea of extending it to Heartbeat. In which case, if you're already changing the option, you might want to make it: legacy on/off Where off would be the equivalent of starting with -M (no resource management) but wouldn't spawn any daemons. Thoughts? I have a several concerns with that change, 1) Is it possible to recover or cause a fail-over correctly when any of the Pacemaker/Heartbeat process was failed? (In particular, for the failure of the new mcp process of pacemaker and for the current heartbeat's MCP process failure) 2) Would the daemons used with respawn directive such as hbagent(SNMP daemon) or pingd work as compatible? 3) After all, what would be the benefit for end users with the change? I feel like it's only adding some complexity to the operations and the diagnostics by the end users. I guess that I would only use legacy on on the heartbeat stack... -- Keisuke MORI ___ Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/
Re: [Linux-ha-dev] [PATCH] IPv6addr: removing libnet dependency
On Fri, Jul 30, 2010 at 11:42 AM, Keisuke MORI keisuke.mori...@gmail.com wrote: 2010/7/27 Andrew Beekhof and...@beekhof.net: On Tue, Jul 27, 2010 at 8:44 AM, Keisuke MORI keisuke.mori...@gmail.com wrote: For heartbeat, I personally like pacemaker on in ha.cf :) One thing thats coming in 1.1.3 is an mcp (master control process) and associated init script for pacemaker. This means that Pacemaker is started/stopped independently of the messaging layer. Currently this is only written for corosync[1], but I've been toying with the idea of extending it to Heartbeat. In which case, if you're already changing the option, you might want to make it: legacy on/off Where off would be the equivalent of starting with -M (no resource management) but wouldn't spawn any daemons. Thoughts? I have a several concerns with that change, 1) Is it possible to recover or cause a fail-over correctly when any of the Pacemaker/Heartbeat process was failed? (In particular, for the failure of the new mcp process of pacemaker and for the current heartbeat's MCP process failure) If the MCP dies, so will the crmd and cib (and by extension, everything else except the PE and LRMd). The types of failures are well tested. Failure of heartbeat also result in the same types of secondary failures and recovery as we see now. 2) Would the daemons used with respawn directive such as hbagent(SNMP daemon) or pingd work as compatible? Pingd will no longer exist in 1.1, if I've not removed it already. It is completely replaced by ocf:pacemaker:ping hbagent might have to be a bit smarter about what to do when the cib isn't around, but otherwise it shouldn't be a problem. 3) After all, what would be the benefit for end users with the change? For corosync based clusters its a clear win - we get a much more reliable startup/shutdown sequence. Its also far more obvious what is happening at each stage, one can also stop all resources on a node without taking the node offline. If we changed it for heartbeat, it would be mostly for consistency. I feel like it's only adding some complexity to the operations and the diagnostics by the end users. I guess that I would only use legacy on on the heartbeat stack... Correct. ___ Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/
Re: [Linux-ha-dev] [PATCH] IPv6addr: removing libnet dependency
2010/7/26 Lars Ellenberg lars.ellenb...@linbit.com: On Mon, Jul 26, 2010 at 06:39:50PM +0900, Keisuke MORI wrote: By the way, do we have any plan to release the next agents/glue/heartbeat packages from the Linux-HA project? I think it's good time to consider them for the best use of pacemaker-1.0.9. I think glue was released by dejan just before he went on vacation, though the release announcement is missing (1.0.6). Heartbeat does not have many changes (appart from some cleanup in the build dependencies), so there is no urge to release a 3.0.4, but we could do so any time. Agents has a few fixes, but also has some big changes. I have to take an other close look, but yes, I think we should release an agents 1.0.4 within the next few weeks. Great! Then let's go for the next release for agents/heartbeat along with glue. My most concern about agents is LF#2378: http://developerbugs.linux-foundation.org/show_bug.cgi?id=2378 It is a change but it's a necessary change to make the maintenance mode work fine. For heartbeat, I personally like pacemaker on in ha.cf :) find_if for IPv6 is also missing if you want to write a script based one. I'm sure that can be scripted itself around ip -o -f inet6 a s | grep ... but we already sort of agreed that this would not be development time well spent. find_if does more than just grepping. It has to do matching against the network address calculated from the given address and the prefix to find out which interface would be appropriate to be assigned the virtual address. The current IPaddr2 also relies on find_if to do this. But anyway, I would also agree that we are not going to develop such. Just off topic. Thanks, -- Keisuke MORI ___ Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/
Re: [Linux-ha-dev] [PATCH] IPv6addr: removing libnet dependency
2010/7/27 Keisuke MORI keisuke.mori...@gmail.com: 2010/7/26 Lars Ellenberg lars.ellenb...@linbit.com: On Mon, Jul 26, 2010 at 06:39:50PM +0900, Keisuke MORI wrote: Heartbeat does not have many changes (appart from some cleanup in the build dependencies), so there is no urge to release a 3.0.4, but we could do so any time. (...) For heartbeat, I personally like pacemaker on in ha.cf :) I should have mentioned this too, the version number in the log file from heartbeat 3.0.3 seems incorrect. I want to fix this soon to avoid confusion. Jul 20 14:08:50 srv01 heartbeat: [6299]: info: Configuration validated. Starting heartbeat 3.0.2 Thanks, -- Keisuke MORI ___ Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/
Re: [Linux-ha-dev] [PATCH] IPv6addr: removing libnet dependency
On Tue, Jul 27, 2010 at 03:44:21PM +0900, Keisuke MORI wrote: 2010/7/26 Lars Ellenberg lars.ellenb...@linbit.com: On Mon, Jul 26, 2010 at 06:39:50PM +0900, Keisuke MORI wrote: By the way, do we have any plan to release the next agents/glue/heartbeat packages from the Linux-HA project? I think it's good time to consider them for the best use of pacemaker-1.0.9. I think glue was released by dejan just before he went on vacation, though the release announcement is missing (1.0.6). Heartbeat does not have many changes (appart from some cleanup in the build dependencies), so there is no urge to release a 3.0.4, but we could do so any time. Agents has a few fixes, but also has some big changes. I have to take an other close look, but yes, I think we should release an agents 1.0.4 within the next few weeks. Great! Then let's go for the next release for agents/heartbeat along with glue. My most concern about agents is LF#2378: http://developerbugs.linux-foundation.org/show_bug.cgi?id=2378 It is a change but it's a necessary change to make the maintenance mode work fine. For heartbeat, I personally like pacemaker on in ha.cf :) find_if for IPv6 is also missing if you want to write a script based one. I'm sure that can be scripted itself around ip -o -f inet6 a s | grep ... but we already sort of agreed that this would not be development time well spent. find_if does more than just grepping. It has to do matching against the network address calculated from the given address and the prefix to find out which interface would be appropriate to be assigned the virtual address. The current IPaddr2 also relies on find_if to do this. But anyway, I would also agree that we are not going to develop such. Just off topic. Personally I think find_if is an abomination to mankind. But if one really wants such a thing, I wonder if it can be done like this: ip -o addr show to PREFIX | cut -d ' ' -f 2 Where PREFIX can either be the address to be added: ip -o addr show to 172.16.4.222/16 | cut -d ' ' -f 2 ip -o addr show to 172.16.4.222 | cut -d ' ' -f 2 Or the network to which the address is to be added: ip -o addr show to 172.16.0.0/16 | cut -d ' ' -f 2 And this also works with IPv6 ip -o addr show to fe80::20c:76ff:fe24:932/64 | cut -d ' ' -f 2 ip -o addr show to fe80::20c:76ff:fe24:932 | cut -d ' ' -f 2 ip -o addr show to fe80::20c:76ff:0:0/64 | cut -d ' ' -f 2 Although I suspect its schemantics are slightly different that of find_if ___ Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/
Re: [Linux-ha-dev] [PATCH] IPv6addr: removing libnet dependency
On Tue, Jul 27, 2010 at 8:44 AM, Keisuke MORI keisuke.mori...@gmail.com wrote: 2010/7/26 Lars Ellenberg lars.ellenb...@linbit.com: On Mon, Jul 26, 2010 at 06:39:50PM +0900, Keisuke MORI wrote: By the way, do we have any plan to release the next agents/glue/heartbeat packages from the Linux-HA project? I think it's good time to consider them for the best use of pacemaker-1.0.9. I think glue was released by dejan just before he went on vacation, though the release announcement is missing (1.0.6). Heartbeat does not have many changes (appart from some cleanup in the build dependencies), so there is no urge to release a 3.0.4, but we could do so any time. Agents has a few fixes, but also has some big changes. I have to take an other close look, but yes, I think we should release an agents 1.0.4 within the next few weeks. Great! Then let's go for the next release for agents/heartbeat along with glue. My most concern about agents is LF#2378: http://developerbugs.linux-foundation.org/show_bug.cgi?id=2378 It is a change but it's a necessary change to make the maintenance mode work fine. For heartbeat, I personally like pacemaker on in ha.cf :) One thing thats coming in 1.1.3 is an mcp (master control process) and associated init script for pacemaker. This means that Pacemaker is started/stopped independently of the messaging layer. Currently this is only written for corosync[1], but I've been toying with the idea of extending it to Heartbeat. In which case, if you're already changing the option, you might want to make it: legacy on/off Where off would be the equivalent of starting with -M (no resource management) but wouldn't spawn any daemons. Thoughts? [1] Which has an API call which allows Pacemaker to prevent Corosync from shutting down if its still running. So service corosync stop will fail if you didnt already run service pacemaker stop ___ Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/
Re: [Linux-ha-dev] [PATCH] IPv6addr: removing libnet dependency
On Tue, Jul 27, 2010 at 04:12:34PM +0900, Keisuke MORI wrote: 2010/7/27 Keisuke MORI keisuke.mori...@gmail.com: 2010/7/26 Lars Ellenberg lars.ellenb...@linbit.com: On Mon, Jul 26, 2010 at 06:39:50PM +0900, Keisuke MORI wrote: Heartbeat does not have many changes (appart from some cleanup in the build dependencies), so there is no urge to release a 3.0.4, but we could do so any time. (...) For heartbeat, I personally like pacemaker on in ha.cf :) I should have mentioned this too, the version number in the log file from heartbeat 3.0.3 seems incorrect. I want to fix this soon to avoid confusion. Jul 20 14:08:50 srv01 heartbeat: [6299]: info: Configuration validated. Starting heartbeat 3.0.2 Yes, I know. Not a problem. Needs to be changed in configure.ac before the 3.0.4 release. -- : Lars Ellenberg : LINBIT | Your Way to High Availability : DRBD/HA support and consulting http://www.linbit.com DRBD® and LINBIT® are registered trademarks of LINBIT, Austria. ___ Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/
Re: [Linux-ha-dev] [PATCH] IPv6addr: removing libnet dependency
Hi, 2010/7/23 Lars Ellenberg lars.ellenb...@linbit.com: On Fri, Jul 23, 2010 at 03:04:20PM +0200, Andrew Beekhof wrote: On Fri, Jul 23, 2010 at 5:09 AM, Simon Horman ho...@verge.net.au wrote: Hi Mori-san, I will add that libnet seems to be more or less unmaintained. Someone recently picked it up again, but I'm in favor of the patch for the reasons Mori-san already stated. You seem to make using libnet optional, is there a reason not to just remove it? portability? Agreed, lets just drop it. Ack. Thanks to Simon, Andrew and Lars for all of your constructive comments. I've revised the patch so that it drops the old libnet code completely. Please apply this into the repository. By the way, do we have any plan to release the next agents/glue/heartbeat packages from the Linux-HA project? I think it's good time to consider them for the best use of pacemaker-1.0.9. BTW, is it correct that most of it could be done by ip, similar as IPaddr2 does it? The only think missing would be a send_arp v6. Anyone want to write an IPv6addr2? ;-) find_if for IPv6 is also missing if you want to write a script based one. Thanks, -- Keisuke MORI # HG changeset patch # User Keisuke MORI kskm...@intellilink.co.jp # Date 1280134509 -32400 # Branch ipv6 # Node ID 275089e31232b870e4218f7dd930538daa438cbf # Parent b3142fd9cc672f2217e632608bc986b46265b193 IPv6addr: remove libnet dependency diff -r b3142fd9cc67 -r 275089e31232 configure.in --- a/configure.in Fri Jul 16 09:46:38 2010 +0200 +++ b/configure.in Mon Jul 26 17:55:09 2010 +0900 @@ -634,7 +634,7 @@ dnl dnl * Check for netinet/icmp6.h to enable the IPv6addr resource agent AC_CHECK_HEADERS(netinet/icmp6.h,[],[],[#include sys/types.h]) -AM_CONDITIONAL(USE_IPV6ADDR, test $ac_cv_header_netinet_icmp6_h = yes -a $new_libnet = yes ) +AM_CONDITIONAL(USE_IPV6ADDR, test $ac_cv_header_netinet_icmp6_h = yes ) dnl dnl Compiler flags diff -r b3142fd9cc67 -r 275089e31232 heartbeat/IPv6addr.c --- a/heartbeat/IPv6addr.c Fri Jul 16 09:46:38 2010 +0200 +++ b/heartbeat/IPv6addr.c Mon Jul 26 17:55:09 2010 +0900 @@ -87,13 +87,22 @@ #include config.h +#include stdio.h #include stdlib.h +#include unistd.h #include sys/types.h +#include sys/socket.h #include netinet/icmp6.h +#include arpa/inet.h /* for inet_pton */ +#include net/if.h /* for if_nametoindex */ +#include sys/ioctl.h +#include sys/stat.h +#include fcntl.h #include libgen.h #include syslog.h +#include signal.h +#include errno.h #include clplumbing/cl_log.h -#include libnet.h #define PIDFILE_BASE HA_RSCTMPDIR /IPv6addr- @@ -141,6 +150,8 @@ const int UA_REPEAT_COUNT = 5; const int QUERY_COUNT = 5; +#define HWADDR_LEN 6 /* mac address length */ + struct in6_ifreq { struct in6_addr ifr6_addr; uint32_t ifr6_prefixlen; @@ -401,69 +412,100 @@ } /* Send an unsolicited advertisement packet - * Please refer to rfc2461 + * Please refer to rfc4861 / rfc3542 */ int send_ua(struct in6_addr* src_ip, char* if_name) { int status = -1; - libnet_t *l; - char errbuf[LIBNET_ERRBUF_SIZE]; + int fd; - struct libnet_in6_addr dst_ip; - struct libnet_ether_addr *mac_address; - char payload[24]; int ifindex; + int hop; + struct ifreq ifr; + u_int8_t payload[sizeof(struct nd_neighbor_advert) + + sizeof(struct nd_opt_hdr) + HWADDR_LEN]; + struct nd_neighbor_advert *na; + struct nd_opt_hdr *opt; + struct sockaddr_in6 src_sin6; + struct sockaddr_in6 dst_sin6; - - if ((l=libnet_init(LIBNET_RAW6, if_name, errbuf)) == NULL) { - cl_log(LOG_ERR, libnet_init failure on %s, if_name); + if ((fd = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) == 0) { + cl_log(LOG_ERR, socket(IPPROTO_ICMPV6) failed: %s, + strerror(errno)); goto err; } /* set the outgoing interface */ ifindex = if_nametoindex(if_name); - if (setsockopt(libnet_getfd(l), IPPROTO_IPV6, IPV6_MULTICAST_IF, + if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF, ifindex, sizeof(ifindex)) 0) { - cl_log(LOG_ERR, setsockopt(IPV6_MULTICAST_IF): %s, + cl_log(LOG_ERR, setsockopt(IPV6_MULTICAST_IF) failed: %s, strerror(errno)); goto err; } - - mac_address = libnet_get_hwaddr(l); - if (!mac_address) { - cl_log(LOG_ERR, libnet_get_hwaddr: %s, errbuf); + /* set the hop limit */ + hop = 255; /* 255 is required. see rfc4861 7.1.2 */ + if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, + hop, sizeof(hop)) 0) { + cl_log(LOG_ERR, setsockopt(IPV6_MULTICAST_HOPS) failed: %s, + strerror(errno)); + goto err; + } + + /* set the source address */ + memset(src_sin6, 0, sizeof(src_sin6)); + src_sin6.sin6_family = AF_INET6; + src_sin6.sin6_addr = *src_ip; + src_sin6.sin6_port = 0; + if (bind(fd, (struct sockaddr *)src_sin6, sizeof(src_sin6)) 0) { + cl_log(LOG_ERR, bind() failed: %s, strerror(errno)); goto err; } - dst_ip =
Re: [Linux-ha-dev] [PATCH] IPv6addr: removing libnet dependency
On Mon, Jul 26, 2010 at 06:39:50PM +0900, Keisuke MORI wrote: I've revised the patch so that it drops the old libnet code completely. Please apply this into the repository. By the way, do we have any plan to release the next agents/glue/heartbeat packages from the Linux-HA project? I think it's good time to consider them for the best use of pacemaker-1.0.9. I think glue was released by dejan just before he went on vacation, though the release announcement is missing (1.0.6). Heartbeat does not have many changes (appart from some cleanup in the build dependencies), so there is no urge to release a 3.0.4, but we could do so any time. Agents has a few fixes, but also has some big changes. I have to take an other close look, but yes, I think we should release an agents 1.0.4 within the next few weeks. BTW, is it correct that most of it could be done by ip, similar as IPaddr2 does it? The only thing missing would be a send_arp v6. Anyone want to write an IPv6addr2? ;-) find_if for IPv6 is also missing if you want to write a script based one. I'm sure that can be scripted itself around ip -o -f inet6 a s | grep ... but we already sort of agreed that this would not be development time well spent. -- : Lars Ellenberg : LINBIT | Your Way to High Availability : DRBD/HA support and consulting http://www.linbit.com DRBD® and LINBIT® are registered trademarks of LINBIT, Austria. ___ Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/
Re: [Linux-ha-dev] [PATCH] IPv6addr: removing libnet dependency
On Mon, Jul 26, 2010 at 06:39:50PM +0900, Keisuke MORI wrote: Hi, 2010/7/23 Lars Ellenberg lars.ellenb...@linbit.com: On Fri, Jul 23, 2010 at 03:04:20PM +0200, Andrew Beekhof wrote: On Fri, Jul 23, 2010 at 5:09 AM, Simon Horman ho...@verge.net.au wrote: Hi Mori-san, I will add that libnet seems to be more or less unmaintained. Someone recently picked it up again, but I'm in favor of the patch for the reasons Mori-san already stated. You seem to make using libnet optional, is there a reason not to just remove it? portability? Agreed, lets just drop it. Ack. Thanks to Simon, Andrew and Lars for all of your constructive comments. This change looks good to me. ___ Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/
Re: [Linux-ha-dev] [PATCH] IPv6addr: removing libnet dependency
On Sat, Jul 24, 2010 at 12:48:30PM +0900, Simon Horman wrote: You seem to make using libnet optional, is there a reason not to just remove it? portability? Agreed, lets just drop it. Ack. BTW, is it correct that most of it could be done by ip, similar as IPaddr2 does it? The only think missing would be a send_arp v6. Anyone want to write an IPv6addr2? ;-) I believe that the main objection to using ip is that it doesn't exist outside of Linux. If you look at the history of IPaddr vs IPaddr2. Yes, I know. If we contrast this to IPv6addr, its cross platform, Oh, I did not realize that. So no, I don't think there is a strong reason for an ip based IPv6addr2. And I really wish the IPaddr/IPaddr2 situation didn't exist. me too ;-) -- : Lars Ellenberg : LINBIT | Your Way to High Availability : DRBD/HA support and consulting http://www.linbit.com DRBD® and LINBIT® are registered trademarks of LINBIT, Austria. ___ Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/
Re: [Linux-ha-dev] [PATCH] IPv6addr: removing libnet dependency
On Sat, Jul 24, 2010 at 12:52:26PM +0200, Lars Ellenberg wrote: On Sat, Jul 24, 2010 at 12:48:30PM +0900, Simon Horman wrote: You seem to make using libnet optional, is there a reason not to just remove it? portability? Agreed, lets just drop it. Ack. BTW, is it correct that most of it could be done by ip, similar as IPaddr2 does it? The only think missing would be a send_arp v6. Anyone want to write an IPv6addr2? ;-) I believe that the main objection to using ip is that it doesn't exist outside of Linux. If you look at the history of IPaddr vs IPaddr2. Yes, I know. Sorry if I sounded condescending, I know you know that code pretty well :-) If we contrast this to IPv6addr, its cross platform, Oh, I did not realize that. So no, I don't think there is a strong reason for an ip based IPv6addr2. And I really wish the IPaddr/IPaddr2 situation didn't exist. me too ;-) :-) ___ Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/
Re: [Linux-ha-dev] [PATCH] IPv6addr: removing libnet dependency
Hi, 2010/7/23 Simon Horman ho...@verge.net.au: I will add that libnet seems to be more or less unmaintained. You seem to make using libnet optional, is there a reason not to just remove it? portability? I just thought that some people may want to preserve the existing behavior. OpenSUSE has libnet shipped with it for example, and I'm not sure if they would agree to change the implementation or just want to keep using libnet. But ok, If no one has objections I'll revise the patch so that it removes all libnet code from IPv6addr.c and make it single code. Any other opinions? As for portability, I believe that the new implementation is more portable than using libnet. (cf. http://developerbugs.linux-foundation.org/show_bug.cgi?id=2034#c10) +#define HWADDR_LEN 6 /* mac address length */ Personally I'd prefer the define outside of the function. Ok, I just wanted to place them closely but no strong preference. I'll move it to somewhere around the other macro definitions. + na-nd_na_target = (*src_ip); There is no need to enclose *src_ip in brackets. Right. removing the parens. + if (sendto(fd, payload, sizeof(payload), 0, + (struct sockaddr *)dst_sin6, sizeof(dst_sin6)) + != sizeof(payload)) { Is it valid to assume that there will never be a partial write? I think that reporting an error is just enough when a partial write occurred here. The packet is very small (32 bytes) and it should rarely happen, it will be retried 5 times when it occurred, and if it still fails then it should be considered that a really bad things happened:-) And also the current libnet code does exactly same as above inside so no behavior would be changed with this code. Thanks, -- Keisuke MORI ___ Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/
Re: [Linux-ha-dev] [PATCH] IPv6addr: removing libnet dependency
On Fri, Jul 23, 2010 at 5:09 AM, Simon Horman ho...@verge.net.au wrote: On Fri, Jul 23, 2010 at 09:19:44AM +0900, Keisuke MORI wrote: The attached patch is to remove libnet dependency from IPv6addr RA by replacing the same functionality using the standard socket API. Currently there are following problems with resource-agents package: - IPv6addr RA requires an extra libnet package on the run-time environment. That is pretty inconvenient particularly for RHEL users because it's not included in the standard distribution. - The pre-built RPMs from ClusterLabs does not include IPv6addr RA. This was once reported in the pacemaker list: http://www.gossamer-threads.com/lists/linuxha/pacemaker/64295#64295 The patch will resolve those issues. I believe that none of Pacemaker/Heartbeat related packages would be depending on libnet library any more after patched. Hi Mori-san, I will add that libnet seems to be more or less unmaintained. Someone recently picked it up again, but I'm in favor of the patch for the reasons Mori-san already stated. You seem to make using libnet optional, is there a reason not to just remove it? portability? Agreed, lets just drop it. ___ Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/
Re: [Linux-ha-dev] [PATCH] IPv6addr: removing libnet dependency
On Fri, Jul 23, 2010 at 03:04:20PM +0200, Andrew Beekhof wrote: On Fri, Jul 23, 2010 at 5:09 AM, Simon Horman ho...@verge.net.au wrote: On Fri, Jul 23, 2010 at 09:19:44AM +0900, Keisuke MORI wrote: The attached patch is to remove libnet dependency from IPv6addr RA by replacing the same functionality using the standard socket API. Currently there are following problems with resource-agents package: - IPv6addr RA requires an extra libnet package on the run-time environment. That is pretty inconvenient particularly for RHEL users because it's not included in the standard distribution. - The pre-built RPMs from ClusterLabs does not include IPv6addr RA. This was once reported in the pacemaker list: http://www.gossamer-threads.com/lists/linuxha/pacemaker/64295#64295 The patch will resolve those issues. I believe that none of Pacemaker/Heartbeat related packages would be depending on libnet library any more after patched. Hi Mori-san, I will add that libnet seems to be more or less unmaintained. Someone recently picked it up again, but I'm in favor of the patch for the reasons Mori-san already stated. You seem to make using libnet optional, is there a reason not to just remove it? portability? Agreed, lets just drop it. Ack. BTW, is it correct that most of it could be done by ip, similar as IPaddr2 does it? The only think missing would be a send_arp v6. Anyone want to write an IPv6addr2? ;-) -- : Lars Ellenberg : LINBIT | Your Way to High Availability : DRBD/HA support and consulting http://www.linbit.com DRBD® and LINBIT® are registered trademarks of LINBIT, Austria. ___ Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/
Re: [Linux-ha-dev] [PATCH] IPv6addr: removing libnet dependency
On Fri, Jul 23, 2010 at 03:54:16PM +0200, Lars Ellenberg wrote: On Fri, Jul 23, 2010 at 03:04:20PM +0200, Andrew Beekhof wrote: On Fri, Jul 23, 2010 at 5:09 AM, Simon Horman ho...@verge.net.au wrote: On Fri, Jul 23, 2010 at 09:19:44AM +0900, Keisuke MORI wrote: The attached patch is to remove libnet dependency from IPv6addr RA by replacing the same functionality using the standard socket API. Currently there are following problems with resource-agents package: - IPv6addr RA requires an extra libnet package on the run-time environment. That is pretty inconvenient particularly for RHEL users because it's not included in the standard distribution. - The pre-built RPMs from ClusterLabs does not include IPv6addr RA. This was once reported in the pacemaker list: http://www.gossamer-threads.com/lists/linuxha/pacemaker/64295#64295 The patch will resolve those issues. I believe that none of Pacemaker/Heartbeat related packages would be depending on libnet library any more after patched. Hi Mori-san, I will add that libnet seems to be more or less unmaintained. Someone recently picked it up again, but I'm in favor of the patch for the reasons Mori-san already stated. You seem to make using libnet optional, is there a reason not to just remove it? portability? Agreed, lets just drop it. Ack. BTW, is it correct that most of it could be done by ip, similar as IPaddr2 does it? The only think missing would be a send_arp v6. Anyone want to write an IPv6addr2? ;-) I believe that the main objection to using ip is that it doesn't exist outside of Linux. If you look at the history of IPaddr vs IPaddr2. They are both scripts. The former is based on ifconfig and route, and is portable. IPaddr2 is based on ip is cleaner and probably has better features. There is also a compatibility issue because ip aliases aren't exactly the same as secondary addresses. If we contrast this to IPv6addr, its cross platform, and there seems to be no strong argument for new features (at all, let alone ones that can't be added to the C code). So no, I don't think there is a strong reason for an ip based IPv6addr2. And I really wish the IPaddr/IPaddr2 situation didn't exist. ___ Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/
Re: [Linux-ha-dev] [PATCH] IPv6addr: removing libnet dependency
On Fri, Jul 23, 2010 at 09:19:44AM +0900, Keisuke MORI wrote: The attached patch is to remove libnet dependency from IPv6addr RA by replacing the same functionality using the standard socket API. Currently there are following problems with resource-agents package: - IPv6addr RA requires an extra libnet package on the run-time environment. That is pretty inconvenient particularly for RHEL users because it's not included in the standard distribution. - The pre-built RPMs from ClusterLabs does not include IPv6addr RA. This was once reported in the pacemaker list: http://www.gossamer-threads.com/lists/linuxha/pacemaker/64295#64295 The patch will resolve those issues. I believe that none of Pacemaker/Heartbeat related packages would be depending on libnet library any more after patched. Hi Mori-san, I will add that libnet seems to be more or less unmaintained. You seem to make using libnet optional, is there a reason not to just remove it? portability? # HG changeset patch # User Keisuke MORI kskm...@intellilink.co.jp # Date 1279802861 -32400 # Branch ipv6 # Node ID 40d5dbdca9cc089b6514c7525cd2dbd678299711 # Parent b3142fd9cc672f2217e632608bc986b46265b193 IPv6addr: remove libnet dependency diff -r b3142fd9cc67 -r 40d5dbdca9cc configure.in --- a/configure.inFri Jul 16 09:46:38 2010 +0200 +++ b/configure.inThu Jul 22 21:47:41 2010 +0900 @@ -607,6 +607,7 @@ [new_libnet=yes; AC_DEFINE(HAVE_LIBNET_1_1_API, 1, Libnet 1.1 API)], [new_libnet=no; AC_DEFINE(HAVE_LIBNET_1_0_API, 1, Libnet 1.0 API)],$LIBNETLIBS) AC_SUBST(LIBNETLIBS) + AC_DEFINE(HAVE_LIBNET_API, 1, Libnet API) fi if test $new_libnet = yes; then @@ -634,7 +635,7 @@ dnl dnl * Check for netinet/icmp6.h to enable the IPv6addr resource agent AC_CHECK_HEADERS(netinet/icmp6.h,[],[],[#include sys/types.h]) -AM_CONDITIONAL(USE_IPV6ADDR, test $ac_cv_header_netinet_icmp6_h = yes -a $new_libnet = yes ) +AM_CONDITIONAL(USE_IPV6ADDR, test $ac_cv_header_netinet_icmp6_h = yes ) dnl dnl Compiler flags diff -r b3142fd9cc67 -r 40d5dbdca9cc heartbeat/IPv6addr.c --- a/heartbeat/IPv6addr.cFri Jul 16 09:46:38 2010 +0200 +++ b/heartbeat/IPv6addr.cThu Jul 22 21:47:41 2010 +0900 @@ -87,13 +87,25 @@ #include config.h +#include stdio.h #include stdlib.h +#include unistd.h #include sys/types.h +#include sys/socket.h #include netinet/icmp6.h +#include arpa/inet.h /* for inet_pton */ +#include net/if.h /* for if_nametoindex */ +#include sys/ioctl.h +#include sys/stat.h +#include fcntl.h #include libgen.h #include syslog.h +#include signal.h +#include errno.h #include clplumbing/cl_log.h +#ifdef HAVE_LIBNET_API #include libnet.h +#endif #define PIDFILE_BASE HA_RSCTMPDIR /IPv6addr- @@ -400,8 +412,11 @@ return OCF_NOT_RUNNING; } +#ifdef HAVE_LIBNET_API /* Send an unsolicited advertisement packet * Please refer to rfc2461 + * + * Libnet based implementation. */ int send_ua(struct in6_addr* src_ip, char* if_name) @@ -466,6 +481,108 @@ libnet_destroy(l); return status; } +#else /* HAVE_LIBNET_API */ +/* Send an unsolicited advertisement packet + * Please refer to rfc4861 / rfc3542 + * + * Libnet independent implementation. + */ +int +send_ua(struct in6_addr* src_ip, char* if_name) +{ + int status = -1; + int fd; + + int ifindex; + int hop; + struct ifreq ifr; +#define HWADDR_LEN 6 /* mac address length */ Personally I'd prefer the define outside of the function. + u_int8_t payload[sizeof(struct nd_neighbor_advert) + + sizeof(struct nd_opt_hdr) + HWADDR_LEN]; + struct nd_neighbor_advert *na; + struct nd_opt_hdr *opt; + struct sockaddr_in6 src_sin6; + struct sockaddr_in6 dst_sin6; + + if ((fd = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) == 0) { + cl_log(LOG_ERR, socket(IPPROTO_ICMPV6) failed: %s, +strerror(errno)); + goto err; + } + /* set the outgoing interface */ + ifindex = if_nametoindex(if_name); + if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF, +ifindex, sizeof(ifindex)) 0) { + cl_log(LOG_ERR, setsockopt(IPV6_MULTICAST_IF) failed: %s, +strerror(errno)); + goto err; + } + /* set the hop limit */ + hop = 255; /* 255 is required. see rfc4861 7.1.2 */ + if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, +hop, sizeof(hop)) 0) { + cl_log(LOG_ERR, setsockopt(IPV6_MULTICAST_HOPS) failed: %s, +strerror(errno)); + goto err; + } + + /* set the source address */ + memset(src_sin6, 0, sizeof(src_sin6)); +