aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/at91
Commit message (Expand)AuthorAgeFilesLines
* treewide: replace backticks by $(...) in gen_*_img.sh scriptsAdrian Schmutzler2019-09-291-1/+1
* at91:sam9x: create sdcard imagesSandeep Sheriker M2019-09-211-2/+42
* at91:sama5: create fit imageSandeep Sheriker M2019-09-212-1/+5
* at91/image/sama5.mk: check for sama5d4_xplained deviceSandeep Sheriker M2019-08-171-3/+7
* at91: remove Build/at91-sdcard commandSandeep Sheriker M2019-08-171-35/+0
* at91: add uboot environmentsSandeep Sheriker M2019-08-172-1/+24
* at91: move at91-sdcard command to sama5.mkSandeep Sheriker M2019-08-171-0/+33
* at91bootstrap: add sama5d27_som1_eksd1_uboot as default defconfigSandeep Sheriker M2019-08-171-3/+7
* at91: split up DEVICE_TITLEMoritz Warning2019-08-021-19/+39
* at91:renaming subtraget legacy to sam9xSandeep Sheriker M2019-05-306-12/+12
* at91: Update kernel to version 4.14Hauke Mehrtens2019-05-309-912/+44
* at91: Merge SAMA5 subtargetsHauke Mehrtens2019-05-3014-129/+87
* at91: Clean up kernel configurationHauke Mehrtens2019-05-302-20/+1
* at91: Refresh kernel configurationHauke Mehrtens2019-05-305-179/+65
* kernel: Activate CONFIG_SYN_COOKIES for all targetsHauke Mehrtens2019-05-111-1/+0
* kernel: Build: Split kmod-regmapHauke Mehrtens2019-01-271-1/+1
* at91: dts: Unify naming of gpio-keys nodesPetr Štetiar2019-01-242-2/+2
* kernel: Deactivate CONFIG_COMPAT_BRKHauke Mehrtens2018-12-261-1/+0
* treewide: dts: Remove default-state=off property from all gpio LED nodesPetr Štetiar2018-12-171-3/+0
* kernel: bump 4.9 to 4.9.143Koen Vandeputte2018-12-101-0/+1
* kernel: enable memory compactionFelix Fietkau2018-10-091-1/+0
* treewide: fix some cosmetic glitches in dts filesPaul Wassi2018-08-273-31/+29
* at91: do not build image for at91-q5xr5Hauke Mehrtens2018-08-121-1/+1
* kernel: only optimized for size if small_flashMathias Kresin2018-07-121-2/+0
* kernel: remove DEVMEM and DEVKMEM from target's configLuis Araneda2018-07-071-2/+0
* kernel: bump 4.9 to 4.9.100Koen Vandeputte2018-05-182-35/+13
* at91: sama5d4: fix bad mkubifs optionsJo-Philipp Wich2018-05-131-1/+1
* at91: cleanup kernel configurationsJo-Philipp Wich2018-05-115-1104/+141
* at91: sama5d2: remove CONFIG_XZ_DEC overrideJo-Philipp Wich2018-05-111-5/+0
* at91: add missing config symbolsJo-Philipp Wich2018-05-112-0/+3
* at91: refreshing kernel configurations.Sandeep Sheriker Mallikarjun2018-05-055-2435/+1202
* at91: Add SAMA5D2 PTC EK boardSandeep Sheriker Mallikarjun2018-05-053-0/+453
* at91: reorganize at91 subtargetsSandeep Sheriker Mallikarjun2018-05-0513-113/+2777
* at91: sdcard image with ext4 rootfsSandeep Sheriker Mallikarjun2018-05-052-2/+3
* at91: Add SAMA5D27 SOM1 EK boardSandeep Sheriker Mallikarjun2018-05-053-5/+924
* at91: fix sdcard create imageSandeep Sheriker Mallikarjun2018-05-051-7/+9
* at91: sama5: remove neon and VFPv4 supportSandeep Sheriker Mallikarjun2018-04-301-3/+1
* at91: fix build error for wb50n.Sandeep Sheriker Mallikarjun2018-04-301-10/+14
* at91: fix image building with CONFIG_TARGET_MULTI_PROFILEJo-Philipp Wich2018-02-142-11/+10
* at91: create device specific sdcard imagesHauke Mehrtens2018-01-111-4/+4
* at91: sama5: activate fpuHauke Mehrtens2018-01-021-0/+2
* at91: create sdcard image for sama5Sandeep Sheriker Mallikarjun2017-12-162-0/+79
* at91: remove unused at91part driverHauke Mehrtens2017-10-221-122/+0
* at91: update to kernel 4.9Hauke Mehrtens2017-10-229-23/+26
* at91: fix legacy buildHauke Mehrtens2017-10-161-2/+1
* at91: add support for the WB50N module from LairdBen Whitten2017-10-154-0/+348
* at91: add support for the WB45N module from LairdBen Whitten2017-10-154-0/+253
* at91: separate MKUBIFS opts to defaults in the sub targetBen Whitten2017-10-153-13/+18
* at91: refresh kernel config, enable UBI block and DMABen Whitten2017-10-151-1/+6
* at91: Add ext4 filesystemSandeep Sheriker Mallikarjun2017-10-141-1/+1
route set and that will overwrite the current + * default route. This is the case only when doing demand, otherwise + * during demand, this cifdefaultroute would restore the old default + * route which is not what we want in this case. In the non-demand + * case, we'll delete the default route and restore the old if there + * is one saved by an sifdefaultroute with replacedefaultroute. + */ + if (!replacedefaultroute && default_route_set[unit]) { cifdefaultroute(unit, ouraddr, hisaddr); default_route_set[unit] = 0; } --- a/pppd/ipcp.h +++ b/pppd/ipcp.h @@ -70,6 +70,7 @@ typedef struct ipcp_options { bool old_addrs; /* Use old (IP-Addresses) option? */ bool req_addr; /* Ask peer to send IP address? */ bool default_route; /* Assign default route through interface? */ + bool replace_default_route; /* Replace default route through interface? */ bool proxy_arp; /* Make proxy ARP entry for peer? */ bool neg_vj; /* Van Jacobson Compression? */ bool old_vj; /* use old (short) form of VJ option? */ --- a/pppd/pppd.8 +++ b/pppd/pppd.8 @@ -121,6 +121,11 @@ the gateway, when IPCP negotiation is su This entry is removed when the PPP connection is broken. This option is privileged if the \fInodefaultroute\fR option has been specified. .TP +.B replacedefaultroute +This option is a flag to the defaultroute option. If defaultroute is +set and this flag is also set, pppd replaces an existing default route +with the new default route. +.TP .B disconnect \fIscript Execute the command specified by \fIscript\fR, by passing it to a shell, after @@ -717,7 +722,12 @@ disable both forms of hardware flow cont .TP .B nodefaultroute Disable the \fIdefaultroute\fR option. The system administrator who -wishes to prevent users from creating default routes with pppd +wishes to prevent users from adding a default route with pppd +can do so by placing this option in the /etc/ppp/options file. +.TP +.B noreplacedefaultroute +Disable the \fIreplacedefaultroute\fR option. The system administrator who +wishes to prevent users from replacing a default route with pppd can do so by placing this option in the /etc/ppp/options file. .TP .B nodeflate --- a/pppd/pppd.h +++ b/pppd/pppd.h @@ -645,7 +645,7 @@ int sif6addr __P((int, eui64_t, eui64_t int cif6addr __P((int, eui64_t, eui64_t)); /* Remove an IPv6 address from i/f */ #endif -int sifdefaultroute __P((int, u_int32_t, u_int32_t)); +int sifdefaultroute __P((int, u_int32_t, u_int32_t, bool replace_default_rt)); /* Create default route through i/f */ int cifdefaultroute __P((int, u_int32_t, u_int32_t)); /* Delete default route through i/f */ --- a/pppd/sys-linux.c +++ b/pppd/sys-linux.c @@ -206,6 +206,8 @@ static unsigned char inbuf[512]; /* buff static int if_is_up; /* Interface has been marked up */ static int have_default_route; /* Gateway for default route added */ +static struct rtentry old_def_rt; /* Old default route */ +static int default_rt_repl_rest; /* replace and restore old default rt */ static u_int32_t proxy_arp_addr; /* Addr for proxy arp entry added */ static char proxy_arp_dev[16]; /* Device for proxy arp entry */ static u_int32_t our_old_addr; /* for detecting address changes */ @@ -1544,6 +1546,9 @@ static int read_route_table(struct rtent p = NULL; } + SET_SA_FAMILY (rt->rt_dst, AF_INET); + SET_SA_FAMILY (rt->rt_gateway, AF_INET); + SIN_ADDR(rt->rt_dst) = strtoul(cols[route_dest_col], NULL, 16); SIN_ADDR(rt->rt_gateway) = strtoul(cols[route_gw_col], NULL, 16); SIN_ADDR(rt->rt_genmask) = strtoul(cols[route_mask_col], NULL, 16); @@ -1613,20 +1618,51 @@ int have_route_to(u_int32_t addr) /******************************************************************** * * sifdefaultroute - assign a default route through the address given. - */ - -int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway) -{ - struct rtentry rt; - - if (defaultroute_exists(&rt) && strcmp(rt.rt_dev, ifname) != 0) { - if (rt.rt_flags & RTF_GATEWAY) - error("not replacing existing default route via %I", - SIN_ADDR(rt.rt_gateway)); - else + * + * If the global default_rt_repl_rest flag is set, then this function + * already replaced the original system defaultroute with some other + * route and it should just replace the current defaultroute with + * another one, without saving the current route. Use: demand mode, + * when pppd sets first a defaultroute it it's temporary ppp0 addresses + * and then changes the temporary addresses to the addresses for the real + * ppp connection when it has come up. + */ + +int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway, bool replace) +{ + struct rtentry rt, tmp_rt; + struct rtentry *del_rt = NULL; + + if (default_rt_repl_rest) { + /* We have already reclaced the original defaultroute, if we + are called again, we will delete the current default route + and set the new default route in this function. + - this is normally only the case the doing demand: */ + if (defaultroute_exists(&tmp_rt)) + del_rt = &tmp_rt; + } else if (defaultroute_exists(&old_def_rt) && + strcmp(old_def_rt.rt_dev, ifname) != 0) { + /* We did not yet replace an existing default route, let's + check if we should save and replace a default route: */ + if (old_def_rt.rt_flags & RTF_GATEWAY) { + if (!replace) { + error("not replacing existing default route via %I", + SIN_ADDR(old_def_rt.rt_gateway)); + return 0; + } else { + /* we need to copy rt_dev because we need it permanent too: */ + char *tmp_dev = malloc(strlen(old_def_rt.rt_dev) + 1); + strcpy(tmp_dev, old_def_rt.rt_dev); + old_def_rt.rt_dev = tmp_dev; + + notice("replacing old default route to %s [%I]", + old_def_rt.rt_dev, SIN_ADDR(old_def_rt.rt_gateway)); + default_rt_repl_rest = 1; + del_rt = &old_def_rt; + } + } else error("not replacing existing default route through %s", - rt.rt_dev); - return 0; + old_def_rt.rt_dev); } memset (&rt, 0, sizeof (rt)); @@ -1641,10 +1677,16 @@ int sifdefaultroute (int unit, u_int32_t rt.rt_flags = RTF_UP; if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) { - if ( ! ok_error ( errno )) + if (!ok_error(errno)) error("default route ioctl(SIOCADDRT): %m"); return 0; } + if (default_rt_repl_rest && del_rt) + if (ioctl(sock_fd, SIOCDELRT, del_rt) < 0) { + if (!ok_error(errno)) + error("del old default route ioctl(SIOCDELRT): %m"); + return 0; + } have_default_route = 1; return 1; @@ -1675,11 +1717,21 @@ int cifdefaultroute (int unit, u_int32_t rt.rt_flags = RTF_UP; if (ioctl(sock_fd, SIOCDELRT, &rt) < 0 && errno != ESRCH) { if (still_ppp()) { - if ( ! ok_error ( errno )) + if (!ok_error(errno)) error("default route ioctl(SIOCDELRT): %m"); return 0; } } + if (default_rt_repl_rest) { + notice("restoring old default route to %s [%I]", + old_def_rt.rt_dev, SIN_ADDR(old_def_rt.rt_gateway)); + if (ioctl(sock_fd, SIOCADDRT, &old_def_rt) < 0) { + if (!ok_error(errno)) + error("restore default route ioctl(SIOCADDRT): %m"); + return 0; + } + default_rt_repl_rest = 0; + } return 1; } --- a/pppd/sys-solaris.c +++ b/pppd/sys-solaris.c @@ -2036,12 +2036,18 @@ cifaddr(u, o, h) * sifdefaultroute - assign a default route through the address given. */ int -sifdefaultroute(u, l, g) +sifdefaultroute(u, l, g, replace) int u; u_int32_t l, g; + bool replace; { struct rtentry rt; + if (replace) { + error("replacedefaultroute not supported on this platform"); + return 0; + } + #if defined(__USLC__) g = l; /* use the local address as gateway */ #endif