tNetTask consumed a CPU - VxWorks

This is a discussion on tNetTask consumed a CPU - VxWorks ; Hi VxWorks users We have a system that has been run for a number of years and just a few months ago, We notice abnormal behavior : The system from time to time (rough estimation once in a two days) ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: tNetTask consumed a CPU

  1. tNetTask consumed a CPU

    Hi VxWorks users
    We have a system that has been run for a number of years and just a few
    months ago,
    We notice abnormal behavior : The system from time to time (rough
    estimation once in a two days) working slowly. Our investigation shown
    that the tNetTask consume a CPU like a "pig".
    We measured that the tNetTask consume about up to 5 second continuity,
    we checked it by small routine that "plug" to the "switch hook"
    function.
    Some more info - we are running on Motorola 860. The VxWorks version
    - 5.3.1
    Has anyone seen this problem or behavior before ? Or Any idea ?

    Thanks in advance,
    Ben


  2. Re: tNetTask consumed a CPU

    Hi:

    Sounds like you are getting a lot of net traffic when the load goes up
    like that. Maybe a DOS attack?

    I'd try to look at the traffic with either the "stat" functions in the
    shell or use the ethernet driver hooks to measure traffic averages more
    precisely.
    Ethereal might also be useful.

    Good luck.

    LC

    === cut here for vxsniff.c ===
    *
    * quick and dirty ethernet sniffer for vxworks
    */


    #include "vxWorks.h"
    #include "sys/types.h"
    #include "ioLib.h"
    #include "iosLib.h"
    #include "fioLib.h"
    #include "stdio.h"
    #include "unistd.h"
    #include "string.h"
    #include "usrLib.h"
    #include "errnoLib.h"
    #include "hostLib.h"
    #include "sockLib.h"
    #include "socket.h"
    #include "inetLib.h"
    #include "in.h"
    #include "selectLib.h"
    #include "taskLib.h"
    #include "dosFsLib.h"
    #include "etherLib.h"
    #include "net/mbuf.h"
    #include "net/domain.h"
    #include "tickLib.h"
    #include "net/protosw.h"
    #include "socket.h"
    #include "errno.h"
    #include "net/if.h"
    #include "net/route.h"
    #include "in.h"
    #include "netinet/in_pcb.h"
    #include "netinet/in_systm.h"
    #include "netinet/in_var.h"
    #include "netinet/ip.h"
    #include "netinet/ip_var.h"
    #include "netinet/ip_icmp.h"
    #include "netinet/udp.h"
    #include "netinet/tcp.h"
    #include "netinet/if_ether.h"
    #include "net/systm.h"
    #include "inetLib.h"


    char vxSniffLog[200][200];
    int vxSniffLogIdx= 0;


    STATUS
    vxSniffHook(struct ifnet *ifp, char *buf, int len)
    {
    struct ip *ip;
    struct udphdr *udp;
    struct tcphdr *tcp;
    unsigned long ticks;
    char *proto;
    int optlen;
    char srcAddr[20], dstAddr[20];
    char protoxxx[10];


    ip = (struct ip *)(buf + 14);
    inet_ntoa_b(ip->ip_src, srcAddr);
    inet_ntoa_b(ip->ip_dst, dstAddr);
    switch (ip->ip_p) {
    case IPPROTO_TCP:
    proto = "TCP";
    break;
    case IPPROTO_UDP:
    proto = "UDP";
    break;
    case IPPROTO_ICMP:
    proto = "ICMP";
    break;
    default:
    sprintf(protoxxx, "?0x%x", ip->ip_p);
    proto = protoxxx;
    break;
    }


    ticks = tickGet ();


    sprintf(vxSniffLog[vxSniffLogIdx++],
    "0x%x:IP(p:%s,v:%d,h:%d,l:%d) %s -> %s\n",
    ticks,
    proto,
    (ip->ip_v_hl>>4)&0xf,
    (ip->ip_v_hl & 0xf)<<2, ip->ip_len,
    srcAddr, dstAddr);


    if (vxSniffLogIdx == 200)
    vxSniffLogIdx = 0;


    optlen = ((ip->ip_v_hl & 0xf)<<2) - sizeof( struct ip );
    if (ip->ip_p == IPPROTO_UDP) {
    udp = (struct udphdr *)((char *)(ip + 1) + optlen);
    sprintf(vxSniffLog[vxSniffLogIdx++],
    " UDP(s:%d,d:%d,l:%d)\n",
    udp->uh_sport, udp->uh_dport,
    udp->uh_ulen);
    } else if (ip->ip_p == IPPROTO_TCP) {
    tcp = (struct tcphdr *)((char *)(ip + 1) + optlen);
    sprintf(vxSniffLog[vxSniffLogIdx++],
    " TCP(s:%d,d:%d,q:%d,a:%d,f:0x%x,w:%d)\n",
    tcp->th_sport, tcp->th_dport,
    tcp->th_seq, tcp->th_ack, tcp->th_flags,
    tcp->th_win);
    }


    if (vxSniffLogIdx == 200)
    vxSniffLogIdx = 0;


    return FALSE;



    }


    int vxSniffStartIdx = 0;

    void
    vxSniffStart()
    {
    vxSniffStartIdx = vxSniffLogIdx;



    }


    void
    vxSniffShow()
    {
    int end = vxSniffLogIdx;
    int i;

    if (end < vxSniffStartIdx) {
    for (i = vxSniffStartIdx; i < 200; i++)
    printf("%s", vxSniffLog[i]);
    for (i = 0; i < end; i++)
    printf("%s", vxSniffLog[i]);
    } else {
    for (i = vxSniffStartIdx; i < end; i++)
    printf("%s", vxSniffLog[i]);
    }



    }


    #define SYNC __asm__(" sync")
    #define PSMR1(base) ((volatile UINT32*)(base + 0x0A08))
    void
    vxSniffInit()
    {
    /* XXX do something here to put ethernet driver in promiscuous mode */


    *(PSMR1(vxImmrGet())) |= (1 << 6); SYNC;


    etherInputHookAdd(vxSniffHook);



    }


  3. Re: tNetTask consumed a CPU


    LarryC wrote:
    > Hi:
    >
    > Sounds like you are getting a lot of net traffic when the load goes up
    > like that. Maybe a DOS attack?
    >
    > I'd try to look at the traffic with either the "stat" functions in the
    > shell or use the ethernet driver hooks to measure traffic averages more
    > precisely.
    > Ethereal might also be useful.
    >
    > Good luck.
    >
    > LC
    >
    > === cut here for vxsniff.c ===
    > *
    > * quick and dirty ethernet sniffer for vxworks
    > */
    >
    >
    > #include "vxWorks.h"
    > #include "sys/types.h"
    > #include "ioLib.h"
    > #include "iosLib.h"
    > #include "fioLib.h"
    > #include "stdio.h"
    > #include "unistd.h"
    > #include "string.h"
    > #include "usrLib.h"
    > #include "errnoLib.h"
    > #include "hostLib.h"
    > #include "sockLib.h"
    > #include "socket.h"
    > #include "inetLib.h"
    > #include "in.h"
    > #include "selectLib.h"
    > #include "taskLib.h"
    > #include "dosFsLib.h"
    > #include "etherLib.h"
    > #include "net/mbuf.h"
    > #include "net/domain.h"
    > #include "tickLib.h"
    > #include "net/protosw.h"
    > #include "socket.h"
    > #include "errno.h"
    > #include "net/if.h"
    > #include "net/route.h"
    > #include "in.h"
    > #include "netinet/in_pcb.h"
    > #include "netinet/in_systm.h"
    > #include "netinet/in_var.h"
    > #include "netinet/ip.h"
    > #include "netinet/ip_var.h"
    > #include "netinet/ip_icmp.h"
    > #include "netinet/udp.h"
    > #include "netinet/tcp.h"
    > #include "netinet/if_ether.h"
    > #include "net/systm.h"
    > #include "inetLib.h"
    >
    >
    > char vxSniffLog[200][200];
    > int vxSniffLogIdx= 0;
    >
    >
    > STATUS
    > vxSniffHook(struct ifnet *ifp, char *buf, int len)
    > {
    > struct ip *ip;
    > struct udphdr *udp;
    > struct tcphdr *tcp;
    > unsigned long ticks;
    > char *proto;
    > int optlen;
    > char srcAddr[20], dstAddr[20];
    > char protoxxx[10];
    >
    >
    > ip = (struct ip *)(buf + 14);
    > inet_ntoa_b(ip->ip_src, srcAddr);
    > inet_ntoa_b(ip->ip_dst, dstAddr);
    > switch (ip->ip_p) {
    > case IPPROTO_TCP:
    > proto = "TCP";
    > break;
    > case IPPROTO_UDP:
    > proto = "UDP";
    > break;
    > case IPPROTO_ICMP:
    > proto = "ICMP";
    > break;
    > default:
    > sprintf(protoxxx, "?0x%x", ip->ip_p);
    > proto = protoxxx;
    > break;
    > }
    >
    >
    > ticks = tickGet ();
    >
    >
    > sprintf(vxSniffLog[vxSniffLogIdx++],
    > "0x%x:IP(p:%s,v:%d,h:%d,l:%d) %s -> %s\n",
    > ticks,
    > proto,
    > (ip->ip_v_hl>>4)&0xf,
    > (ip->ip_v_hl & 0xf)<<2, ip->ip_len,
    > srcAddr, dstAddr);
    >
    >
    > if (vxSniffLogIdx == 200)
    > vxSniffLogIdx = 0;
    >
    >
    > optlen = ((ip->ip_v_hl & 0xf)<<2) - sizeof( struct ip );
    > if (ip->ip_p == IPPROTO_UDP) {
    > udp = (struct udphdr *)((char *)(ip + 1) + optlen);
    > sprintf(vxSniffLog[vxSniffLogIdx++],
    > " UDP(s:%d,d:%d,l:%d)\n",
    > udp->uh_sport, udp->uh_dport,
    > udp->uh_ulen);
    > } else if (ip->ip_p == IPPROTO_TCP) {
    > tcp = (struct tcphdr *)((char *)(ip + 1) + optlen);
    > sprintf(vxSniffLog[vxSniffLogIdx++],
    > " TCP(s:%d,d:%d,q:%d,a:%d,f:0x%x,w:%d)\n",
    > tcp->th_sport, tcp->th_dport,
    > tcp->th_seq, tcp->th_ack, tcp->th_flags,
    > tcp->th_win);
    > }
    >
    >
    > if (vxSniffLogIdx == 200)
    > vxSniffLogIdx = 0;
    >
    >
    > return FALSE;
    >
    >
    >
    > }
    >
    >
    > int vxSniffStartIdx = 0;
    >
    > void
    > vxSniffStart()
    > {
    > vxSniffStartIdx = vxSniffLogIdx;
    >
    >
    >
    > }
    >
    >
    > void
    > vxSniffShow()
    > {
    > int end = vxSniffLogIdx;
    > int i;
    >
    > if (end < vxSniffStartIdx) {
    > for (i = vxSniffStartIdx; i < 200; i++)
    > printf("%s", vxSniffLog[i]);
    > for (i = 0; i < end; i++)
    > printf("%s", vxSniffLog[i]);
    > } else {
    > for (i = vxSniffStartIdx; i < end; i++)
    > printf("%s", vxSniffLog[i]);
    > }
    >
    >
    >
    > }
    >
    >
    > #define SYNC __asm__(" sync")
    > #define PSMR1(base) ((volatile UINT32*)(base + 0x0A08))
    > void
    > vxSniffInit()
    > {
    > /* XXX do something here to put ethernet driver in promiscuous mode */
    >
    >
    > *(PSMR1(vxImmrGet())) |= (1 << 6); SYNC;
    >
    >
    > etherInputHookAdd(vxSniffHook);
    >
    >
    >
    > }


    Hi Larry
    Thanks a lot for your reply.
    But as it seems there isn't evidence for DOS attack or abnormal
    behavior over the net
    it looks like the nnettask is busy with something else. The problem is
    : How I can know where the nettask "spend time" (I can't use
    "tt" command).

    Thanks
    Ben


+ Reply to Thread