Sorry For the last one..seems like hyperlinks got expanded :(<br><br>Hi Bjørn,<br><br><br><br>I have put some debug message in kernel...while compilation so that we get what the error is.<br><div class="gmail_quote"><div class="h5">

<br> <br>
In "net/packet/af_packet.c"<br><br>static int packet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)<br>{<br>        struct sockaddr_ll *sll = (struct sockaddr_ll*)uaddr;<br>        struct sock *sk=sock->sk;<br>

        struct net_device *dev = NULL;<br>        int err;<br><br>        /*<br>         *      Check legality<br>         */<br><br>        if (addr_len < sizeof(struct sockaddr_ll))<br>        {<br>                printk("packet_bind: invalid len %d %d\n", addr_len, sizeof(struct sockaddr_ll));<br>

                return -EINVAL;<br>        }<br>        if (sll->sll_family != AF_PACKET)<br>        {<br>                printk("packet_bind: invalid socket family %d %d\n", sll->sll_family,  AF_PACKET);<br>

                return -EINVAL;<br>        }<br>        if (sll->sll_ifindex) {<br>                err = -ENODEV;<br>                dev = dev_get_by_index(sock_net(sk), sll->sll_ifindex);<br>                if (dev == NULL)<br>

                        goto out;<br>        }<br><br><br>Got the output as<br><br>Internet Systems Consortium DHCP Server 4.2.2<br>Copyright 2004-2011 Internet Systems Consortium.<br>All rights reserved.<br>For info, please visit <a href="https://www.isc.org/software/dhcp/">https://www.isc.org/software/dhcp/</a><br>

Wrote 0 leases to leases file.<br>packet_bind: invalid len 16 20<br>socket: Error_2 (Bind to the interface name) Invalid argument , 22 16- make<br>sure<br>CONFIG_PACKET (Packet socket) and CONFIG_FILTER<br>(Socket Filtering) are enabled in your kernel<br>

configuration!<br><br>If you did not get this software from <a href="http://ftp.isc.org">ftp.isc.org</a>, please<br>get the latest from <a href="http://ftp.isc.org">ftp.isc.org</a> and install that before<br>requesting help.<br>

<br>If you did get this software from <a href="http://ftp.isc.org">ftp.isc.org</a> and have not<br>yet read the README, please read it before requesting help.<br>If you intend to request help from the dhcp-server at <a href="http://isc.org">isc.org</a><br>

mailing list, please read the section on the README about<br>submitting bug reports and requests for help.<br><br>Please do not under any circumstances send requests for<br>help directly to the authors of this software - please<br>

send them to the appropriate mailing list as described in<br>the README file.<br><br>exiting.<br><br><br>You can find this """packet_bind: invalid len 16 20 """<br><br>addr_len is 16 and size of sockaddr_ll is 20 hence its failing!!!!<br>

<br>Any pointers as to why its different? sizeof sa passed in bind is 16<br>whereas it has to be 20...<br><br><br>Regards,<br>Mukund<br><br>
<br><br><br><br><br><br><br><br><br><div class="gmail_quote">On Wed, Nov 30, 2011 at 3:00 PM, Bjørn Mork <span dir="ltr"><<a href="mailto:bjorn@mork.no" target="_blank">bjorn@mork.no</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Mukund Deshpande <<a href="mailto:sai.mukund.sagar@gmail.com" target="_blank">sai.mukund.sagar@gmail.com</a>> writes:<br>



<br>
> I added extra message for each of the cases where this error was occuring.<br>
> It has failed at bind call..<br>
<br>
</div>That's interesting.<br>
<div><br>
> Any suggestions how to find if there is any problem in ifindex detection?<br>
<br>
</div>I see now that I was a bit too quick as usual when thinking about what<br>
could fail, looking only briefly at the lines before the bind() call and<br>
assuming that the code must be correct on most systems.<br>
<br>
Looking at it more in detail, I now believe this code is utterly wrong<br>
on *any* system....<br>
<br>
Quoting from packet(7):<br>
<br>
</quote><br>
NAME<br>
       packet, AF_PACKET - packet interface on device level.<br>
<br>
SYNOPSIS<br>
       #include <sys/socket.h><br>
       #include <netpacket/packet.h><br>
       #include <net/ethernet.h> /* the L2 protocols */<br>
<br>
       packet_socket = socket(AF_PACKET, int socket_type, int protocol);<br>
<br>
DESCRIPTION<br>
       Packet sockets are used to receive or send raw packets at the device driver (OSI Layer 2) level.<br>
       They allow the user to implement protocol modules in user space on top of the physical layer.<br>
<br>
       The socket_type is either SOCK_RAW for raw packets including the link level header or SOCK_DGRAM<br>
       for  cooked  packets  with  the link level header removed.  The link level header information is<br>
       available in a common format in a sockaddr_ll.  protocol is the IEEE 802.3  protocol  number  in<br>
       network  order.   See the <linux/if_ether.h> include file for a list of allowed protocols.  When<br>
       protocol is set to htons(ETH_P_ALL) then all protocols are received.  All  incoming  packets  of<br>
       that  protocol  type will be passed to the packet socket before they are passed to the protocols<br>
       implemented in the kernel.<br>
<br>
       Only processes with effective UID 0 or the CAP_NET_RAW capability may open packet sockets.<br>
<br>
       SOCK_RAW packets are passed to and from the device driver without  any  changes  in  the  packet<br>
       data.  When receiving a packet, the address is still parsed and passed in a standard sockaddr_ll<br>
       address structure.  When transmitting a packet, the user  supplied  buffer  should  contain  the<br>
       physical  layer  header.   That  packet  is  then queued unmodified to the network driver of the<br>
       interface defined by the destination address.  Some device drivers  always  add  other  headers.<br>
       SOCK_RAW is similar to but not compatible with the obsolete AF_INET/SOCK_PACKET of Linux 2.0.<br>
<br>
       SOCK_DGRAM  operates  on  a  slightly  higher  level.  The physical header is removed before the<br>
       packet is passed to the user.  Packets sent through a SOCK_DGRAM packet socket  get  a  suitable<br>
       physical  layer  header  based  on the information in the sockaddr_ll destination address before<br>
       they are queued.<br>
<br>
       By default all packets of the specified protocol type are passed to a packet  socket.   To  only<br>
       get  packets from a specific interface use bind(2) specifying an address in a struct sockaddr_ll<br>
       to bind the packet socket to an interface.  Only the sll_protocol and  the  sll_ifindex  address<br>
       fields are used for purposes of binding.<br>
</quote><br>
<br>
<br>
So you can't really do socket(PF_PACKET, SOCK_PACKET, ...) and expect it<br>
to work.  And the bind() may be correct for the obsolete SOCK_PACKET<br>
sockets, but I don't think it will work correctly with AF_PACKET<br>
sockets. They need to have sll_protocol and sll_ifindex set, and not the<br>
ifreq structure in info->ifp.<br>
<br>
I have a feeling I must be missing something here, as this code<br>
obviously does work for most of us.  Maybe the bind() call does in fact<br>
work, but the interface name in info->ifp is wrong somehow?<br>
<br>
Maybe someone else has a comment?<br>
<div><div><br>
<br>
<br>
Bjørn<br>
_______________________________________________<br>
dhcp-users mailing list<br>
<a href="mailto:dhcp-users@lists.isc.org" target="_blank">dhcp-users@lists.isc.org</a><br>
<a href="https://lists.isc.org/mailman/listinfo/dhcp-users" target="_blank">https://lists.isc.org/mailman/listinfo/dhcp-users</a></div></div></blockquote></div><br><br clear="all"><br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<br><span class="HOEnZb"><font color="#888888">-- <br>Regards,<div>Mukund</div><br>

</font></span></blockquote></div><br><br clear="all"><br>-- <br>Regards,<div>Mukund</div><br>