diff options
| -rw-r--r-- | net/core/neighbour.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 8e38f17288d3..8d614c93f86a 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c | |||
| @@ -2043,6 +2043,12 @@ static int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
| 2043 | case NDTPA_BASE_REACHABLE_TIME: | 2043 | case NDTPA_BASE_REACHABLE_TIME: |
| 2044 | NEIGH_VAR_SET(p, BASE_REACHABLE_TIME, | 2044 | NEIGH_VAR_SET(p, BASE_REACHABLE_TIME, |
| 2045 | nla_get_msecs(tbp[i])); | 2045 | nla_get_msecs(tbp[i])); |
| 2046 | /* update reachable_time as well, otherwise, the change will | ||
| 2047 | * only be effective after the next time neigh_periodic_work | ||
| 2048 | * decides to recompute it (can be multiple minutes) | ||
| 2049 | */ | ||
| 2050 | p->reachable_time = | ||
| 2051 | neigh_rand_reach_time(NEIGH_VAR(p, BASE_REACHABLE_TIME)); | ||
| 2046 | break; | 2052 | break; |
| 2047 | case NDTPA_GC_STALETIME: | 2053 | case NDTPA_GC_STALETIME: |
| 2048 | NEIGH_VAR_SET(p, GC_STALETIME, | 2054 | NEIGH_VAR_SET(p, GC_STALETIME, |
| @@ -2921,6 +2927,31 @@ static int neigh_proc_dointvec_unres_qlen(struct ctl_table *ctl, int write, | |||
| 2921 | return ret; | 2927 | return ret; |
| 2922 | } | 2928 | } |
| 2923 | 2929 | ||
| 2930 | static int neigh_proc_base_reachable_time(struct ctl_table *ctl, int write, | ||
| 2931 | void __user *buffer, | ||
| 2932 | size_t *lenp, loff_t *ppos) | ||
| 2933 | { | ||
| 2934 | struct neigh_parms *p = ctl->extra2; | ||
| 2935 | int ret; | ||
| 2936 | |||
| 2937 | if (strcmp(ctl->procname, "base_reachable_time") == 0) | ||
| 2938 | ret = neigh_proc_dointvec_jiffies(ctl, write, buffer, lenp, ppos); | ||
| 2939 | else if (strcmp(ctl->procname, "base_reachable_time_ms") == 0) | ||
| 2940 | ret = neigh_proc_dointvec_ms_jiffies(ctl, write, buffer, lenp, ppos); | ||
| 2941 | else | ||
| 2942 | ret = -1; | ||
| 2943 | |||
| 2944 | if (write && ret == 0) { | ||
| 2945 | /* update reachable_time as well, otherwise, the change will | ||
| 2946 | * only be effective after the next time neigh_periodic_work | ||
| 2947 | * decides to recompute it | ||
| 2948 | */ | ||
| 2949 | p->reachable_time = | ||
| 2950 | neigh_rand_reach_time(NEIGH_VAR(p, BASE_REACHABLE_TIME)); | ||
| 2951 | } | ||
| 2952 | return ret; | ||
| 2953 | } | ||
| 2954 | |||
| 2924 | #define NEIGH_PARMS_DATA_OFFSET(index) \ | 2955 | #define NEIGH_PARMS_DATA_OFFSET(index) \ |
| 2925 | (&((struct neigh_parms *) 0)->data[index]) | 2956 | (&((struct neigh_parms *) 0)->data[index]) |
| 2926 | 2957 | ||
| @@ -3047,6 +3078,19 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p, | |||
| 3047 | t->neigh_vars[NEIGH_VAR_RETRANS_TIME_MS].proc_handler = handler; | 3078 | t->neigh_vars[NEIGH_VAR_RETRANS_TIME_MS].proc_handler = handler; |
| 3048 | /* ReachableTime (in milliseconds) */ | 3079 | /* ReachableTime (in milliseconds) */ |
| 3049 | t->neigh_vars[NEIGH_VAR_BASE_REACHABLE_TIME_MS].proc_handler = handler; | 3080 | t->neigh_vars[NEIGH_VAR_BASE_REACHABLE_TIME_MS].proc_handler = handler; |
| 3081 | } else { | ||
| 3082 | /* Those handlers will update p->reachable_time after | ||
| 3083 | * base_reachable_time(_ms) is set to ensure the new timer starts being | ||
| 3084 | * applied after the next neighbour update instead of waiting for | ||
| 3085 | * neigh_periodic_work to update its value (can be multiple minutes) | ||
| 3086 | * So any handler that replaces them should do this as well | ||
| 3087 | */ | ||
| 3088 | /* ReachableTime */ | ||
| 3089 | t->neigh_vars[NEIGH_VAR_BASE_REACHABLE_TIME].proc_handler = | ||
| 3090 | neigh_proc_base_reachable_time; | ||
| 3091 | /* ReachableTime (in milliseconds) */ | ||
| 3092 | t->neigh_vars[NEIGH_VAR_BASE_REACHABLE_TIME_MS].proc_handler = | ||
| 3093 | neigh_proc_base_reachable_time; | ||
| 3050 | } | 3094 | } |
| 3051 | 3095 | ||
| 3052 | /* Don't export sysctls to unprivileged users */ | 3096 | /* Don't export sysctls to unprivileged users */ |
