pass by value not supported XDP

210 Views Asked by At

I am creating a function to loop through some loops and try to match a set. It is supposed to work fine, but unfortunately, it is not. I get a "pass by value not supported" error. How can I fix this?

    int matchSet(Program p, int match[], int action)
    {
    int matchState = 0;
    int match[4] = {3,4,5,6}; //set as example
    int p.set[10] = {2,1,3,4,5,6,9,10,11,12}; //set as example (normal p.set)

    for (int i = 0; i < 10; i++)
        {
            if (matchState != 2)
            {
                if (p.set[i] == match[0] && p.set[i + 1] == match[1])
                {
                    matchState = 0;
                    for (int j = 0; j <= 4; j++)
                    {
                        bpf_printk("test");
                        if (matchState == 0)
                        {
                            bpf_printk("test3");
                            if (p.set[i] != match[j])
                            {
                                bpf_printk("test4");
                                matchState = 1;
                                break;
                            }
                        }
                    }
                    if (matchState == 0)
                    {
                        bpf_printk("test6");
                        matchState = 2;
                    }
                }
            }
    }

    if(matchState == 2) {
        return action;
    }
}

I call the function by:

Program p;
.....
int set[10] = {2,1,3,4,5,6,9,10,11,12};
p.set = set;
int match[4] = {3,4,5,6};
matchSet(p, match, 1);

Error:

error: pass by value not supported 0x1aca7c8: i64 = GlobalAddress<i32 (%struct.Program*, i8*, i32)* @matchSet> 0
1

There are 1 best solutions below

1
On

You need to change your function to take a pointer to a Program like so:

int matchSet(Program *p, int match[], int action){
...

And then also change your callsite:

Program p;
matchSet(&p, match, 1);