[quagga-dev 8485] Re: Query regarding zapi_ipv4_route(ZEBRA_IPV4_ROUTE_DELETE, .. , .. , .. )

Balaji G balajig81 at gmail.com
Thu Jan 27 03:18:38 GMT 2011


Hi Subin

I had  a very superficial look @ the code but couldnt find something
immediately, the best way to do this would be to check whether the ZServ
daemon gets the message Delete message and whether its able to find the
route node based on the prefix. If yes then you need to find out whats the
reason for the failure. If the route entry/node is not found, you ll have
this kind of problem. I guess this should solve the problem. Let me know

Cheers,
  - Balaji

On Tue, Jan 25, 2011 at 8:16 PM, subin manoj <subinmanoj at gmail.com> wrote:

> Hello Quagga Team,
>
> I am creating a daemon which tries to add and delete routes from the
> Zebra/Quagga daemon. I have follwed the process thats used in other daemons
> like RIP, OSPF to make my daemon. But now I am facing an issue in which I am
> able to add routes to the zebra daemon using the
> zapi_ipv4_route(ZEBRA_IPV4_ROUTE_ADD, .. , .. , .. ) but I am not able to
> delete the route using the zapi_ipv4_route(ZEBRA_IPV4_ROUTE_DELETE, .. , ..
> , .. ) function. Please find the extract of the code below. I have also
> attached the code. I tried many ways but still unclear of the issue. It
> would be really helpful if you can give me any pointers to solve this issue.
> Thanks.
>
> int my_ip_addr_delete(struct zclient *zclient) {
>     my_ip_addr_modify(zclient, ZEBRA_IPV4_ROUTE_DELETE);
> }
>
> int my_ip_addr_add(struct zclient *zclient) {
>     my_ip_addr_modify(zclient, ZEBRA_IPV4_ROUTE_ADD);
> }
>
> /*
> here I am trying to add/ delete 10.34.45.56/8 with gateway 10.3.4.5 based
> on
> ZEBRA_IPV4_ROUTE_ADD and ZEBRA_IPV4_ROUTE_DELETE
> */
> int my_ip_addr_modify(struct zclient *zclient, int operation) {
>
>     struct zapi_ipv4 zr;
>     struct prefix_ipv4 p;
>     struct in_addr newly_added_address;
>     struct in_addr newly_added_nexthop_address;
>     struct in_addr *ptr_newly_added_nexthop_address;
>     unsigned int ifindex_value;
>     int ret;
>
>     memset((void*) &zr, 0, sizeof(zr));
>     memset((void*) &p, 0, sizeof(p));
>
>     p.family = AF_INET;
>     p.prefixlen = 8;
>     inet_pton(AF_INET, "10.34.45.56", &newly_added_address);
>     inet_pton(AF_INET, "10.3.4.5", &newly_added_nexthop_address);
>
>     p.prefix = newly_added_address;
>     zr.type = ZEBRA_ROUTE_STATIC;
>     zr.flags = 0;
>     SET_FLAG (zr.message, ZAPI_MESSAGE_NEXTHOP);
>     zr.nexthop_num = 1;
>     ptr_newly_added_nexthop_address = &newly_added_nexthop_address;
>
>     ret = zapi_ipv4_route(operation, zclient, &p, &zr);
>     printf("Return val from %s is: %d \n",
>             operation == ZEBRA_IPV4_ROUTE_ADD ? "ZEBRA_IPV4_ROUTE_ADD"
>                     : "ZEBRA_IPV4_ROUTE_DELETE", ret);
>     printf("Return val %d \n", ret);
>     return 0;
> }
>
> void my_init() {
>     int i;
>     int ret_client_start;
>     struct interface *ifp;
>
>     /* Set default value to the zebra client structure. */
>     zclient = zclient_new();
>     zclient_init(zclient, ZEBRA_ROUTE_MY);
>     /*
>      * ret_client_start = zclient_start(zclient);
>      *
>      */
>
>     /*    for (i = 0; i++ < ZEBRA_ROUTE_MAX;)
>      if (i != ZEBRA_ROUTE_MY)
>      zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, i);
> */
>
>     /* zclient->ipv4_route_add = my_ip_addr_add;
>     zclient->ipv4_route_delete = my_ip_addr_delete; */
>
>     // Here I try to add and delete the route
>     my_ip_addr_add(zclient);
>     my_ip_addr_delete(zclient);
>
> }
>
> *Regards,*
> *Subin*
>
>
> _______________________________________________
> Quagga-dev mailing list
> Quagga-dev at lists.quagga.net
> http://lists.quagga.net/mailman/listinfo/quagga-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.quagga.net/pipermail/quagga-dev/attachments/20110127/b9c42e9f/attachment-0001.html>


More information about the Quagga-dev mailing list