Hello Edward, On Fri, Jan 15, 2010 at 2:34 PM, Edward Welbourne <eddy@xxxxxxxxx> wrote: > In man 3 rtnetlink, the example code includes the lines: > > rta = (struct rtattr *)(((char *) &req) + > NLMSG_ALIGN(n->nlmsg_len)); > > in which the variable "n" is nowhere declared. It seems likely that > NLMSG_ALIGN(req.nh.nlmsg_len) was intended, albeit I am so deeply > ignorant of relevant systems that I am learning about them by reading > man pages, so I may easilly be wrong ... My guess is that your interpretation is correct, and indeed there are a few other pieces that look to need similar fixes. I've applied the patch below, and CCed Andi, who may be offer further input/confirmation. > I am also acutely aware of the bug already noted on the man page, but > you clearly already know about that one ! Yup. Cheers, Michael --- a/man3/rtnetlink.3 +++ b/man3/rtnetlink.3 @@ -84,6 +84,9 @@ This manual page is incomplete. Creating a rtnetlink message to set the MTU of a device: .nf + #include <linux/rtnetlink.h> + + ... struct { struct nlmsghdr nh; @@ -99,18 +102,18 @@ Creating a rtnetlink message to set the MTU of a device: memset(&req, 0, sizeof(req)); req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)); req.nh.nlmsg_flags = NLM_F_REQUEST; - req.nh.nlmsg_type = RTML_NEWLINK; + req.nh.nlmsg_type = RTM_NEWLINK; req.if.ifi_family = AF_UNSPEC; req.if.ifi_index = INTERFACE_INDEX; req.if.ifi_change = 0xffffffff; /* ???*/ rta = (struct rtattr *)(((char *) &req) + - NLMSG_ALIGN(n\->nlmsg_len)); + NLMSG_ALIGN(req.nh.nlmsg_len)); rta\->rta_type = IFLA_MTU; rta\->rta_len = sizeof(unsigned int); - req.n.nlmsg_len = NLMSG_ALIGN(req.n.nlmsg_len) + + req.n.nlmsg_len = NLMSG_ALIGN(req.nh.nlmsg_len) + RTA_LENGTH(sizeof(mtu)); memcpy(RTA_DATA(rta), &mtu, sizeof(mtu)); - send(rtnetlink_sk, &req, req.n.nlmsg_len); + send(rtnetlink_sk, &req, req.nh.nlmsg_len); .fi .SH "SEE ALSO" .BR netlink (3), -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html