[ovs-dev] Packet marking in kernel

sougol gheissi sougol.gheissi at gmail.com
Sun Jul 22 14:20:44 UTC 2018


Hello,
I want to add a short piece of code to the OVS source code so that I can
mark the packet based on some meta data in the packet. I have add the
snippet code below to the /datapath/vport-netdev.c
void netdev_port_receive(struct sk_buff *skb, struct ip_tunnel_info
*tun_info){
    struct iphdr *ip_header = (struct iphdr *)skb_network_header(skb);
    struct udphdr *udp_header;
        if (ip_header->protocol == 17) //UDP protocol
        {
            udp_header = (struct udphdr *)((__u32 *)ip_header+
ip_header->ihl);
            if ((udp_header->dest == 50195)
            {
                mark = *setMark*((char*)udp_header,htons(ip_header->tot_len)-
20);
                if(mark != -1){
                    skb->mark = mark;
                }
            }
        }
}
which *setMark* is an function in the same file. Then I managed my
controller in floodlight to set the rules based on pkt_mark first time
these kind of packets come to the switch. After that I expect packets to be
routed based on that rules and not going to the controller anymore, however
some of them do not hit the rules related to them and go to the
controllers. I have to mention that I made the rules coming from the
controller to last forever. I have some questions here. As the packet do
not hit the rules associated to them, I concluded that the packets do not
get the marks. (Is it right?)
1. Is the vport-netdev.c the right place to add my snippet? Actually I mean
is it the first place I can mangle the packet in kernel?
2. If no, where should I add my snippet?


More information about the dev mailing list