CONFIG_FILTER error on arm

Mukund Deshpande sai.mukund.sagar at gmail.com
Wed Nov 30 13:21:43 UTC 2011


Hi Bjørn,


I have put some debug message in kernel...while compilation so that we get
what the error is.

1752 <http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1752>static
int packet_bind <http://lxr.linux.no/linux+*/+code=packet_bind>(struct
socket <http://lxr.linux.no/linux+*/+code=socket> *sock
<http://lxr.linux.no/linux+*/+code=sock>, struct sockaddr
<http://lxr.linux.no/linux+*/+code=sockaddr> *uaddr
<http://lxr.linux.no/linux+*/+code=uaddr>, int addr_len
<http://lxr.linux.no/linux+*/+code=addr_len>)1753
<http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1753>{1754
<http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1754>
struct sockaddr_ll <http://lxr.linux.no/linux+*/+code=sockaddr_ll>
*sll <http://lxr.linux.no/linux+*/+code=sll> = (struct sockaddr_ll
<http://lxr.linux.no/linux+*/+code=sockaddr_ll> *)uaddr
<http://lxr.linux.no/linux+*/+code=uaddr>;1755
<http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1755>
struct sock <http://lxr.linux.no/linux+*/+code=sock> *sk
<http://lxr.linux.no/linux+*/+code=sk> = sock
<http://lxr.linux.no/linux+*/+code=sock>->sk
<http://lxr.linux.no/linux+*/+code=sk>;1756
<http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1756>
struct net_device <http://lxr.linux.no/linux+*/+code=net_device> *dev
<http://lxr.linux.no/linux+*/+code=dev> = NULL
<http://lxr.linux.no/linux+*/+code=NULL>;1757
<http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1757>        int
err <http://lxr.linux.no/linux+*/+code=err>;1758
<http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1758>1759
<http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1759>1760
<http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1760>
/*1761 <http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1761>
   *      Check legality1762
<http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1762>
*/1763 <http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1763>1764
<http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1764>        if
(addr_len <http://lxr.linux.no/linux+*/+code=addr_len> < sizeof(struct
sockaddr_ll <http://lxr.linux.no/linux+*/+code=sockaddr_ll>))

              {
                   printk("packet_bind: invalid len %d %d\n",
addr_len, sizeof(struct sockaddr_ll));
                     ///ADDED THIS PRINTK IN LINUX CODE
1765 <http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1765>
       return -EINVAL <http://lxr.linux.no/linux+*/+code=EINVAL>;

              }
 1766 <http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1766>
 if (sll <http://lxr.linux.no/linux+*/+code=sll>->sll_family
<http://lxr.linux.no/linux+*/+code=sll_family> != AF_PACKET
<http://lxr.linux.no/linux+*/+code=AF_PACKET>)

               {
                     printk("packet_bind: invalid socket family %d
%d\n", sll->sll_family,  AF_PACKET);
                   ///ADDED THIS PRINTK IN LINUX CODE
 1767 <http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1767>
         return -EINVAL <http://lxr.linux.no/linux+*/+code=EINVAL>;

               }

1768 <http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1768>1769
<http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1769>        if
(sll <http://lxr.linux.no/linux+*/+code=sll>->sll_ifindex
<http://lxr.linux.no/linux+*/+code=sll_ifindex>) {1770
<http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1770>
   err <http://lxr.linux.no/linux+*/+code=err> = -ENODEV
<http://lxr.linux.no/linux+*/+code=ENODEV>;1771
<http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1771>
   dev <http://lxr.linux.no/linux+*/+code=dev> = dev_get_by_index
<http://lxr.linux.no/linux+*/+code=dev_get_by_index>(sock_net
<http://lxr.linux.no/linux+*/+code=sock_net>(sk
<http://lxr.linux.no/linux+*/+code=sk>), sll
<http://lxr.linux.no/linux+*/+code=sll>->sll_ifindex
<http://lxr.linux.no/linux+*/+code=sll_ifindex>);1772
<http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1772>
   if (dev <http://lxr.linux.no/linux+*/+code=dev> == NULL
<http://lxr.linux.no/linux+*/+code=NULL>)1773
<http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1773>
           goto out <http://lxr.linux.no/linux+*/+code=out>;1774
<http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1774>
}1775 <http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1775>
 err <http://lxr.linux.no/linux+*/+code=err> = packet_do_bind
<http://lxr.linux.no/linux+*/+code=packet_do_bind>(sk
<http://lxr.linux.no/linux+*/+code=sk>, dev
<http://lxr.linux.no/linux+*/+code=dev>, sll
<http://lxr.linux.no/linux+*/+code=sll>->sll_protocol
<http://lxr.linux.no/linux+*/+code=sll_protocol> ? : pkt_sk
<http://lxr.linux.no/linux+*/+code=pkt_sk>(sk
<http://lxr.linux.no/linux+*/+code=sk>)->num
<http://lxr.linux.no/linux+*/+code=num>);1776
<http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1776>1777
<http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1777>out
<http://lxr.linux.no/linux+*/+code=out>:1778
<http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1778>
return err <http://lxr.linux.no/linux+*/+code=err>;1779
<http://lxr.linux.no/linux+*/net/packet/af_packet.c#L1779>}




Got the output as

Internet Systems Consortium DHCP Server 4.2.2
Copyright 2004-2011 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Wrote 0 leases to leases file.
packet_bind: invalid len 16 20
socket: Error_2 (Bind to the interface name) Invalid argument , 22 16- make
sure
CONFIG_PACKET (Packet socket) and CONFIG_FILTER
(Socket Filtering) are enabled in your kernel
configuration!

If you did not get this software from ftp.isc.org, please
get the latest from ftp.isc.org and install that before
requesting help.

If you did get this software from ftp.isc.org and have not
yet read the README, please read it before requesting help.
If you intend to request help from the dhcp-server at isc.org
mailing list, please read the section on the README about
submitting bug reports and requests for help.

Please do not under any circumstances send requests for
help directly to the authors of this software - please
send them to the appropriate mailing list as described in
the README file.

exiting.


You can find this """packet_bind: invalid len 16 20 """

addr_len is 16 and size of sockaddr_ll is 20 hence its failing!!!!

Any pointers as to why its different? sizeof sa passed in bind is 16
whereas it has to be 20...


Regards,
Mukund



On Wed, Nov 30, 2011 at 3:00 PM, Bjørn Mork <bjorn at mork.no> wrote:

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



-- 
Regards,
Mukund
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.isc.org/pipermail/dhcp-users/attachments/20111130/d3d3862a/attachment.html>


More information about the dhcp-users mailing list