Re: printk mac address --hangs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 13, 2010 at 9:49 PM, Jan Engelhardt <jengelh@xxxxxxxxxx> wrote:
> If you do not have an Ethernet packet, this is going to explode.

I have only one  ethernet network interface (eth0 ) with 192.168.1.5 .
I could see in wireshark all  packets with ethernet mac addresses .
When i try to prink the mac address or copy ,  it hangs ..

-Ratheesh


On Thu, May 13, 2010 at 9:49 PM, Jan Engelhardt <jengelh@xxxxxxxxxx> wrote:
>h
> On Thursday 2010-05-13 17:45, ratheesh k wrote:
>
>>Why this program cause kernel crash ? , If i comment out "memcpy " ,
>>it works fine
>>
>>/* This is the hook function itself */
>>unsigned int hook_func(unsigned int hooknum,
>>                       struct sk_buff *skb,
>>                       const struct net_device *in,
>>                       const struct net_device *out,
>>                       int (*okfn)(struct sk_buff *))
>>{
>>    struct iphdr* ip_header;
>>    struct tcphdr* tcp_header;
>>    struct ethhdr * eth_header ;
>>    char src[ETH_ALEN+2];
>>    char dst[ETH_ALEN+2];
>>      src[ETH_ALEN+1]='\0';
>>      dst[ETH_ALEN+1]='\0' ;
>>
>>     ip_header  = ip_hdr(skb);
>>    tcp_header = tcp_hdr(skb);
>>    eth_header = eth_hdr(skb);
>>
>>
>>      memcpy(src , eth_header->h_source , ETH_ALEN );
>>      memcpy(dst , eth_header->h_dest , ETH_ALEN );
>
> If you do not have an Ethernet packet, this is going to explode.
>
>
>>
>>    return NF_ACCEPT;           /* Drop ALL packets */
>>}
>>
>>/* Initialisation routine */
>>int init_module()
>                 ^ void
>
>>{
>>    /* Fill in our hook structure */
>>    nfho.hook = hook_func;         /* Handler function */
>>
>>    nfho.hooknum  = NF_IP_LOCAL_OUT; /* First hook for IPv4 */
>>
>>    nfho.pf       = PF_INET;
>>
>>    nfho.priority = NF_IP_PRI_FIRST;   /* Make our function first */
>>
>>    nf_register_hook(&nfho);
>>
>>    return 0;
>>}
>>
>>/* Cleanup routine */
>>void cleanup_module()
>                     ^ void
>
>>{
>>    nf_unregister_hook(&nfho);
>
--
To unsubscribe from this list: send the line "unsubscribe netfilter" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Netfilter Development]     [Linux Kernel Networking Development]     [Netem]     [Berkeley Packet Filter]     [Linux Kernel Development]     [Advanced Routing & Traffice Control]     [Bugtraq]

  Powered by Linux