diff options
Diffstat (limited to 'include/net/xfrm.h')
-rw-r--r-- | include/net/xfrm.h | 79 |
1 files changed, 71 insertions, 8 deletions
diff --git a/include/net/xfrm.h b/include/net/xfrm.h index ae35991b5877..7d2077665c0b 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h | |||
@@ -968,7 +968,7 @@ static inline bool xfrm_sec_ctx_match(struct xfrm_sec_ctx *s1, struct xfrm_sec_c | |||
968 | 968 | ||
969 | /* A struct encoding bundle of transformations to apply to some set of flow. | 969 | /* A struct encoding bundle of transformations to apply to some set of flow. |
970 | * | 970 | * |
971 | * dst->child points to the next element of bundle. | 971 | * xdst->child points to the next element of bundle. |
972 | * dst->xfrm points to an instanse of transformer. | 972 | * dst->xfrm points to an instanse of transformer. |
973 | * | 973 | * |
974 | * Due to unfortunate limitations of current routing cache, which we | 974 | * Due to unfortunate limitations of current routing cache, which we |
@@ -984,6 +984,8 @@ struct xfrm_dst { | |||
984 | struct rt6_info rt6; | 984 | struct rt6_info rt6; |
985 | } u; | 985 | } u; |
986 | struct dst_entry *route; | 986 | struct dst_entry *route; |
987 | struct dst_entry *child; | ||
988 | struct dst_entry *path; | ||
987 | struct xfrm_policy *pols[XFRM_POLICY_TYPE_MAX]; | 989 | struct xfrm_policy *pols[XFRM_POLICY_TYPE_MAX]; |
988 | int num_pols, num_xfrms; | 990 | int num_pols, num_xfrms; |
989 | u32 xfrm_genid; | 991 | u32 xfrm_genid; |
@@ -994,7 +996,35 @@ struct xfrm_dst { | |||
994 | u32 path_cookie; | 996 | u32 path_cookie; |
995 | }; | 997 | }; |
996 | 998 | ||
999 | static inline struct dst_entry *xfrm_dst_path(const struct dst_entry *dst) | ||
1000 | { | ||
1001 | #ifdef CONFIG_XFRM | ||
1002 | if (dst->xfrm) { | ||
1003 | const struct xfrm_dst *xdst = (const struct xfrm_dst *) dst; | ||
1004 | |||
1005 | return xdst->path; | ||
1006 | } | ||
1007 | #endif | ||
1008 | return (struct dst_entry *) dst; | ||
1009 | } | ||
1010 | |||
1011 | static inline struct dst_entry *xfrm_dst_child(const struct dst_entry *dst) | ||
1012 | { | ||
1013 | #ifdef CONFIG_XFRM | ||
1014 | if (dst->xfrm) { | ||
1015 | struct xfrm_dst *xdst = (struct xfrm_dst *) dst; | ||
1016 | return xdst->child; | ||
1017 | } | ||
1018 | #endif | ||
1019 | return NULL; | ||
1020 | } | ||
1021 | |||
997 | #ifdef CONFIG_XFRM | 1022 | #ifdef CONFIG_XFRM |
1023 | static inline void xfrm_dst_set_child(struct xfrm_dst *xdst, struct dst_entry *child) | ||
1024 | { | ||
1025 | xdst->child = child; | ||
1026 | } | ||
1027 | |||
998 | static inline void xfrm_dst_destroy(struct xfrm_dst *xdst) | 1028 | static inline void xfrm_dst_destroy(struct xfrm_dst *xdst) |
999 | { | 1029 | { |
1000 | xfrm_pols_put(xdst->pols, xdst->num_pols); | 1030 | xfrm_pols_put(xdst->pols, xdst->num_pols); |
@@ -1021,6 +1051,7 @@ struct xfrm_offload { | |||
1021 | #define XFRM_GSO_SEGMENT 16 | 1051 | #define XFRM_GSO_SEGMENT 16 |
1022 | #define XFRM_GRO 32 | 1052 | #define XFRM_GRO 32 |
1023 | #define XFRM_ESP_NO_TRAILER 64 | 1053 | #define XFRM_ESP_NO_TRAILER 64 |
1054 | #define XFRM_DEV_RESUME 128 | ||
1024 | 1055 | ||
1025 | __u32 status; | 1056 | __u32 status; |
1026 | #define CRYPTO_SUCCESS 1 | 1057 | #define CRYPTO_SUCCESS 1 |
@@ -1847,34 +1878,53 @@ static inline struct xfrm_state *xfrm_input_state(struct sk_buff *skb) | |||
1847 | { | 1878 | { |
1848 | return skb->sp->xvec[skb->sp->len - 1]; | 1879 | return skb->sp->xvec[skb->sp->len - 1]; |
1849 | } | 1880 | } |
1881 | #endif | ||
1882 | |||
1850 | static inline struct xfrm_offload *xfrm_offload(struct sk_buff *skb) | 1883 | static inline struct xfrm_offload *xfrm_offload(struct sk_buff *skb) |
1851 | { | 1884 | { |
1885 | #ifdef CONFIG_XFRM | ||
1852 | struct sec_path *sp = skb->sp; | 1886 | struct sec_path *sp = skb->sp; |
1853 | 1887 | ||
1854 | if (!sp || !sp->olen || sp->len != sp->olen) | 1888 | if (!sp || !sp->olen || sp->len != sp->olen) |
1855 | return NULL; | 1889 | return NULL; |
1856 | 1890 | ||
1857 | return &sp->ovec[sp->olen - 1]; | 1891 | return &sp->ovec[sp->olen - 1]; |
1858 | } | 1892 | #else |
1893 | return NULL; | ||
1859 | #endif | 1894 | #endif |
1895 | } | ||
1860 | 1896 | ||
1861 | void __net_init xfrm_dev_init(void); | 1897 | void __net_init xfrm_dev_init(void); |
1862 | 1898 | ||
1863 | #ifdef CONFIG_XFRM_OFFLOAD | 1899 | #ifdef CONFIG_XFRM_OFFLOAD |
1864 | int validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t features); | 1900 | void xfrm_dev_resume(struct sk_buff *skb); |
1901 | void xfrm_dev_backlog(struct softnet_data *sd); | ||
1902 | struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t features, bool *again); | ||
1865 | int xfrm_dev_state_add(struct net *net, struct xfrm_state *x, | 1903 | int xfrm_dev_state_add(struct net *net, struct xfrm_state *x, |
1866 | struct xfrm_user_offload *xuo); | 1904 | struct xfrm_user_offload *xuo); |
1867 | bool xfrm_dev_offload_ok(struct sk_buff *skb, struct xfrm_state *x); | 1905 | bool xfrm_dev_offload_ok(struct sk_buff *skb, struct xfrm_state *x); |
1868 | 1906 | ||
1907 | static inline void xfrm_dev_state_advance_esn(struct xfrm_state *x) | ||
1908 | { | ||
1909 | struct xfrm_state_offload *xso = &x->xso; | ||
1910 | |||
1911 | if (xso->dev && xso->dev->xfrmdev_ops->xdo_dev_state_advance_esn) | ||
1912 | xso->dev->xfrmdev_ops->xdo_dev_state_advance_esn(x); | ||
1913 | } | ||
1914 | |||
1869 | static inline bool xfrm_dst_offload_ok(struct dst_entry *dst) | 1915 | static inline bool xfrm_dst_offload_ok(struct dst_entry *dst) |
1870 | { | 1916 | { |
1871 | struct xfrm_state *x = dst->xfrm; | 1917 | struct xfrm_state *x = dst->xfrm; |
1918 | struct xfrm_dst *xdst; | ||
1872 | 1919 | ||
1873 | if (!x || !x->type_offload) | 1920 | if (!x || !x->type_offload) |
1874 | return false; | 1921 | return false; |
1875 | 1922 | ||
1876 | if (x->xso.offload_handle && (x->xso.dev == dst->path->dev) && | 1923 | xdst = (struct xfrm_dst *) dst; |
1877 | !dst->child->xfrm) | 1924 | if (!x->xso.offload_handle && !xdst->child->xfrm) |
1925 | return true; | ||
1926 | if (x->xso.offload_handle && (x->xso.dev == xfrm_dst_path(dst)->dev) && | ||
1927 | !xdst->child->xfrm) | ||
1878 | return true; | 1928 | return true; |
1879 | 1929 | ||
1880 | return false; | 1930 | return false; |
@@ -1894,15 +1944,24 @@ static inline void xfrm_dev_state_free(struct xfrm_state *x) | |||
1894 | struct net_device *dev = xso->dev; | 1944 | struct net_device *dev = xso->dev; |
1895 | 1945 | ||
1896 | if (dev && dev->xfrmdev_ops) { | 1946 | if (dev && dev->xfrmdev_ops) { |
1897 | dev->xfrmdev_ops->xdo_dev_state_free(x); | 1947 | if (dev->xfrmdev_ops->xdo_dev_state_free) |
1948 | dev->xfrmdev_ops->xdo_dev_state_free(x); | ||
1898 | xso->dev = NULL; | 1949 | xso->dev = NULL; |
1899 | dev_put(dev); | 1950 | dev_put(dev); |
1900 | } | 1951 | } |
1901 | } | 1952 | } |
1902 | #else | 1953 | #else |
1903 | static inline int validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t features) | 1954 | static inline void xfrm_dev_resume(struct sk_buff *skb) |
1904 | { | 1955 | { |
1905 | return 0; | 1956 | } |
1957 | |||
1958 | static inline void xfrm_dev_backlog(struct softnet_data *sd) | ||
1959 | { | ||
1960 | } | ||
1961 | |||
1962 | static inline struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t features, bool *again) | ||
1963 | { | ||
1964 | return skb; | ||
1906 | } | 1965 | } |
1907 | 1966 | ||
1908 | static inline int xfrm_dev_state_add(struct net *net, struct xfrm_state *x, struct xfrm_user_offload *xuo) | 1967 | static inline int xfrm_dev_state_add(struct net *net, struct xfrm_state *x, struct xfrm_user_offload *xuo) |
@@ -1923,6 +1982,10 @@ static inline bool xfrm_dev_offload_ok(struct sk_buff *skb, struct xfrm_state *x | |||
1923 | return false; | 1982 | return false; |
1924 | } | 1983 | } |
1925 | 1984 | ||
1985 | static inline void xfrm_dev_state_advance_esn(struct xfrm_state *x) | ||
1986 | { | ||
1987 | } | ||
1988 | |||
1926 | static inline bool xfrm_dst_offload_ok(struct dst_entry *dst) | 1989 | static inline bool xfrm_dst_offload_ok(struct dst_entry *dst) |
1927 | { | 1990 | { |
1928 | return false; | 1991 | return false; |