Giter Site home page Giter Site logo

Comments (3)

calvin2021y avatar calvin2021y commented on August 19, 2024

try with:

./nl-route-add --scope=link --protocol=kernel --dst=10.0.0.0/24 --nexthop=dev=eth101,via=10.0.0.1
Error: Unable to add route: Unspecific failure

 ./nl-route-add --scope=link --protocol=kernel --dst=10.0.0.0/24 --src=10.0.0.3  --nexthop=dev=eth101,via=10.0.0.1
Error: Unable to set source address: Source based routing not supported

./nl-route-add --iif=eth101 --scope=link --protocol=kernel --dst=10.0.0.0/24 --src=10.0.0.3
Error: Unable to set source address: Source based routing not supported

change --src into --pref-src get Unspecific failure

from libnl.

calvin2021y avatar calvin2021y commented on August 19, 2024

rtnl_route_add return error No such device, but the route is add into system.

from libnl.

calvin2021y avatar calvin2021y commented on August 19, 2024

I adjust some order and it get fixed.

		errn0 = nl_addr_parse(subnet, family, &dst_addr);
		if( dst_addr == NULL ) {
			break;
		}
		errn0	= rtnl_route_set_dst(route, dst_addr);
		if( errn0 < 0 ) {
			break;
		}

		errn0 = nl_addr_parse(ip, family, &src_addr);
		if( src_addr == NULL ) {
			break;
		}
		errn0	= rtnl_route_set_family(route, family);
		if( errn0 < 0 ) {
			break;
		}
		errn0	= rtnl_route_set_pref_src(route, src_addr);
		if( errn0 < 0 ) {
			break;
		}
		struct rtnl_nexthop *nh = rtnl_route_nh_alloc();
		if( nh == NULL ) {
			break;
		}
		errn0 = rtnl_route_nh_set_newdst(nh, dst_addr);
		if( errn0 < 0 ) {
			break;
		}
		rtnl_route_nh_set_ifindex(nh, ifindex);
		rtnl_route_add_nexthop(route, nh);
		errn0	= rtnl_route_set_family(route, family);
		if( errn0 < 0 ) {
			break;
		}
		rtnl_route_set_priority(route, RTN_UNSPEC);
		rtnl_route_set_protocol(route, RTPROT_KERNEL);
		rtnl_route_set_scope(route, RT_SCOPE_LINK);
		rtnl_route_set_table(route, RT_TABLE_MAIN);
		rtnl_route_set_iif(route, ifindex);
		errn0	= rtnl_route_add(sock, route, NLM_F_CREATE | NLM_F_REPLACE);
		if( errn0 < 0 ) {
			break;
		}
		line	= 0;

from libnl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.