LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Compiling tcng in ubuntu 8.04 (http://www.linuxquestions.org/questions/linux-software-2/compiling-tcng-in-ubuntu-8-04-a-670350/)

Primeiro 09-16-2008 05:30 PM

Compiling tcng in ubuntu 8.04
 
Hi,

I'm trying to compile tcng-10b (linux traffic control next generation) in ubuntu hardy. I'm getting the following errors. By looking at file ksvc.c I've noticed that errors occur whenever struct sk_buff is used. Any suggestions on how to fix this?

ksvc.c:28: warning: ‘struct sock’ declared inside parameter list
ksvc.c:28: warning: its scope is only this definition or declaration, which is probably not what you want
ksvc.c:46: warning: no previous prototype for ‘printk’
ksvc.c: In function ‘__kfree_skb’:
ksvc.c:70: error: dereferencing pointer to incomplete type
ksvc.c:71: error: dereferencing pointer to incomplete type
ksvc.c: In function ‘alloc_skb’:
ksvc.c:81: error: invalid application of ‘sizeof’ to incomplete type ‘struct sk_buff’
ksvc.c:82: error: dereferencing pointer to incomplete type
ksvc.c:83: error: dereferencing pointer to incomplete type
ksvc.c:83: error: dereferencing pointer to incomplete type
ksvc.c:83: error: dereferencing pointer to incomplete type
ksvc.c:83: error: dereferencing pointer to incomplete type
ksvc.c:84: error: dereferencing pointer to incomplete type
ksvc.c:88: error: dereferencing pointer to incomplete type
ksvc.c:89: error: dereferencing pointer to incomplete type
ksvc.c:89: error: invalid application of ‘sizeof’ to incomplete type ‘struct sk_buff’
ksvc.c:90: error: dereferencing pointer to incomplete type
ksvc.c:91: error: dereferencing pointer to incomplete type
ksvc.c:91: error: dereferencing pointer to incomplete type
ksvc.c: In function ‘rtnetlink_send’:
ksvc.c:150: error: dereferencing pointer to incomplete type

nadroj 09-16-2008 06:17 PM

use Synaptic to install this, unless you really need to compile from source. if the latter is true then you would need to post the code for us to look at, or send it to the developers of the tool if it is actually a bug (well, compilation error, not a bug).

Synaptic is in System->Administration. use the 'Search' button to find 'tcng'. you should be able to install it with GUI-only, no command line stuff.

Primeiro 09-16-2008 08:03 PM

I've successfully installed tcng from the ubuntu repos using synaptic. However I don't want to use the tcng in the ubuntu repos because it doesn't have tcsim (traffic control simulator).

The problem is not in the tool itself because I've installed it before in Feisty. Now that I've updated to Hardy I can't seem to get it compiled. I'm I missing a package?

The errors happen to be in the followin two functions:

void __kfree_skb(struct sk_buff *skb)
{
if (--skb->users) return;
free(skb->data);
...
}

...

struct sk_buff *alloc_skb(unsigned int size,int priority)
{
...

skb = alloc_t(struct sk_buff);
memset(skb,0,sizeof(*skb));
skb->data = skb->head = skb->tail = skb->end = alloc(size);
if (!skb->data) {
...
}
skb->users = 1;
skb->truesize = size+sizeof(struct sk_buff);
skb->end += size;
SKB_GEN(skb) = generation++;
...
}

nadroj 09-16-2008 08:23 PM

can you post the complete ksvc.c file. use the "code" tags to put the source code in.

Primeiro 09-16-2008 08:29 PM

Here it is:

Code:

/*
 * ksvc.c - Kernel services replacement for tcsim
 *
 * Written 2001,2002 by Werner Almesberger
 * Copyright 2001 EPFL-ICA, Network Robots
 * Copyright 2002 Werner Almesberger
 */


#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <sys/time.h> /* struct timeval for skbuff.h */

#define __TCSIM__
#include <linux/slab.h> /* for prototypes */
#include <linux/netdevice.h> /* for prototypes */

#include <memutil.h>

#include "tckernel.h"
#include "tcsim.h"


extern int netlink_unicast(struct sock *ssk,struct sk_buff *skb,u32 pid,
  int nonblock);

struct net_device *dev_base = NULL;


void *kmalloc(size_t size, int flags)
{
    return alloc(size);
}


void kfree(const void *ptr)
{
    free((void *) ptr);
}


int printk(const char *fmt,...)
{
    va_list ap;
    int res;

    if (fmt[0] == '<' && isdigit(fmt[1]) && fmt[2] == '>') {
        if (fmt[1]-'0' > printk_threshold) return 0; /* return more ? */
        fmt += 3;
    }
    else {
        /* KERN_WARNING, linux/kernel/printk.c:DEFAULT_MESSAGE_LOGLEVEL */
        if (4 > printk_threshold) return 0;
    }
    fflush(stdout);
    fprintf(stderr,"| ");
    va_start(ap,fmt);
    res = vfprintf(stderr,fmt,ap);
    va_end(ap);
    fflush(stderr);
    return res;
}


void __kfree_skb(struct sk_buff *skb)
{
    if (--skb->users) return;
    free(skb->data);
    free(skb);
}


struct sk_buff *alloc_skb(unsigned int size,int priority)
{
    static __u32 generation = 0; /* skb generation number */
    struct sk_buff *skb;

    skb = alloc_t(struct sk_buff);
    memset(skb,0,sizeof(*skb));
    skb->data = skb->head = skb->tail = skb->end = alloc(size);
    if (!skb->data) {
        perror("out of memory");
        exit(1);
    }
    skb->users = 1;
    skb->truesize = size+sizeof(struct sk_buff);
    skb->end += size;
    SKB_GEN(skb) = generation++;
    return skb;
}


void skb_over_panic(struct sk_buff *skb,int len,void *here);
    /* from linux/include/linux/skbuff.h */

void skb_over_panic(struct sk_buff *skb,int len,void *here)
{
    fflush(stdout);
    fprintf(stderr,"PANIC: skb %p, length %d\n",skb,len);
    abort();
}


int ___pskb_trim(struct sk_buff *skb, unsigned int len, int realloc);
    /* from linux/include/linux/skbuff.h */

int ___pskb_trim(struct sk_buff *skb, unsigned int len, int realloc)
{
    abort(); /* we shouldn't need this for now @@@ */
}


/*
 * From net/core/dev.c
 */


struct net_device *dev_get_by_index(int ifindex)
{
    struct net_device *dev;

    for (dev = dev_base; dev; dev = dev->next)
        if (dev->ifindex == ifindex) return dev;
    return NULL;
}


void dev_deactivate(struct net_device *dev)
{
    /* do nothing */
}


/*
 * From net/core/rtnetlink.c
 */


int pseudo_netlink_from_kernel(void *buf,int len)
{
    return netlink_recv(buf,len);
}


int rtnetlink_send(struct sk_buff *skb,__u32 pid,unsigned group,int echo)
{
    if (group) return skb->len;
    if (debug) debugf("rtnetlink_send to pid %u",pid);
//    NETLINK_CB(skb).dst_groups = group;
    return netlink_unicast(NULL,skb,pid,0);
}


int ffz(int v)
{
    return ffs(~v)-1;
}


/*
 * From net/core/utils.c
 */


static unsigned long net_rand_seed = 152L;


unsigned long net_random(void)
{
    net_rand_seed = net_rand_seed*69069L+1;
    return net_rand_seed;
}


/*
 * ll_name_to_index and ll_index_to_name ought to be in usvc.c, not ksvc.c.
 * Unfortunately, including netdevice.h there would cause problems, that's
 * why they're here.
 */


int ll_name_to_index(const char *name); /* in ulib */

int ll_name_to_index(const char *name)
{
    struct net_device *dev;

    for (dev = dev_base; dev; dev = dev->next)
        if (!strcmp(dev->name,name)) return dev->ifindex;
    return 0;
}


const char *ll_index_to_name(int idx); /* in ulib */

const char *ll_index_to_name(int idx)
{
    struct net_device *dev;

    for (dev = dev_base; dev; dev = dev->next)
        if (dev->ifindex == idx) return dev->name;
    return NULL;
}


extern void setup_netlink(void);
extern int pktsched_init(void);


int kernel_init(void)
{
    setup_netlink();
    return pktsched_init();
}


nadroj 09-16-2008 09:02 PM

is it just the above warnings and errors that you showed in post #1? or is there a larger list? did you read and follow the README for tcng exactly? (ie installed required libraries, etc)

Primeiro 09-16-2008 09:46 PM

Yes, those are all the errors I got. I followed all the steps in the README. I installed all the packages they mentioned there.

Primeiro 09-18-2008 08:57 AM

Fixed
 
The problem was the linux kernel (2.5.0) that I was using to compile tcsim. The kernels that compile are 2.4.27 and 2.5.4.

Thanks


All times are GMT -5. The time now is 05:14 AM.