fib_semantics.c (b8d3e4163a3562d7cba486687904383e78e7dd6a) fib_semantics.c (c3a8d9474684d391b0afc3970d9b249add15ec07)
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * IPv4 Forwarding Information Base: semantics.
7 *
8 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>

--- 865 unchanged lines hidden (view full) ---

874 }
875 }
876 return true;
877}
878
879static int
880fib_convert_metrics(struct fib_info *fi, const struct fib_config *cfg)
881{
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * IPv4 Forwarding Information Base: semantics.
7 *
8 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>

--- 865 unchanged lines hidden (view full) ---

874 }
875 }
876 return true;
877}
878
879static int
880fib_convert_metrics(struct fib_info *fi, const struct fib_config *cfg)
881{
882 bool ecn_ca = false;
882 struct nlattr *nla;
883 int remaining;
884
885 if (!cfg->fc_mx)
886 return 0;
887
888 nla_for_each_attr(nla, cfg->fc_mx, cfg->fc_mx_len, remaining) {
889 int type = nla_type(nla);
890 u32 val;
891
892 if (!type)
893 continue;
894 if (type > RTAX_MAX)
895 return -EINVAL;
896
897 if (type == RTAX_CC_ALGO) {
898 char tmp[TCP_CA_NAME_MAX];
899
900 nla_strlcpy(tmp, nla, sizeof(tmp));
883 struct nlattr *nla;
884 int remaining;
885
886 if (!cfg->fc_mx)
887 return 0;
888
889 nla_for_each_attr(nla, cfg->fc_mx, cfg->fc_mx_len, remaining) {
890 int type = nla_type(nla);
891 u32 val;
892
893 if (!type)
894 continue;
895 if (type > RTAX_MAX)
896 return -EINVAL;
897
898 if (type == RTAX_CC_ALGO) {
899 char tmp[TCP_CA_NAME_MAX];
900
901 nla_strlcpy(tmp, nla, sizeof(tmp));
901 val = tcp_ca_get_key_by_name(tmp);
902 val = tcp_ca_get_key_by_name(tmp, &ecn_ca);
902 if (val == TCP_CA_UNSPEC)
903 return -EINVAL;
904 } else {
905 val = nla_get_u32(nla);
906 }
907 if (type == RTAX_ADVMSS && val > 65535 - 40)
908 val = 65535 - 40;
909 if (type == RTAX_MTU && val > 65535 - 15)
910 val = 65535 - 15;
911 if (type == RTAX_FEATURES && (val & ~RTAX_FEATURE_MASK))
912 return -EINVAL;
913 fi->fib_metrics[type - 1] = val;
914 }
915
903 if (val == TCP_CA_UNSPEC)
904 return -EINVAL;
905 } else {
906 val = nla_get_u32(nla);
907 }
908 if (type == RTAX_ADVMSS && val > 65535 - 40)
909 val = 65535 - 40;
910 if (type == RTAX_MTU && val > 65535 - 15)
911 val = 65535 - 15;
912 if (type == RTAX_FEATURES && (val & ~RTAX_FEATURE_MASK))
913 return -EINVAL;
914 fi->fib_metrics[type - 1] = val;
915 }
916
917 if (ecn_ca)
918 fi->fib_metrics[RTAX_FEATURES - 1] |= DST_FEATURE_ECN_CA;
919
916 return 0;
917}
918
919struct fib_info *fib_create_info(struct fib_config *cfg)
920{
921 int err;
922 struct fib_info *fi = NULL;
923 struct fib_info *ofi;

--- 622 unchanged lines hidden ---
920 return 0;
921}
922
923struct fib_info *fib_create_info(struct fib_config *cfg)
924{
925 int err;
926 struct fib_info *fi = NULL;
927 struct fib_info *ofi;

--- 622 unchanged lines hidden ---