OpenFastPath / ofp

OpenFastPath project
BSD 3-Clause "New" or "Revised" License
351 stars 126 forks source link

Question about default route setup #240

Open freak82 opened 4 years ago

freak82 commented 4 years ago

Hi there,

I'm researching the capabilities of the OpenFastPath stack. I hit a problem where my packets get dropped and found that my rule for default route doesn't work. The packets get dropped because ofp_get_next_hop can't find next hop when processing output packets. I'm able to reproduce and show my problem with the following simplified snippet:

        struct ofp_route_msg rtpars = {
                                       .type    = OFP_ROUTE_ADD,                
                                       .flags   = OFP_RTF_GATEWAY,
                                       .dst     = 0x00000000,        
                                       .masklen = 0,                            
                                       .gw      = 0x011E140A, // 10.20.30.1        
                                       .port    = 0,                            
                                       .vlan    = 0,                            
                                       .vrf     = 0,                            
                                       .dst6    = {},                          
                                       .gw6     = {}};                          
        ofp_set_route_msg(&rtpars);                                            
        usleep(1'000'000);                                                      
        ofp_show_routes(STDOUT_FILENO, OFP_SHOW_ROUTES);                                                                      
        uint32_t flags = 0;                                                    
        uint32_t addr  = 0x051E140A; // 10.20.30.5                              
        printf("Next hop %p for %s\n",                                          
               ofp_get_next_hop(rtpars.vrf, addr, &flags),                      
               ofp_print_ip_addr(addr));

This code prints:

Destination        Gateway         Iface  Flags
VRF: 0
0.0.0.0/0          10.20.30.1      fp0    net gateway
Next hop (nil) for 10.20.30.5   <----- Next hop is not found for this ip address

And just to make sure that the above snippet actually works. If I do this change in the above code

                                       .dst     = 0x001E140A, // 10.20.30.0    
                                       .masklen = 24,

then the code prints:

Destination        Gateway         Iface  Flags
VRF: 0
10.20.30.0/24      10.20.30.1      fp0    net gateway
Next hop 0x7f5e106e936c for 10.20.30.5    <----- Next hop is found

So, my question is: What I'm doing wrong and how can I setup default route for all packets?

Thanks, Pavel.

MatiasElo commented 4 years ago

You may get some useful info if you configure OFP with --enable-debug flag.