aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/linux/ethtool.h233
-rw-r--r--include/linux/netdevice.h4
-rw-r--r--include/linux/pkt_sched.h15
-rw-r--r--include/net/flow.h25
-rw-r--r--include/net/ip_fib.h6
-rw-r--r--include/net/route.h60
-rw-r--r--include/net/sock.h54
-rw-r--r--include/net/xfrm.h9
8 files changed, 293 insertions, 113 deletions
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index dc80d829424..12cfbd0be2e 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -380,27 +380,42 @@ struct ethtool_usrip4_spec {
380 __u8 proto; 380 __u8 proto;
381}; 381};
382 382
383union ethtool_flow_union {
384 struct ethtool_tcpip4_spec tcp_ip4_spec;
385 struct ethtool_tcpip4_spec udp_ip4_spec;
386 struct ethtool_tcpip4_spec sctp_ip4_spec;
387 struct ethtool_ah_espip4_spec ah_ip4_spec;
388 struct ethtool_ah_espip4_spec esp_ip4_spec;
389 struct ethtool_usrip4_spec usr_ip4_spec;
390 struct ethhdr ether_spec;
391 __u8 hdata[60];
392};
393
394struct ethtool_flow_ext {
395 __be16 vlan_etype;
396 __be16 vlan_tci;
397 __be32 data[2];
398};
399
383/** 400/**
384 * struct ethtool_rx_flow_spec - specification for RX flow filter 401 * struct ethtool_rx_flow_spec - specification for RX flow filter
385 * @flow_type: Type of match to perform, e.g. %TCP_V4_FLOW 402 * @flow_type: Type of match to perform, e.g. %TCP_V4_FLOW
386 * @h_u: Flow fields to match (dependent on @flow_type) 403 * @h_u: Flow fields to match (dependent on @flow_type)
387 * @m_u: Masks for flow field bits to be ignored 404 * @h_ext: Additional fields to match
405 * @m_u: Masks for flow field bits to be matched
406 * @m_ext: Masks for additional field bits to be matched
407 * Note, all additional fields must be ignored unless @flow_type
408 * includes the %FLOW_EXT flag.
388 * @ring_cookie: RX ring/queue index to deliver to, or %RX_CLS_FLOW_DISC 409 * @ring_cookie: RX ring/queue index to deliver to, or %RX_CLS_FLOW_DISC
389 * if packets should be discarded 410 * if packets should be discarded
390 * @location: Index of filter in hardware table 411 * @location: Index of filter in hardware table
391 */ 412 */
392struct ethtool_rx_flow_spec { 413struct ethtool_rx_flow_spec {
393 __u32 flow_type; 414 __u32 flow_type;
394 union { 415 union ethtool_flow_union h_u;
395 struct ethtool_tcpip4_spec tcp_ip4_spec; 416 struct ethtool_flow_ext h_ext;
396 struct ethtool_tcpip4_spec udp_ip4_spec; 417 union ethtool_flow_union m_u;
397 struct ethtool_tcpip4_spec sctp_ip4_spec; 418 struct ethtool_flow_ext m_ext;
398 struct ethtool_ah_espip4_spec ah_ip4_spec;
399 struct ethtool_ah_espip4_spec esp_ip4_spec;
400 struct ethtool_usrip4_spec usr_ip4_spec;
401 struct ethhdr ether_spec;
402 __u8 hdata[72];
403 } h_u, m_u;
404 __u64 ring_cookie; 419 __u64 ring_cookie;
405 __u32 location; 420 __u32 location;
406}; 421};
@@ -458,16 +473,10 @@ struct ethtool_rxnfc {
458 473
459struct compat_ethtool_rx_flow_spec { 474struct compat_ethtool_rx_flow_spec {
460 u32 flow_type; 475 u32 flow_type;
461 union { 476 union ethtool_flow_union h_u;
462 struct ethtool_tcpip4_spec tcp_ip4_spec; 477 struct ethtool_flow_ext h_ext;
463 struct ethtool_tcpip4_spec udp_ip4_spec; 478 union ethtool_flow_union m_u;
464 struct ethtool_tcpip4_spec sctp_ip4_spec; 479 struct ethtool_flow_ext m_ext;
465 struct ethtool_ah_espip4_spec ah_ip4_spec;
466 struct ethtool_ah_espip4_spec esp_ip4_spec;
467 struct ethtool_usrip4_spec usr_ip4_spec;
468 struct ethhdr ether_spec;
469 u8 hdata[72];
470 } h_u, m_u;
471 compat_u64 ring_cookie; 480 compat_u64 ring_cookie;
472 u32 location; 481 u32 location;
473}; 482};
@@ -663,6 +672,22 @@ struct ethtool_rx_ntuple_list {
663 unsigned int count; 672 unsigned int count;
664}; 673};
665 674
675/**
676 * enum ethtool_phys_id_state - indicator state for physical identification
677 * @ETHTOOL_ID_INACTIVE: Physical ID indicator should be deactivated
678 * @ETHTOOL_ID_ACTIVE: Physical ID indicator should be activated
679 * @ETHTOOL_ID_ON: LED should be turned on (used iff %ETHTOOL_ID_ACTIVE
680 * is not supported)
681 * @ETHTOOL_ID_OFF: LED should be turned off (used iff %ETHTOOL_ID_ACTIVE
682 * is not supported)
683 */
684enum ethtool_phys_id_state {
685 ETHTOOL_ID_INACTIVE,
686 ETHTOOL_ID_ACTIVE,
687 ETHTOOL_ID_ON,
688 ETHTOOL_ID_OFF
689};
690
666struct net_device; 691struct net_device;
667 692
668/* Some generic methods drivers may use in their ethtool_ops */ 693/* Some generic methods drivers may use in their ethtool_ops */
@@ -683,63 +708,126 @@ void ethtool_ntuple_flush(struct net_device *dev);
683bool ethtool_invalid_flags(struct net_device *dev, u32 data, u32 supported); 708bool ethtool_invalid_flags(struct net_device *dev, u32 data, u32 supported);
684 709
685/** 710/**
686 * &ethtool_ops - Alter and report network device settings 711 * struct ethtool_ops - optional netdev operations
687 * get_settings: Get device-specific settings 712 * @get_settings: Get various device settings including Ethernet link
688 * set_settings: Set device-specific settings 713 * settings. Returns a negative error code or zero.
689 * get_drvinfo: Report driver information 714 * @set_settings: Set various device settings including Ethernet link
690 * get_regs: Get device registers 715 * settings. Returns a negative error code or zero.
691 * get_wol: Report whether Wake-on-Lan is enabled 716 * @get_drvinfo: Report driver/device information. Should only set the
692 * set_wol: Turn Wake-on-Lan on or off 717 * @driver, @version, @fw_version and @bus_info fields. If not
693 * get_msglevel: Report driver message level 718 * implemented, the @driver and @bus_info fields will be filled in
694 * set_msglevel: Set driver message level 719 * according to the netdev's parent device.
695 * nway_reset: Restart autonegotiation 720 * @get_regs_len: Get buffer length required for @get_regs
696 * get_link: Get link status 721 * @get_regs: Get device registers
697 * get_eeprom: Read data from the device EEPROM 722 * @get_wol: Report whether Wake-on-Lan is enabled
698 * set_eeprom: Write data to the device EEPROM 723 * @set_wol: Turn Wake-on-Lan on or off. Returns a negative error code
699 * get_coalesce: Get interrupt coalescing parameters 724 * or zero.
700 * set_coalesce: Set interrupt coalescing parameters 725 * @get_msglevel: Report driver message level. This should be the value
701 * get_ringparam: Report ring sizes 726 * of the @msg_enable field used by netif logging functions.
702 * set_ringparam: Set ring sizes 727 * @set_msglevel: Set driver message level
703 * get_pauseparam: Report pause parameters 728 * @nway_reset: Restart autonegotiation. Returns a negative error code
704 * set_pauseparam: Set pause parameters 729 * or zero.
705 * get_rx_csum: Report whether receive checksums are turned on or off 730 * @get_link: Report whether physical link is up. Will only be called if
706 * set_rx_csum: Turn receive checksum on or off 731 * the netdev is up. Should usually be set to ethtool_op_get_link(),
707 * get_tx_csum: Report whether transmit checksums are turned on or off 732 * which uses netif_carrier_ok().
708 * set_tx_csum: Turn transmit checksums on or off 733 * @get_eeprom: Read data from the device EEPROM.
709 * get_sg: Report whether scatter-gather is enabled
710 * set_sg: Turn scatter-gather on or off
711 * get_tso: Report whether TCP segmentation offload is enabled
712 * set_tso: Turn TCP segmentation offload on or off
713 * get_ufo: Report whether UDP fragmentation offload is enabled
714 * set_ufo: Turn UDP fragmentation offload on or off
715 * self_test: Run specified self-tests
716 * get_strings: Return a set of strings that describe the requested objects
717 * phys_id: Identify the device
718 * get_stats: Return statistics about the device
719 * get_flags: get 32-bit flags bitmap
720 * set_flags: set 32-bit flags bitmap
721 *
722 * Description:
723 *
724 * get_settings:
725 * @get_settings is passed an &ethtool_cmd to fill in. It returns
726 * an negative errno or zero.
727 *
728 * set_settings:
729 * @set_settings is passed an &ethtool_cmd and should attempt to set
730 * all the settings this device supports. It may return an error value
731 * if something goes wrong (otherwise 0).
732 *
733 * get_eeprom:
734 * Should fill in the magic field. Don't need to check len for zero 734 * Should fill in the magic field. Don't need to check len for zero
735 * or wraparound. Fill in the data argument with the eeprom values 735 * or wraparound. Fill in the data argument with the eeprom values
736 * from offset to offset + len. Update len to the amount read. 736 * from offset to offset + len. Update len to the amount read.
737 * Returns an error or zero. 737 * Returns an error or zero.
738 * 738 * @set_eeprom: Write data to the device EEPROM.
739 * set_eeprom:
740 * Should validate the magic field. Don't need to check len for zero 739 * Should validate the magic field. Don't need to check len for zero
741 * or wraparound. Update len to the amount written. Returns an error 740 * or wraparound. Update len to the amount written. Returns an error
742 * or zero. 741 * or zero.
742 * @get_coalesce: Get interrupt coalescing parameters. Returns a negative
743 * error code or zero.
744 * @set_coalesce: Set interrupt coalescing parameters. Returns a negative
745 * error code or zero.
746 * @get_ringparam: Report ring sizes
747 * @set_ringparam: Set ring sizes. Returns a negative error code or zero.
748 * @get_pauseparam: Report pause parameters
749 * @set_pauseparam: Set pause parameters. Returns a negative error code
750 * or zero.
751 * @get_rx_csum: Deprecated in favour of the netdev feature %NETIF_F_RXCSUM.
752 * Report whether receive checksums are turned on or off.
753 * @set_rx_csum: Deprecated in favour of generic netdev features. Turn
754 * receive checksum on or off. Returns a negative error code or zero.
755 * @get_tx_csum: Deprecated as redundant. Report whether transmit checksums
756 * are turned on or off.
757 * @set_tx_csum: Deprecated in favour of generic netdev features. Turn
758 * transmit checksums on or off. Returns a egative error code or zero.
759 * @get_sg: Deprecated as redundant. Report whether scatter-gather is
760 * enabled.
761 * @set_sg: Deprecated in favour of generic netdev features. Turn
762 * scatter-gather on or off. Returns a negative error code or zero.
763 * @get_tso: Deprecated as redundant. Report whether TCP segmentation
764 * offload is enabled.
765 * @set_tso: Deprecated in favour of generic netdev features. Turn TCP
766 * segmentation offload on or off. Returns a negative error code or zero.
767 * @self_test: Run specified self-tests
768 * @get_strings: Return a set of strings that describe the requested objects
769 * @set_phys_id: Identify the physical devices, e.g. by flashing an LED
770 * attached to it. The implementation may update the indicator
771 * asynchronously or synchronously, but in either case it must return
772 * quickly. It is initially called with the argument %ETHTOOL_ID_ACTIVE,
773 * and must either activate asynchronous updates or return -%EINVAL.
774 * If it returns -%EINVAL then it will be called again at intervals with
775 * argument %ETHTOOL_ID_ON or %ETHTOOL_ID_OFF and should set the state of
776 * the indicator accordingly. Finally, it is called with the argument
777 * %ETHTOOL_ID_INACTIVE and must deactivate the indicator. Returns a
778 * negative error code or zero.
779 * @phys_id: Deprecated in favour of @set_phys_id.
780 * Identify the physical device, e.g. by flashing an LED
781 * attached to it until interrupted by a signal or the given time
782 * (in seconds) elapses. If the given time is zero, use a default
783 * time limit. Returns a negative error code or zero. Being
784 * interrupted by a signal is not an error.
785 * @get_ethtool_stats: Return extended statistics about the device.
786 * This is only useful if the device maintains statistics not
787 * included in &struct rtnl_link_stats64.
788 * @begin: Function to be called before any other operation. Returns a
789 * negative error code or zero.
790 * @complete: Function to be called after any other operation except
791 * @begin. Will be called even if the other operation failed.
792 * @get_ufo: Deprecated as redundant. Report whether UDP fragmentation
793 * offload is enabled.
794 * @set_ufo: Deprecated in favour of generic netdev features. Turn UDP
795 * fragmentation offload on or off. Returns a negative error code or zero.
796 * @get_flags: Deprecated as redundant. Report features included in
797 * &enum ethtool_flags that are enabled.
798 * @set_flags: Deprecated in favour of generic netdev features. Turn
799 * features included in &enum ethtool_flags on or off. Returns a
800 * negative error code or zero.
801 * @get_priv_flags: Report driver-specific feature flags.
802 * @set_priv_flags: Set driver-specific feature flags. Returns a negative
803 * error code or zero.
804 * @get_sset_count: Get number of strings that @get_strings will write.
805 * @get_rxnfc: Get RX flow classification rules. Returns a negative
806 * error code or zero.
807 * @set_rxnfc: Set RX flow classification rules. Returns a negative
808 * error code or zero.
809 * @flash_device: Write a firmware image to device's flash memory.
810 * Returns a negative error code or zero.
811 * @reset: Reset (part of) the device, as specified by a bitmask of
812 * flags from &enum ethtool_reset_flags. Returns a negative
813 * error code or zero.
814 * @set_rx_ntuple: Set an RX n-tuple rule. Returns a negative error code
815 * or zero.
816 * @get_rx_ntuple: Deprecated.
817 * @get_rxfh_indir: Get the contents of the RX flow hash indirection table.
818 * Returns a negative error code or zero.
819 * @set_rxfh_indir: Set the contents of the RX flow hash indirection table.
820 * Returns a negative error code or zero.
821 *
822 * All operations are optional (i.e. the function pointer may be set
823 * to %NULL) and callers must take this into account. Callers must
824 * hold the RTNL, except that for @get_drvinfo the caller may or may
825 * not hold the RTNL.
826 *
827 * See the structures used by these operations for further documentation.
828 *
829 * See &struct net_device and &struct net_device_ops for documentation
830 * of the generic netdev features interface.
743 */ 831 */
744struct ethtool_ops { 832struct ethtool_ops {
745 int (*get_settings)(struct net_device *, struct ethtool_cmd *); 833 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
@@ -778,6 +866,7 @@ struct ethtool_ops {
778 int (*set_tso)(struct net_device *, u32); 866 int (*set_tso)(struct net_device *, u32);
779 void (*self_test)(struct net_device *, struct ethtool_test *, u64 *); 867 void (*self_test)(struct net_device *, struct ethtool_test *, u64 *);
780 void (*get_strings)(struct net_device *, u32 stringset, u8 *); 868 void (*get_strings)(struct net_device *, u32 stringset, u8 *);
869 int (*set_phys_id)(struct net_device *, enum ethtool_phys_id_state);
781 int (*phys_id)(struct net_device *, u32); 870 int (*phys_id)(struct net_device *, u32);
782 void (*get_ethtool_stats)(struct net_device *, 871 void (*get_ethtool_stats)(struct net_device *,
783 struct ethtool_stats *, u64 *); 872 struct ethtool_stats *, u64 *);
@@ -992,6 +1081,8 @@ struct ethtool_ops {
992#define IPV4_FLOW 0x10 /* hash only */ 1081#define IPV4_FLOW 0x10 /* hash only */
993#define IPV6_FLOW 0x11 /* hash only */ 1082#define IPV6_FLOW 0x11 /* hash only */
994#define ETHER_FLOW 0x12 /* spec only (ether_spec) */ 1083#define ETHER_FLOW 0x12 /* spec only (ether_spec) */
1084/* Flag to enable additional fields in struct ethtool_rx_flow_spec */
1085#define FLOW_EXT 0x80000000
995 1086
996/* L3-L4 network traffic flow hash options */ 1087/* L3-L4 network traffic flow hash options */
997#define RXH_L2DA (1 << 1) 1088#define RXH_L2DA (1 << 1)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 0249fe7e387..09d26241576 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1066,6 +1066,7 @@ struct net_device {
1066#define NETIF_F_NTUPLE (1 << 27) /* N-tuple filters supported */ 1066#define NETIF_F_NTUPLE (1 << 27) /* N-tuple filters supported */
1067#define NETIF_F_RXHASH (1 << 28) /* Receive hashing offload */ 1067#define NETIF_F_RXHASH (1 << 28) /* Receive hashing offload */
1068#define NETIF_F_RXCSUM (1 << 29) /* Receive checksumming offload */ 1068#define NETIF_F_RXCSUM (1 << 29) /* Receive checksumming offload */
1069#define NETIF_F_NOCACHE_COPY (1 << 30) /* Use no-cache copyfromuser */
1069 1070
1070 /* Segmentation offload features */ 1071 /* Segmentation offload features */
1071#define NETIF_F_GSO_SHIFT 16 1072#define NETIF_F_GSO_SHIFT 16
@@ -1081,7 +1082,7 @@ struct net_device {
1081 /* = all defined minus driver/device-class-related */ 1082 /* = all defined minus driver/device-class-related */
1082#define NETIF_F_NEVER_CHANGE (NETIF_F_HIGHDMA | NETIF_F_VLAN_CHALLENGED | \ 1083#define NETIF_F_NEVER_CHANGE (NETIF_F_HIGHDMA | NETIF_F_VLAN_CHALLENGED | \
1083 NETIF_F_LLTX | NETIF_F_NETNS_LOCAL) 1084 NETIF_F_LLTX | NETIF_F_NETNS_LOCAL)
1084#define NETIF_F_ETHTOOL_BITS (0x3f3fffff & ~NETIF_F_NEVER_CHANGE) 1085#define NETIF_F_ETHTOOL_BITS (0x7f3fffff & ~NETIF_F_NEVER_CHANGE)
1085 1086
1086 /* List of features with software fallbacks. */ 1087 /* List of features with software fallbacks. */
1087#define NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | \ 1088#define NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | \
@@ -2550,6 +2551,7 @@ static inline u32 netdev_get_wanted_features(struct net_device *dev)
2550} 2551}
2551u32 netdev_increment_features(u32 all, u32 one, u32 mask); 2552u32 netdev_increment_features(u32 all, u32 one, u32 mask);
2552u32 netdev_fix_features(struct net_device *dev, u32 features); 2553u32 netdev_fix_features(struct net_device *dev, u32 features);
2554int __netdev_update_features(struct net_device *dev);
2553void netdev_update_features(struct net_device *dev); 2555void netdev_update_features(struct net_device *dev);
2554 2556
2555void netif_stacked_transfer_operstate(const struct net_device *rootdev, 2557void netif_stacked_transfer_operstate(const struct net_device *rootdev,
diff --git a/include/linux/pkt_sched.h b/include/linux/pkt_sched.h
index 3a02e020857..c5336705921 100644
--- a/include/linux/pkt_sched.h
+++ b/include/linux/pkt_sched.h
@@ -588,4 +588,19 @@ struct tc_sfb_xstats {
588 588
589#define SFB_MAX_PROB 0xFFFF 589#define SFB_MAX_PROB 0xFFFF
590 590
591/* QFQ */
592enum {
593 TCA_QFQ_UNSPEC,
594 TCA_QFQ_WEIGHT,
595 TCA_QFQ_LMAX,
596 __TCA_QFQ_MAX
597};
598
599#define TCA_QFQ_MAX (__TCA_QFQ_MAX - 1)
600
601struct tc_qfq_stats {
602 __u32 weight;
603 __u32 lmax;
604};
605
591#endif 606#endif
diff --git a/include/net/flow.h b/include/net/flow.h
index 7fe5a0f9483..c6d5fe5ec1b 100644
--- a/include/net/flow.h
+++ b/include/net/flow.h
@@ -26,8 +26,8 @@ struct flowi_common {
26 26
27union flowi_uli { 27union flowi_uli {
28 struct { 28 struct {
29 __be16 sport;
30 __be16 dport; 29 __be16 dport;
30 __be16 sport;
31 } ports; 31 } ports;
32 32
33 struct { 33 struct {
@@ -36,8 +36,8 @@ union flowi_uli {
36 } icmpt; 36 } icmpt;
37 37
38 struct { 38 struct {
39 __le16 sport;
40 __le16 dport; 39 __le16 dport;
40 __le16 sport;
41 } dnports; 41 } dnports;
42 42
43 __be32 spi; 43 __be32 spi;
@@ -70,6 +70,27 @@ struct flowi4 {
70#define fl4_gre_key uli.gre_key 70#define fl4_gre_key uli.gre_key
71}; 71};
72 72
73static inline void flowi4_init_output(struct flowi4 *fl4, int oif,
74 __u32 mark, __u8 tos, __u8 scope,
75 __u8 proto, __u8 flags,
76 __be32 daddr, __be32 saddr,
77 __be16 dport, __be32 sport)
78{
79 fl4->flowi4_oif = oif;
80 fl4->flowi4_iif = 0;
81 fl4->flowi4_mark = mark;
82 fl4->flowi4_tos = tos;
83 fl4->flowi4_scope = scope;
84 fl4->flowi4_proto = proto;
85 fl4->flowi4_flags = flags;
86 fl4->flowi4_secid = 0;
87 fl4->daddr = daddr;
88 fl4->saddr = saddr;
89 fl4->fl4_dport = dport;
90 fl4->fl4_sport = sport;
91}
92
93
73struct flowi6 { 94struct flowi6 {
74 struct flowi_common __fl_common; 95 struct flowi_common __fl_common;
75#define flowi6_oif __fl_common.flowic_oif 96#define flowi6_oif __fl_common.flowic_oif
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index e5d66ec88cf..514627f5633 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -227,9 +227,9 @@ extern struct fib_table *fib_get_table(struct net *net, u32 id);
227/* Exported by fib_frontend.c */ 227/* Exported by fib_frontend.c */
228extern const struct nla_policy rtm_ipv4_policy[]; 228extern const struct nla_policy rtm_ipv4_policy[];
229extern void ip_fib_init(void); 229extern void ip_fib_init(void);
230extern int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif, 230extern int fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
231 struct net_device *dev, __be32 *spec_dst, 231 u8 tos, int oif, struct net_device *dev,
232 u32 *itag, u32 mark); 232 __be32 *spec_dst, u32 *itag);
233extern void fib_select_default(struct fib_result *res); 233extern void fib_select_default(struct fib_result *res);
234 234
235/* Exported by fib_semantics.c */ 235/* Exported by fib_semantics.c */
diff --git a/include/net/route.h b/include/net/route.h
index 8fce0621cad..3782cddd138 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -150,17 +150,12 @@ static inline struct rtable *ip_route_output_ports(struct net *net, struct sock
150 __be16 dport, __be16 sport, 150 __be16 dport, __be16 sport,
151 __u8 proto, __u8 tos, int oif) 151 __u8 proto, __u8 tos, int oif)
152{ 152{
153 struct flowi4 fl4 = { 153 struct flowi4 fl4;
154 .flowi4_oif = oif, 154
155 .flowi4_flags = sk ? inet_sk_flowi_flags(sk) : 0, 155 flowi4_init_output(&fl4, oif, sk ? sk->sk_mark : 0, tos,
156 .flowi4_mark = sk ? sk->sk_mark : 0, 156 RT_SCOPE_UNIVERSE, proto,
157 .daddr = daddr, 157 sk ? inet_sk_flowi_flags(sk) : 0,
158 .saddr = saddr, 158 daddr, saddr, dport, sport);
159 .flowi4_tos = tos,
160 .flowi4_proto = proto,
161 .fl4_dport = dport,
162 .fl4_sport = sport,
163 };
164 if (sk) 159 if (sk)
165 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4)); 160 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4));
166 return ip_route_output_flow(net, &fl4, sk); 161 return ip_route_output_flow(net, &fl4, sk);
@@ -230,25 +225,21 @@ static inline struct rtable *ip_route_connect(__be32 dst, __be32 src, u32 tos,
230 __be16 sport, __be16 dport, 225 __be16 sport, __be16 dport,
231 struct sock *sk, bool can_sleep) 226 struct sock *sk, bool can_sleep)
232{ 227{
233 struct flowi4 fl4 = {
234 .flowi4_oif = oif,
235 .flowi4_mark = sk->sk_mark,
236 .daddr = dst,
237 .saddr = src,
238 .flowi4_tos = tos,
239 .flowi4_proto = protocol,
240 .fl4_sport = sport,
241 .fl4_dport = dport,
242 };
243 struct net *net = sock_net(sk); 228 struct net *net = sock_net(sk);
244 struct rtable *rt; 229 struct rtable *rt;
230 struct flowi4 fl4;
231 __u8 flow_flags;
245 232
233 flow_flags = 0;
246 if (inet_sk(sk)->transparent) 234 if (inet_sk(sk)->transparent)
247 fl4.flowi4_flags |= FLOWI_FLAG_ANYSRC; 235 flow_flags |= FLOWI_FLAG_ANYSRC;
248 if (protocol == IPPROTO_TCP) 236 if (protocol == IPPROTO_TCP)
249 fl4.flowi4_flags |= FLOWI_FLAG_PRECOW_METRICS; 237 flow_flags |= FLOWI_FLAG_PRECOW_METRICS;
250 if (can_sleep) 238 if (can_sleep)
251 fl4.flowi4_flags |= FLOWI_FLAG_CAN_SLEEP; 239 flow_flags |= FLOWI_FLAG_CAN_SLEEP;
240
241 flowi4_init_output(&fl4, oif, sk->sk_mark, tos, RT_SCOPE_UNIVERSE,
242 protocol, flow_flags, dst, src, dport, sport);
252 243
253 if (!dst || !src) { 244 if (!dst || !src) {
254 rt = __ip_route_output_key(net, &fl4); 245 rt = __ip_route_output_key(net, &fl4);
@@ -268,20 +259,17 @@ static inline struct rtable *ip_route_newports(struct rtable *rt,
268 __be16 dport, struct sock *sk) 259 __be16 dport, struct sock *sk)
269{ 260{
270 if (sport != orig_sport || dport != orig_dport) { 261 if (sport != orig_sport || dport != orig_dport) {
271 struct flowi4 fl4 = { 262 struct flowi4 fl4;
272 .flowi4_oif = rt->rt_oif, 263 __u8 flow_flags;
273 .flowi4_mark = rt->rt_mark, 264
274 .daddr = rt->rt_dst, 265 flow_flags = 0;
275 .saddr = rt->rt_src,
276 .flowi4_tos = rt->rt_tos,
277 .flowi4_proto = protocol,
278 .fl4_sport = sport,
279 .fl4_dport = dport
280 };
281 if (inet_sk(sk)->transparent) 266 if (inet_sk(sk)->transparent)
282 fl4.flowi4_flags |= FLOWI_FLAG_ANYSRC; 267 flow_flags |= FLOWI_FLAG_ANYSRC;
283 if (protocol == IPPROTO_TCP) 268 if (protocol == IPPROTO_TCP)
284 fl4.flowi4_flags |= FLOWI_FLAG_PRECOW_METRICS; 269 flow_flags |= FLOWI_FLAG_PRECOW_METRICS;
270 flowi4_init_output(&fl4, rt->rt_oif, rt->rt_mark, rt->rt_tos,
271 RT_SCOPE_UNIVERSE, protocol, flow_flags,
272 rt->rt_dst, rt->rt_src, dport, sport);
285 ip_rt_put(rt); 273 ip_rt_put(rt);
286 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4)); 274 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4));
287 return ip_route_output_flow(sock_net(sk), &fl4, sk); 275 return ip_route_output_flow(sock_net(sk), &fl4, sk);
diff --git a/include/net/sock.h b/include/net/sock.h
index 01810a3f19d..f2046e404a6 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -52,6 +52,7 @@
52#include <linux/mm.h> 52#include <linux/mm.h>
53#include <linux/security.h> 53#include <linux/security.h>
54#include <linux/slab.h> 54#include <linux/slab.h>
55#include <linux/uaccess.h>
55 56
56#include <linux/filter.h> 57#include <linux/filter.h>
57#include <linux/rculist_nulls.h> 58#include <linux/rculist_nulls.h>
@@ -1389,6 +1390,59 @@ static inline void sk_nocaps_add(struct sock *sk, int flags)
1389 sk->sk_route_caps &= ~flags; 1390 sk->sk_route_caps &= ~flags;
1390} 1391}
1391 1392
1393static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
1394 char __user *from, char *to,
1395 int copy, int offset)
1396{
1397 if (skb->ip_summed == CHECKSUM_NONE) {
1398 int err = 0;
1399 __wsum csum = csum_and_copy_from_user(from, to, copy, 0, &err);
1400 if (err)
1401 return err;
1402 skb->csum = csum_block_add(skb->csum, csum, offset);
1403 } else if (sk->sk_route_caps & NETIF_F_NOCACHE_COPY) {
1404 if (!access_ok(VERIFY_READ, from, copy) ||
1405 __copy_from_user_nocache(to, from, copy))
1406 return -EFAULT;
1407 } else if (copy_from_user(to, from, copy))
1408 return -EFAULT;
1409
1410 return 0;
1411}
1412
1413static inline int skb_add_data_nocache(struct sock *sk, struct sk_buff *skb,
1414 char __user *from, int copy)
1415{
1416 int err, offset = skb->len;
1417
1418 err = skb_do_copy_data_nocache(sk, skb, from, skb_put(skb, copy),
1419 copy, offset);
1420 if (err)
1421 __skb_trim(skb, offset);
1422
1423 return err;
1424}
1425
1426static inline int skb_copy_to_page_nocache(struct sock *sk, char __user *from,
1427 struct sk_buff *skb,
1428 struct page *page,
1429 int off, int copy)
1430{
1431 int err;
1432
1433 err = skb_do_copy_data_nocache(sk, skb, from, page_address(page) + off,
1434 copy, skb->len);
1435 if (err)
1436 return err;
1437
1438 skb->len += copy;
1439 skb->data_len += copy;
1440 skb->truesize += copy;
1441 sk->sk_wmem_queued += copy;
1442 sk_mem_charge(sk, copy);
1443 return 0;
1444}
1445
1392static inline int skb_copy_to_page(struct sock *sk, char __user *from, 1446static inline int skb_copy_to_page(struct sock *sk, char __user *from,
1393 struct sk_buff *skb, struct page *page, 1447 struct sk_buff *skb, struct page *page,
1394 int off, int copy) 1448 int off, int copy)
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 6ae4bc5ce8a..65ea3134863 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -957,6 +957,15 @@ struct sec_path {
957 struct xfrm_state *xvec[XFRM_MAX_DEPTH]; 957 struct xfrm_state *xvec[XFRM_MAX_DEPTH];
958}; 958};
959 959
960static inline int secpath_exists(struct sk_buff *skb)
961{
962#ifdef CONFIG_XFRM
963 return skb->sp != NULL;
964#else
965 return 0;
966#endif
967}
968
960static inline struct sec_path * 969static inline struct sec_path *
961secpath_get(struct sec_path *sp) 970secpath_get(struct sec_path *sp)
962{ 971{