summaryrefslogtreecommitdiffhomepage
path: root/interface-ip.c
AgeCommit message (Collapse)Author
2020-10-22interface: proto_ip: order by address index firstYousong Zhou
At the moment, dnsmasq initscript generates dhcp-range for an interface by inspecting first address of that interface from netifd ubus output. Order by address index as specified in the uci config makes netifd ubus output consistent with linux network interfaces' primary/secondary address settings. More importantly, the ubus output and dnsmasq config generation will be more predictable. Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com> Acked-by: Hans Dedecker <dedeckeh@gmail.com>
2020-08-10interface-ip: clear host bits of the device prefixHans Dedecker
Clear the host bits of the device prefix in interface_ip_add_device_prefix as interface_set_prefix_address just ORs the calculated assignment part which would lead to an invalid IPv6 address if the host bits are not masked out Suggested-by: Daniel Gröber <dxld@darkboxed.org> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2020-06-04interface-ip: fix build on non-linux systemsFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-02-05interface-ip: transfer prefix route ownership for deprecated ipv6addr to kernelAlin Nastac
When netifd manages the prefix route directly, it will remove it the moment prefix gets deprecated. This will make it impossible for the target to send ICMPv6 errors back to LAN devices still using the deprecated prefix, thus breaking the L-14 requirement of RFC 7084. Signed-off-by: Alin Nastac <alin.nastac@gmail.com>
2020-01-18add basic support for jail network namespacesDaniel Golle
Prepare netifd for handling procd service jails having their own network namespace. Intefaces having the jail attribute will only be brought inside the jail's network namespace by procd calling the newly introduced ubus method 'netns_updown'. Currently proto 'static' is supported and configuration changes are not yet being handled (ie. you'll have to restart the jailed service for changes to take effect). Example /etc/config/network snippet: config device 'veth0' option type 'veth' option name 'vhost0' option peer_name 'virt0' config interface 'virt' option type 'bridge' list ifname 'vhost0' option proto 'static' option ipaddr '10.0.0.1' option netmask '255.255.255.0' config interface 'virt0' option ifname 'virt0' option proto 'static' option ipaddr '10.0.0.2' option netmask '255.255.255.0' option gateway '10.0.0.1' option dns '10.0.0.1' option jail 'transmission' Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2019-06-13interface-ip: fix possible null pointer dereferenceHans Dedecker
Reported by Coverity in CID 1445749 Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-05-17interface-ip: use ptp address as well to find local address targetHans Dedecker
In case of tunnel over PPP(such as gretap over l2tp): tunnel interface use PPP's peer address as remote address, netifd script will call proto_add_host_dependency function, then netifd will search which device can reach to the remote address. Before the patch, netifd don't consider the PPP interface can reach to the remote address, so netifd will select default route to remote address, it will lead to remote address unreachable. Based on a patch by xiaofan <xfan1024@live.com> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-05-16treewide: pass bool as second argument of blobmsg_check_attrHans Dedecker
blobmsg_check_attr() takes as second argument a bool; fix it where needed Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-05-08interface-ip: fine tune IPv6 mtu warningHans Dedecker
Failing to set the IPv6 mtu is only a real issue if the mtu to be set is smaller than the current mtu as in that case it would break IPv6 path mtu; adapt the logic to generate the warning accordingly Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-05-07interface: tidy ipv6 mtu warningKevin Darbyshire-Bryant
Add missing space to change from: netifd: Failed to set IPv6 mtu to 1500on interface 'wg0' to: netifd: Failed to set IPv6 mtu to 1500 on interface 'wg0' Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
2019-04-15interface: add neighbor config supportmeurisa
The neighbor or neighbor6 network section makes neighbours configurable via UCI or proto shell handlers. It allows to install neighbor proxy entries or static neighbor entries The neighbor or neighbor6 section has the following types: interface : declares the logical OpenWrt interface ipaddr : the ip address of the neighbor mac : the mac address of the neighbor proxy : specifies whether the neighbor ia a proxy entry (can be 1 or 0) router : specifies whether the neighbor is a router (can be 1 or 0) Signed-off-by: Alexander Meuris <meurisalexander@gmail.com> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-03-13interface-ip: fix delegate config update on reload (FS#2087)Hans Dedecker
Update the no_delegation parameter on a config reload; in case prefixes are present update the prefix assignments as well according to the no_delegation status Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2018-11-19treewide: switch to C-code style commentsHans Dedecker
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2018-11-19treewide: make some functions staticHans Dedecker
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2018-08-07interface-ip: always override downstream IPv6 mtuHans Dedecker
Always override the downstream IPv6 mtu in case it differs with the IPv6 mtu of the upstream link. This allows to increase the downstream IPv6 mtu in case RA messages are received on the upstream link having a mtu attribute higher than the downstream IPv6 mtu. At the same be verbose when failing to set the IPv6 mtu on the downstream link. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2018-07-30fix compile errorJohn Crispin
netifd-2018-07-30-75ee7905/interface-ip.c:724:11: error: unused variable 'macaddr' [-Werror=unused-variable] Signed-off-by: John Crispin <john@phrozen.org>
2018-07-30interface-ip: fix eui64 ifaceid generation (FS#1668)Hans Dedecker
Use the mac address stored in the device_settings struct to generate the eui64 ifaceid as the interface layer3 device does not contain a mac address for non bridge interfaces Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2018-04-26nterface-ip: remove superfluous iface check in interface_ip_set_enabled()Hans Dedecker
No need to check iface pointer in interface_ip_set_enabled as the interface is always set by the function __interface_ip_init(). Reported by Coverity in CID 1330437 Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2018-04-12interface-ip: fix memory leak on error in interface_update_prefix_assignments()Hans Dedecker
Detected by coverity in CID 141267 Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2018-04-02interface-ip: fix memory leak in interface_ip_add_target_route()Hans Dedecker
Commit 9c8d781 introduced a memory leak in interface_ip_add_target_route in case interface_ip_find_addr_target returns true for a given address by not freeing the previously allocated route. While at it rework the logic so a host route is only allocated when it's really required. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2018-03-27netifd: return the interface for locally addressable host dependencies (FS#1452)Felix Fietkau
Fixes an issue where interfaces with host dependencies that resolve to a local subnet stay down. Fixes: 1f5a29c3de6e ("ip: do not add local routes for host dependencies") Signed-off-by: Felix Fietkau <nbd@nbd.name>
2018-03-13interface-ip: fix route selection for host dependenciesFelix Fietkau
In order to find the best match, allow overriding the last found entry if route->mask for the new entry is bigger than the one from the previous entry. Patch submitted by 'Mikael' in FS#1358 Signed-off-by: Felix Fietkau <nbd@nbd.name>
2018-03-07ip: do not add local routes for host dependenciesFelix Fietkau
This avoids creating invalid routes in cases where another daemon is handling local routes for an interface, e.g. on mesh interfaces Signed-off-by: Felix Fietkau <nbd@nbd.name>
2017-12-15interface-ip: harden eui64 IPv6 prefix address generationHans Dedecker
Check if a mac address is actually present when generating an eui64 based IPv6 address; in case of failure bail out. At the same time make sure the active mac address is used as input for the eui64 based IPv6 address and guarantee IPv6 prefix address generation is based on the actual config by resetting the IPv6 prefix address in the assignment structure when it gets deleted. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-12-15interface-ip: fix race condition in IPv6 prefix address generationHans Dedecker
Don't generate an IPv6 prefix address without taking into account the interface state. In case eui64 is configured to generate the ifaceid this could fail as the layer3 device mac address could not yet be available if the interface is not yet in setup or up state. While at it remove the interface metric assignment as this is already done by the function interface_set_route_info. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-11-17interface-ip: add missing IPv6 policy ruleHans Dedecker
Commit 2f31bff38d4dc2f36006ded6b8a7d039cb569eaa added interface routing table support; as a result for IPv6 the prefix route linked to the IPv6 address is added to the specified IPv6 interface routing table. In order to route traffic having as destination the IPv6 prefix a policy rule is required using the prefix destination as policy so the traffic is passed to the correct routing table. The IPv6 prefix address logic was not installing this policy rule effectively breaking routing when trying to reach a global or ULA IPv6 address in the lan from either the device or another wan device. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-10-18proto: add point-to-point IPv4 address config support (FS#1037)Hans Dedecker
Add config support support for point-to-point IPv4 addresses by providing the uci parameter ptpaddr. This allows to support a gateway being in a different subnet than the assigned IP by modeling the local IP having a point-to-point address. This is similar to the point-to-point IPv4 address support already present for the protocol handlers. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com> Tested-by: Stijn Tintel <stijn@linux-ipv6.be>
2017-04-05interface-ip: fix device name for IPv6 link-local DNS serverHans Dedecker
Commit 235a02424c3ab1b59308895c4f00395dacf2557c adds support for IPv6 link-local DNS server by appending the device name; however the interface ifname parameter does not always contain the layer 3 device name (e.g it can hold the aliased interface name) Fix this by passing the device name of the referenced layer 3 device. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-03-21interface-ip: set prefix indicator flag when IPv6 prefix lifetime changesHans Dedecker
Trigger interface update event when IPv6 prefix lifetime changes by setting the prefix indicator flag to inform external subsystems (eg hnetd) about IPv6 prefix lifetime changes. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-02-11interface: add prefix assignment priority supportHans Dedecker
In case of prefix delegation prefixes are assigned to one or more configured downstream interfaces. The delegated prefix length in combination with the assignment length of the downstream interfaces determines the number of subnets which can be allocated from the delegated prefix. The interface ip6weight parameter allows to prioritize the allocation of subnets to interfaces in case of multiple configured downstream interfaces. The order of interface prefix assignment from a delegated prefix is based on the following parameters: - Primary key is prefix assignment based on the configured interface ip6hint - Secondary key is the requested downstream interface prefix length, interfaces configured with the smallest ip6hint will be assigned first - Third key is the assigned interface ip6weight in case of equal prefix assignment length; interfaces having the highest ip6weight will be assigned first - Finally the alphabetical order of the interfaces in case of equal ip6weight Signed-off-by: Hans Dedecker <dedeckeh@gmail.com> Signed-off-by: Felix Fietkau <nbd@nbd.name> [cleanup]
2017-01-25interface-ip: route proto config support (FS#170)Hans Dedecker
Route proto support is usefull when using route distribution via a routing daemon. The route proto parameter can be specified via the route proto uci config parameter, it can hold a numerical value or the string values unspec, kernel, boot, static or a string present in /etc/iproute2/rt_protos. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2016-09-14interface-ip: DNS name server sorting support in resolv.conf.autoHans Dedecker
Interface name servers when being written to resolv.conf.auto are sorted based on the following parameters: -Primary sorting key is interface dns_metric; name servers having lowest interface dns_metric are listed first -Secondary sorting key is interface metric; in case of equal interface dns_metric name servers having lowest interface metric are listed first -Finally alphabetical order of the interface names in case of equal interface dns_metric and metric In case the resolver queries the multiple servers in the order listed; sorting is usefull in the following scenarios : -Name resolving over a main and backup interface -Assign priority to IPv6 name servers over IPv4 or vice versa Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2016-02-20interface-ip: Don't handle external addresses and routesHans Dedecker
Prevent external routes and address being added or deleted when changing the state of the interface ip settings Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2016-02-01interface-ip: Fix possbile segfaultsHans Dedecker
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2016-01-28netifd: Route traffic from LAN to WAN using rulesKristian Evensen
After commit ebd3d8417c7a ("interface: fix moving interface address routes to the table specified by ip[46]table"), it is no longer possible for clients on LAN to reach machines on the WAN. This patch restores support for clients on LAN reaching clients on WAN by using rules. The rules are placed after the address rules, in order to make sure that traffic originating from the router is routed correctly. Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
2016-01-17netifd: Do not add local/source policy rules multiple timesKristian Evensen
interface_ip_set_enabled() is usually called two times right after one another, once to handle config_ip and once to handle proto_ip. As long as ip->iface->l3_dev.dev is set, the local/source policy rules are updated. This value is in several cases set on both config_ip and proto_ip, causing the rules to be added multiple time. The reason is that the kernel does not respect the NLM_F_* flag for rules. In other words, the rule state has to be managed by the routing daemon. Since the local/source policy rules are bound to iface, this commit solves the problem by adding a flag to interface which stores the current rule state. The flag follows the enabled-paramter passed to interface_ip_set_enabled(), similar to route-> and addr->enabled. The flag breaks the alignment of the interface struct, but based on earlier commits this seems to be ok. I have tested the patch in different configurations and have not found any regression. Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
2015-12-16interface-ip: unify handling of interface metric/table for routes, fixes ↵Felix Fietkau
handling for prefixes Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-12-15interface-ip: fix subnet route handlingFelix Fietkau
When the kernel subnet route has to be replaced, the cleanup call needs to match the properties of the replacement route exactly, mainly the metric and the routing table. Fix handling this by embedding the device_route for the subnet in the device_addr struct and using it in the cleanup path. This fixes issues on config reload with changes to the routing table Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-11-12interface: fix moving interface address routes to the table specified by ↵Felix Fietkau
ip[46]table Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-09-29interface-ip: Remove table specific nw rules for IPv4/6 addressesHans Dedecker
2015-09-29interface-ip: Re-enable iif lo policy rules after main table lookupHans Dedecker
2015-09-29interface-ip: Support source ip rule updates when reloadingHans Dedecker
2015-09-26interface-ip: Fix broadcast address when using /31 or /32 IPv4 addressingBaptiste Jonglez
A /31-addressed interface requires a broadcast address of 255.255.255.255, because there is no room for a proper broadcast address. Without this, any packet destinated to the other end of the link is sent as broadcast, which is incorrect. For consistency with the Linux kernel, /32-addressed interfaces are treated in the same way. Signed-off-by: Baptiste Jonglez <git@bitsofnetworks.org>
2015-09-21netifd: Prevent flapping IPv6 routesKristian Evensen
Comparing valid_until will always return false as the value is updated for each route update message. This causes IPv6 routes to jump more around than House of Pain, which might have undesirable consequences for user-space and user-space applications. Removing the valid_until comparison when setting keep fixes this problem, and seems to have no side-effects. I am no IPv6 expert, but I see that valid of the route is updated correctly and route is deleted if I block the route update messages. Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
2015-09-10interface-ip: Set route table when enabling interface ip settingsHans Dedecker
Routes are now inserted in the correct routing table when interface ip4table and/or ip6table was changed during interface_change_config Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2015-09-10interface-ip: Don't create ip network rule if address mask is equal to full maskHans Dedecker
Prevents the creation of identical address and network IP rules Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2015-09-10interface-ip: Insert network and address ip rules for external addresses as wellHans Dedecker
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2015-09-10interface-ip: Remove ip loop policy rules as kernel issue is fixedHans Dedecker
Remove ip loop policy rules as workaround for the kernel using unspecified address to lookup locally originating traffic is fixed by http://lkml.iu.edu/hypermail/linux/kernel/1505.0/03094.html Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2015-06-24Add mtu6 option to override IPv6 MTUSteven Barth
Signed-off-by: Steven Barth <steven@midlink.org>
2015-05-26linux: more IPv6 onlink-route handling fixes / improvementsSteven Barth
Signed-off-by: Steven Barth <steven@midlink.org>