diff options
121 files changed, 1064 insertions, 450 deletions
diff --git a/Documentation/devicetree/bindings/net/ethernet.txt b/Documentation/devicetree/bindings/net/ethernet.txt index e1d76812419c..05150957ecfd 100644 --- a/Documentation/devicetree/bindings/net/ethernet.txt +++ b/Documentation/devicetree/bindings/net/ethernet.txt | |||
@@ -9,10 +9,26 @@ The following properties are common to the Ethernet controllers: | |||
9 | - max-speed: number, specifies maximum speed in Mbit/s supported by the device; | 9 | - max-speed: number, specifies maximum speed in Mbit/s supported by the device; |
10 | - max-frame-size: number, maximum transfer unit (IEEE defined MTU), rather than | 10 | - max-frame-size: number, maximum transfer unit (IEEE defined MTU), rather than |
11 | the maximum frame size (there's contradiction in ePAPR). | 11 | the maximum frame size (there's contradiction in ePAPR). |
12 | - phy-mode: string, operation mode of the PHY interface; supported values are | 12 | - phy-mode: string, operation mode of the PHY interface. This is now a de-facto |
13 | "mii", "gmii", "sgmii", "qsgmii", "tbi", "rev-mii", "rmii", "rgmii", "rgmii-id", | 13 | standard property; supported values are: |
14 | "rgmii-rxid", "rgmii-txid", "rtbi", "smii", "xgmii", "trgmii"; this is now a | 14 | * "mii" |
15 | de-facto standard property; | 15 | * "gmii" |
16 | * "sgmii" | ||
17 | * "qsgmii" | ||
18 | * "tbi" | ||
19 | * "rev-mii" | ||
20 | * "rmii" | ||
21 | * "rgmii" (RX and TX delays are added by the MAC when required) | ||
22 | * "rgmii-id" (RGMII with internal RX and TX delays provided by the PHY, the | ||
23 | MAC should not add the RX or TX delays in this case) | ||
24 | * "rgmii-rxid" (RGMII with internal RX delay provided by the PHY, the MAC | ||
25 | should not add an RX delay in this case) | ||
26 | * "rgmii-txid" (RGMII with internal TX delay provided by the PHY, the MAC | ||
27 | should not add an TX delay in this case) | ||
28 | * "rtbi" | ||
29 | * "smii" | ||
30 | * "xgmii" | ||
31 | * "trgmii" | ||
16 | - phy-connection-type: the same as "phy-mode" property but described in ePAPR; | 32 | - phy-connection-type: the same as "phy-mode" property but described in ePAPR; |
17 | - phy-handle: phandle, specifies a reference to a node representing a PHY | 33 | - phy-handle: phandle, specifies a reference to a node representing a PHY |
18 | device; this property is described in ePAPR and so preferred; | 34 | device; this property is described in ePAPR and so preferred; |
diff --git a/Documentation/networking/nf_conntrack-sysctl.txt b/Documentation/networking/nf_conntrack-sysctl.txt index 399e4e866a9c..433b6724797a 100644 --- a/Documentation/networking/nf_conntrack-sysctl.txt +++ b/Documentation/networking/nf_conntrack-sysctl.txt | |||
@@ -62,10 +62,13 @@ nf_conntrack_generic_timeout - INTEGER (seconds) | |||
62 | protocols. | 62 | protocols. |
63 | 63 | ||
64 | nf_conntrack_helper - BOOLEAN | 64 | nf_conntrack_helper - BOOLEAN |
65 | 0 - disabled | 65 | 0 - disabled (default) |
66 | not 0 - enabled (default) | 66 | not 0 - enabled |
67 | 67 | ||
68 | Enable automatic conntrack helper assignment. | 68 | Enable automatic conntrack helper assignment. |
69 | If disabled it is required to set up iptables rules to assign | ||
70 | helpers to connections. See the CT target description in the | ||
71 | iptables-extensions(8) man page for further information. | ||
69 | 72 | ||
70 | nf_conntrack_icmp_timeout - INTEGER (seconds) | 73 | nf_conntrack_icmp_timeout - INTEGER (seconds) |
71 | default 30 | 74 | default 30 |
diff --git a/drivers/net/can/usb/peak_usb/pcan_ucan.h b/drivers/net/can/usb/peak_usb/pcan_ucan.h index e8fc4952c6b0..2147678f0225 100644 --- a/drivers/net/can/usb/peak_usb/pcan_ucan.h +++ b/drivers/net/can/usb/peak_usb/pcan_ucan.h | |||
@@ -43,11 +43,22 @@ struct __packed pucan_command { | |||
43 | u16 args[3]; | 43 | u16 args[3]; |
44 | }; | 44 | }; |
45 | 45 | ||
46 | #define PUCAN_TSLOW_BRP_BITS 10 | ||
47 | #define PUCAN_TSLOW_TSGEG1_BITS 8 | ||
48 | #define PUCAN_TSLOW_TSGEG2_BITS 7 | ||
49 | #define PUCAN_TSLOW_SJW_BITS 7 | ||
50 | |||
51 | #define PUCAN_TSLOW_BRP_MASK ((1 << PUCAN_TSLOW_BRP_BITS) - 1) | ||
52 | #define PUCAN_TSLOW_TSEG1_MASK ((1 << PUCAN_TSLOW_TSGEG1_BITS) - 1) | ||
53 | #define PUCAN_TSLOW_TSEG2_MASK ((1 << PUCAN_TSLOW_TSGEG2_BITS) - 1) | ||
54 | #define PUCAN_TSLOW_SJW_MASK ((1 << PUCAN_TSLOW_SJW_BITS) - 1) | ||
55 | |||
46 | /* uCAN TIMING_SLOW command fields */ | 56 | /* uCAN TIMING_SLOW command fields */ |
47 | #define PUCAN_TSLOW_SJW_T(s, t) (((s) & 0xf) | ((!!(t)) << 7)) | 57 | #define PUCAN_TSLOW_SJW_T(s, t) (((s) & PUCAN_TSLOW_SJW_MASK) | \ |
48 | #define PUCAN_TSLOW_TSEG2(t) ((t) & 0xf) | 58 | ((!!(t)) << 7)) |
49 | #define PUCAN_TSLOW_TSEG1(t) ((t) & 0x3f) | 59 | #define PUCAN_TSLOW_TSEG2(t) ((t) & PUCAN_TSLOW_TSEG2_MASK) |
50 | #define PUCAN_TSLOW_BRP(b) ((b) & 0x3ff) | 60 | #define PUCAN_TSLOW_TSEG1(t) ((t) & PUCAN_TSLOW_TSEG1_MASK) |
61 | #define PUCAN_TSLOW_BRP(b) ((b) & PUCAN_TSLOW_BRP_MASK) | ||
51 | 62 | ||
52 | struct __packed pucan_timing_slow { | 63 | struct __packed pucan_timing_slow { |
53 | __le16 opcode_channel; | 64 | __le16 opcode_channel; |
@@ -60,11 +71,21 @@ struct __packed pucan_timing_slow { | |||
60 | __le16 brp; /* BaudRate Prescaler */ | 71 | __le16 brp; /* BaudRate Prescaler */ |
61 | }; | 72 | }; |
62 | 73 | ||
74 | #define PUCAN_TFAST_BRP_BITS 10 | ||
75 | #define PUCAN_TFAST_TSGEG1_BITS 5 | ||
76 | #define PUCAN_TFAST_TSGEG2_BITS 4 | ||
77 | #define PUCAN_TFAST_SJW_BITS 4 | ||
78 | |||
79 | #define PUCAN_TFAST_BRP_MASK ((1 << PUCAN_TFAST_BRP_BITS) - 1) | ||
80 | #define PUCAN_TFAST_TSEG1_MASK ((1 << PUCAN_TFAST_TSGEG1_BITS) - 1) | ||
81 | #define PUCAN_TFAST_TSEG2_MASK ((1 << PUCAN_TFAST_TSGEG2_BITS) - 1) | ||
82 | #define PUCAN_TFAST_SJW_MASK ((1 << PUCAN_TFAST_SJW_BITS) - 1) | ||
83 | |||
63 | /* uCAN TIMING_FAST command fields */ | 84 | /* uCAN TIMING_FAST command fields */ |
64 | #define PUCAN_TFAST_SJW(s) ((s) & 0x3) | 85 | #define PUCAN_TFAST_SJW(s) ((s) & PUCAN_TFAST_SJW_MASK) |
65 | #define PUCAN_TFAST_TSEG2(t) ((t) & 0x7) | 86 | #define PUCAN_TFAST_TSEG2(t) ((t) & PUCAN_TFAST_TSEG2_MASK) |
66 | #define PUCAN_TFAST_TSEG1(t) ((t) & 0xf) | 87 | #define PUCAN_TFAST_TSEG1(t) ((t) & PUCAN_TFAST_TSEG1_MASK) |
67 | #define PUCAN_TFAST_BRP(b) ((b) & 0x3ff) | 88 | #define PUCAN_TFAST_BRP(b) ((b) & PUCAN_TFAST_BRP_MASK) |
68 | 89 | ||
69 | struct __packed pucan_timing_fast { | 90 | struct __packed pucan_timing_fast { |
70 | __le16 opcode_channel; | 91 | __le16 opcode_channel; |
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c index c06382cdfdfe..f3141ca56bc3 100644 --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c | |||
@@ -39,6 +39,7 @@ static struct usb_device_id peak_usb_table[] = { | |||
39 | {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPRO_PRODUCT_ID)}, | 39 | {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPRO_PRODUCT_ID)}, |
40 | {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBFD_PRODUCT_ID)}, | 40 | {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBFD_PRODUCT_ID)}, |
41 | {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPROFD_PRODUCT_ID)}, | 41 | {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPROFD_PRODUCT_ID)}, |
42 | {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBX6_PRODUCT_ID)}, | ||
42 | {} /* Terminating entry */ | 43 | {} /* Terminating entry */ |
43 | }; | 44 | }; |
44 | 45 | ||
@@ -50,6 +51,7 @@ static const struct peak_usb_adapter *const peak_usb_adapters_list[] = { | |||
50 | &pcan_usb_pro, | 51 | &pcan_usb_pro, |
51 | &pcan_usb_fd, | 52 | &pcan_usb_fd, |
52 | &pcan_usb_pro_fd, | 53 | &pcan_usb_pro_fd, |
54 | &pcan_usb_x6, | ||
53 | }; | 55 | }; |
54 | 56 | ||
55 | /* | 57 | /* |
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.h b/drivers/net/can/usb/peak_usb/pcan_usb_core.h index 506fe506c9d3..3cbfb069893d 100644 --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.h +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.h | |||
@@ -27,6 +27,7 @@ | |||
27 | #define PCAN_USBPRO_PRODUCT_ID 0x000d | 27 | #define PCAN_USBPRO_PRODUCT_ID 0x000d |
28 | #define PCAN_USBPROFD_PRODUCT_ID 0x0011 | 28 | #define PCAN_USBPROFD_PRODUCT_ID 0x0011 |
29 | #define PCAN_USBFD_PRODUCT_ID 0x0012 | 29 | #define PCAN_USBFD_PRODUCT_ID 0x0012 |
30 | #define PCAN_USBX6_PRODUCT_ID 0x0014 | ||
30 | 31 | ||
31 | #define PCAN_USB_DRIVER_NAME "peak_usb" | 32 | #define PCAN_USB_DRIVER_NAME "peak_usb" |
32 | 33 | ||
@@ -90,6 +91,7 @@ extern const struct peak_usb_adapter pcan_usb; | |||
90 | extern const struct peak_usb_adapter pcan_usb_pro; | 91 | extern const struct peak_usb_adapter pcan_usb_pro; |
91 | extern const struct peak_usb_adapter pcan_usb_fd; | 92 | extern const struct peak_usb_adapter pcan_usb_fd; |
92 | extern const struct peak_usb_adapter pcan_usb_pro_fd; | 93 | extern const struct peak_usb_adapter pcan_usb_pro_fd; |
94 | extern const struct peak_usb_adapter pcan_usb_x6; | ||
93 | 95 | ||
94 | struct peak_time_ref { | 96 | struct peak_time_ref { |
95 | struct timeval tv_host_0, tv_host; | 97 | struct timeval tv_host_0, tv_host; |
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c index ce44a033f63b..304732550f0a 100644 --- a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c +++ b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c | |||
@@ -993,24 +993,24 @@ static void pcan_usb_fd_free(struct peak_usb_device *dev) | |||
993 | static const struct can_bittiming_const pcan_usb_fd_const = { | 993 | static const struct can_bittiming_const pcan_usb_fd_const = { |
994 | .name = "pcan_usb_fd", | 994 | .name = "pcan_usb_fd", |
995 | .tseg1_min = 1, | 995 | .tseg1_min = 1, |
996 | .tseg1_max = 64, | 996 | .tseg1_max = (1 << PUCAN_TSLOW_TSGEG1_BITS), |
997 | .tseg2_min = 1, | 997 | .tseg2_min = 1, |
998 | .tseg2_max = 16, | 998 | .tseg2_max = (1 << PUCAN_TSLOW_TSGEG2_BITS), |
999 | .sjw_max = 16, | 999 | .sjw_max = (1 << PUCAN_TSLOW_SJW_BITS), |
1000 | .brp_min = 1, | 1000 | .brp_min = 1, |
1001 | .brp_max = 1024, | 1001 | .brp_max = (1 << PUCAN_TSLOW_BRP_BITS), |
1002 | .brp_inc = 1, | 1002 | .brp_inc = 1, |
1003 | }; | 1003 | }; |
1004 | 1004 | ||
1005 | static const struct can_bittiming_const pcan_usb_fd_data_const = { | 1005 | static const struct can_bittiming_const pcan_usb_fd_data_const = { |
1006 | .name = "pcan_usb_fd", | 1006 | .name = "pcan_usb_fd", |
1007 | .tseg1_min = 1, | 1007 | .tseg1_min = 1, |
1008 | .tseg1_max = 16, | 1008 | .tseg1_max = (1 << PUCAN_TFAST_TSGEG1_BITS), |
1009 | .tseg2_min = 1, | 1009 | .tseg2_min = 1, |
1010 | .tseg2_max = 8, | 1010 | .tseg2_max = (1 << PUCAN_TFAST_TSGEG2_BITS), |
1011 | .sjw_max = 4, | 1011 | .sjw_max = (1 << PUCAN_TFAST_SJW_BITS), |
1012 | .brp_min = 1, | 1012 | .brp_min = 1, |
1013 | .brp_max = 1024, | 1013 | .brp_max = (1 << PUCAN_TFAST_BRP_BITS), |
1014 | .brp_inc = 1, | 1014 | .brp_inc = 1, |
1015 | }; | 1015 | }; |
1016 | 1016 | ||
@@ -1065,24 +1065,24 @@ const struct peak_usb_adapter pcan_usb_fd = { | |||
1065 | static const struct can_bittiming_const pcan_usb_pro_fd_const = { | 1065 | static const struct can_bittiming_const pcan_usb_pro_fd_const = { |
1066 | .name = "pcan_usb_pro_fd", | 1066 | .name = "pcan_usb_pro_fd", |
1067 | .tseg1_min = 1, | 1067 | .tseg1_min = 1, |
1068 | .tseg1_max = 64, | 1068 | .tseg1_max = (1 << PUCAN_TSLOW_TSGEG1_BITS), |
1069 | .tseg2_min = 1, | 1069 | .tseg2_min = 1, |
1070 | .tseg2_max = 16, | 1070 | .tseg2_max = (1 << PUCAN_TSLOW_TSGEG2_BITS), |
1071 | .sjw_max = 16, | 1071 | .sjw_max = (1 << PUCAN_TSLOW_SJW_BITS), |
1072 | .brp_min = 1, | 1072 | .brp_min = 1, |
1073 | .brp_max = 1024, | 1073 | .brp_max = (1 << PUCAN_TSLOW_BRP_BITS), |
1074 | .brp_inc = 1, | 1074 | .brp_inc = 1, |
1075 | }; | 1075 | }; |
1076 | 1076 | ||
1077 | static const struct can_bittiming_const pcan_usb_pro_fd_data_const = { | 1077 | static const struct can_bittiming_const pcan_usb_pro_fd_data_const = { |
1078 | .name = "pcan_usb_pro_fd", | 1078 | .name = "pcan_usb_pro_fd", |
1079 | .tseg1_min = 1, | 1079 | .tseg1_min = 1, |
1080 | .tseg1_max = 16, | 1080 | .tseg1_max = (1 << PUCAN_TFAST_TSGEG1_BITS), |
1081 | .tseg2_min = 1, | 1081 | .tseg2_min = 1, |
1082 | .tseg2_max = 8, | 1082 | .tseg2_max = (1 << PUCAN_TFAST_TSGEG2_BITS), |
1083 | .sjw_max = 4, | 1083 | .sjw_max = (1 << PUCAN_TFAST_SJW_BITS), |
1084 | .brp_min = 1, | 1084 | .brp_min = 1, |
1085 | .brp_max = 1024, | 1085 | .brp_max = (1 << PUCAN_TFAST_BRP_BITS), |
1086 | .brp_inc = 1, | 1086 | .brp_inc = 1, |
1087 | }; | 1087 | }; |
1088 | 1088 | ||
@@ -1132,3 +1132,75 @@ const struct peak_usb_adapter pcan_usb_pro_fd = { | |||
1132 | 1132 | ||
1133 | .do_get_berr_counter = pcan_usb_fd_get_berr_counter, | 1133 | .do_get_berr_counter = pcan_usb_fd_get_berr_counter, |
1134 | }; | 1134 | }; |
1135 | |||
1136 | /* describes the PCAN-USB X6 adapter */ | ||
1137 | static const struct can_bittiming_const pcan_usb_x6_const = { | ||
1138 | .name = "pcan_usb_x6", | ||
1139 | .tseg1_min = 1, | ||
1140 | .tseg1_max = (1 << PUCAN_TSLOW_TSGEG1_BITS), | ||
1141 | .tseg2_min = 1, | ||
1142 | .tseg2_max = (1 << PUCAN_TSLOW_TSGEG2_BITS), | ||
1143 | .sjw_max = (1 << PUCAN_TSLOW_SJW_BITS), | ||
1144 | .brp_min = 1, | ||
1145 | .brp_max = (1 << PUCAN_TSLOW_BRP_BITS), | ||
1146 | .brp_inc = 1, | ||
1147 | }; | ||
1148 | |||
1149 | static const struct can_bittiming_const pcan_usb_x6_data_const = { | ||
1150 | .name = "pcan_usb_x6", | ||
1151 | .tseg1_min = 1, | ||
1152 | .tseg1_max = (1 << PUCAN_TFAST_TSGEG1_BITS), | ||
1153 | .tseg2_min = 1, | ||
1154 | .tseg2_max = (1 << PUCAN_TFAST_TSGEG2_BITS), | ||
1155 | .sjw_max = (1 << PUCAN_TFAST_SJW_BITS), | ||
1156 | .brp_min = 1, | ||
1157 | .brp_max = (1 << PUCAN_TFAST_BRP_BITS), | ||
1158 | .brp_inc = 1, | ||
1159 | }; | ||
1160 | |||
1161 | const struct peak_usb_adapter pcan_usb_x6 = { | ||
1162 | .name = "PCAN-USB X6", | ||
1163 | .device_id = PCAN_USBX6_PRODUCT_ID, | ||
1164 | .ctrl_count = PCAN_USBPROFD_CHANNEL_COUNT, | ||
1165 | .ctrlmode_supported = CAN_CTRLMODE_FD | | ||
1166 | CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_LISTENONLY, | ||
1167 | .clock = { | ||
1168 | .freq = PCAN_UFD_CRYSTAL_HZ, | ||
1169 | }, | ||
1170 | .bittiming_const = &pcan_usb_x6_const, | ||
1171 | .data_bittiming_const = &pcan_usb_x6_data_const, | ||
1172 | |||
1173 | /* size of device private data */ | ||
1174 | .sizeof_dev_private = sizeof(struct pcan_usb_fd_device), | ||
1175 | |||
1176 | /* timestamps usage */ | ||
1177 | .ts_used_bits = 32, | ||
1178 | .ts_period = 1000000, /* calibration period in ts. */ | ||
1179 | .us_per_ts_scale = 1, /* us = (ts * scale) >> shift */ | ||
1180 | .us_per_ts_shift = 0, | ||
1181 | |||
1182 | /* give here messages in/out endpoints */ | ||
1183 | .ep_msg_in = PCAN_USBPRO_EP_MSGIN, | ||
1184 | .ep_msg_out = {PCAN_USBPRO_EP_MSGOUT_0, PCAN_USBPRO_EP_MSGOUT_1}, | ||
1185 | |||
1186 | /* size of rx/tx usb buffers */ | ||
1187 | .rx_buffer_size = PCAN_UFD_RX_BUFFER_SIZE, | ||
1188 | .tx_buffer_size = PCAN_UFD_TX_BUFFER_SIZE, | ||
1189 | |||
1190 | /* device callbacks */ | ||
1191 | .intf_probe = pcan_usb_pro_probe, /* same as PCAN-USB Pro */ | ||
1192 | .dev_init = pcan_usb_fd_init, | ||
1193 | |||
1194 | .dev_exit = pcan_usb_fd_exit, | ||
1195 | .dev_free = pcan_usb_fd_free, | ||
1196 | .dev_set_bus = pcan_usb_fd_set_bus, | ||
1197 | .dev_set_bittiming = pcan_usb_fd_set_bittiming_slow, | ||
1198 | .dev_set_data_bittiming = pcan_usb_fd_set_bittiming_fast, | ||
1199 | .dev_decode_buf = pcan_usb_fd_decode_buf, | ||
1200 | .dev_start = pcan_usb_fd_start, | ||
1201 | .dev_stop = pcan_usb_fd_stop, | ||
1202 | .dev_restart_async = pcan_usb_fd_restart_async, | ||
1203 | .dev_encode_msg = pcan_usb_fd_encode_msg, | ||
1204 | |||
1205 | .do_get_berr_counter = pcan_usb_fd_get_berr_counter, | ||
1206 | }; | ||
diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c index bda31f308cc2..a0eee7218695 100644 --- a/drivers/net/ethernet/altera/altera_tse_main.c +++ b/drivers/net/ethernet/altera/altera_tse_main.c | |||
@@ -400,12 +400,6 @@ static int tse_rx(struct altera_tse_private *priv, int limit) | |||
400 | 400 | ||
401 | skb_put(skb, pktlength); | 401 | skb_put(skb, pktlength); |
402 | 402 | ||
403 | /* make cache consistent with receive packet buffer */ | ||
404 | dma_sync_single_for_cpu(priv->device, | ||
405 | priv->rx_ring[entry].dma_addr, | ||
406 | priv->rx_ring[entry].len, | ||
407 | DMA_FROM_DEVICE); | ||
408 | |||
409 | dma_unmap_single(priv->device, priv->rx_ring[entry].dma_addr, | 403 | dma_unmap_single(priv->device, priv->rx_ring[entry].dma_addr, |
410 | priv->rx_ring[entry].len, DMA_FROM_DEVICE); | 404 | priv->rx_ring[entry].len, DMA_FROM_DEVICE); |
411 | 405 | ||
@@ -469,7 +463,6 @@ static int tse_tx_complete(struct altera_tse_private *priv) | |||
469 | 463 | ||
470 | if (unlikely(netif_queue_stopped(priv->dev) && | 464 | if (unlikely(netif_queue_stopped(priv->dev) && |
471 | tse_tx_avail(priv) > TSE_TX_THRESH(priv))) { | 465 | tse_tx_avail(priv) > TSE_TX_THRESH(priv))) { |
472 | netif_tx_lock(priv->dev); | ||
473 | if (netif_queue_stopped(priv->dev) && | 466 | if (netif_queue_stopped(priv->dev) && |
474 | tse_tx_avail(priv) > TSE_TX_THRESH(priv)) { | 467 | tse_tx_avail(priv) > TSE_TX_THRESH(priv)) { |
475 | if (netif_msg_tx_done(priv)) | 468 | if (netif_msg_tx_done(priv)) |
@@ -477,7 +470,6 @@ static int tse_tx_complete(struct altera_tse_private *priv) | |||
477 | __func__); | 470 | __func__); |
478 | netif_wake_queue(priv->dev); | 471 | netif_wake_queue(priv->dev); |
479 | } | 472 | } |
480 | netif_tx_unlock(priv->dev); | ||
481 | } | 473 | } |
482 | 474 | ||
483 | spin_unlock(&priv->tx_lock); | 475 | spin_unlock(&priv->tx_lock); |
@@ -592,10 +584,6 @@ static int tse_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
592 | buffer->dma_addr = dma_addr; | 584 | buffer->dma_addr = dma_addr; |
593 | buffer->len = nopaged_len; | 585 | buffer->len = nopaged_len; |
594 | 586 | ||
595 | /* Push data out of the cache hierarchy into main memory */ | ||
596 | dma_sync_single_for_device(priv->device, buffer->dma_addr, | ||
597 | buffer->len, DMA_TO_DEVICE); | ||
598 | |||
599 | priv->dmaops->tx_buffer(priv, buffer); | 587 | priv->dmaops->tx_buffer(priv, buffer); |
600 | 588 | ||
601 | skb_tx_timestamp(skb); | 589 | skb_tx_timestamp(skb); |
@@ -819,6 +807,8 @@ static int init_phy(struct net_device *dev) | |||
819 | 807 | ||
820 | if (!phydev) { | 808 | if (!phydev) { |
821 | netdev_err(dev, "Could not find the PHY\n"); | 809 | netdev_err(dev, "Could not find the PHY\n"); |
810 | if (fixed_link) | ||
811 | of_phy_deregister_fixed_link(priv->device->of_node); | ||
822 | return -ENODEV; | 812 | return -ENODEV; |
823 | } | 813 | } |
824 | 814 | ||
@@ -1545,10 +1535,15 @@ err_free_netdev: | |||
1545 | static int altera_tse_remove(struct platform_device *pdev) | 1535 | static int altera_tse_remove(struct platform_device *pdev) |
1546 | { | 1536 | { |
1547 | struct net_device *ndev = platform_get_drvdata(pdev); | 1537 | struct net_device *ndev = platform_get_drvdata(pdev); |
1538 | struct altera_tse_private *priv = netdev_priv(ndev); | ||
1548 | 1539 | ||
1549 | if (ndev->phydev) | 1540 | if (ndev->phydev) { |
1550 | phy_disconnect(ndev->phydev); | 1541 | phy_disconnect(ndev->phydev); |
1551 | 1542 | ||
1543 | if (of_phy_is_fixed_link(priv->device->of_node)) | ||
1544 | of_phy_deregister_fixed_link(priv->device->of_node); | ||
1545 | } | ||
1546 | |||
1552 | platform_set_drvdata(pdev, NULL); | 1547 | platform_set_drvdata(pdev, NULL); |
1553 | altera_tse_mdio_destroy(ndev); | 1548 | altera_tse_mdio_destroy(ndev); |
1554 | unregister_netdev(ndev); | 1549 | unregister_netdev(ndev); |
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-main.c b/drivers/net/ethernet/amd/xgbe/xgbe-main.c index 9de078819aa6..4f7635178200 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-main.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-main.c | |||
@@ -829,7 +829,7 @@ static int xgbe_remove(struct platform_device *pdev) | |||
829 | return 0; | 829 | return 0; |
830 | } | 830 | } |
831 | 831 | ||
832 | #ifdef CONFIG_PM | 832 | #ifdef CONFIG_PM_SLEEP |
833 | static int xgbe_suspend(struct device *dev) | 833 | static int xgbe_suspend(struct device *dev) |
834 | { | 834 | { |
835 | struct net_device *netdev = dev_get_drvdata(dev); | 835 | struct net_device *netdev = dev_get_drvdata(dev); |
@@ -874,7 +874,7 @@ static int xgbe_resume(struct device *dev) | |||
874 | 874 | ||
875 | return ret; | 875 | return ret; |
876 | } | 876 | } |
877 | #endif /* CONFIG_PM */ | 877 | #endif /* CONFIG_PM_SLEEP */ |
878 | 878 | ||
879 | #ifdef CONFIG_ACPI | 879 | #ifdef CONFIG_ACPI |
880 | static const struct acpi_device_id xgbe_acpi_match[] = { | 880 | static const struct acpi_device_id xgbe_acpi_match[] = { |
diff --git a/drivers/net/ethernet/aurora/nb8800.c b/drivers/net/ethernet/aurora/nb8800.c index 00c38bf151e6..e078d8da978c 100644 --- a/drivers/net/ethernet/aurora/nb8800.c +++ b/drivers/net/ethernet/aurora/nb8800.c | |||
@@ -1466,12 +1466,12 @@ static int nb8800_probe(struct platform_device *pdev) | |||
1466 | 1466 | ||
1467 | ret = nb8800_hw_init(dev); | 1467 | ret = nb8800_hw_init(dev); |
1468 | if (ret) | 1468 | if (ret) |
1469 | goto err_free_bus; | 1469 | goto err_deregister_fixed_link; |
1470 | 1470 | ||
1471 | if (ops && ops->init) { | 1471 | if (ops && ops->init) { |
1472 | ret = ops->init(dev); | 1472 | ret = ops->init(dev); |
1473 | if (ret) | 1473 | if (ret) |
1474 | goto err_free_bus; | 1474 | goto err_deregister_fixed_link; |
1475 | } | 1475 | } |
1476 | 1476 | ||
1477 | dev->netdev_ops = &nb8800_netdev_ops; | 1477 | dev->netdev_ops = &nb8800_netdev_ops; |
@@ -1504,6 +1504,9 @@ static int nb8800_probe(struct platform_device *pdev) | |||
1504 | 1504 | ||
1505 | err_free_dma: | 1505 | err_free_dma: |
1506 | nb8800_dma_free(dev); | 1506 | nb8800_dma_free(dev); |
1507 | err_deregister_fixed_link: | ||
1508 | if (of_phy_is_fixed_link(pdev->dev.of_node)) | ||
1509 | of_phy_deregister_fixed_link(pdev->dev.of_node); | ||
1507 | err_free_bus: | 1510 | err_free_bus: |
1508 | of_node_put(priv->phy_node); | 1511 | of_node_put(priv->phy_node); |
1509 | mdiobus_unregister(bus); | 1512 | mdiobus_unregister(bus); |
@@ -1521,6 +1524,8 @@ static int nb8800_remove(struct platform_device *pdev) | |||
1521 | struct nb8800_priv *priv = netdev_priv(ndev); | 1524 | struct nb8800_priv *priv = netdev_priv(ndev); |
1522 | 1525 | ||
1523 | unregister_netdev(ndev); | 1526 | unregister_netdev(ndev); |
1527 | if (of_phy_is_fixed_link(pdev->dev.of_node)) | ||
1528 | of_phy_deregister_fixed_link(pdev->dev.of_node); | ||
1524 | of_node_put(priv->phy_node); | 1529 | of_node_put(priv->phy_node); |
1525 | 1530 | ||
1526 | mdiobus_unregister(priv->mii_bus); | 1531 | mdiobus_unregister(priv->mii_bus); |
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c index c3354b9941d1..25d1eb4933d0 100644 --- a/drivers/net/ethernet/broadcom/bcmsysport.c +++ b/drivers/net/ethernet/broadcom/bcmsysport.c | |||
@@ -1755,13 +1755,13 @@ static int bcm_sysport_probe(struct platform_device *pdev) | |||
1755 | if (priv->irq0 <= 0 || priv->irq1 <= 0) { | 1755 | if (priv->irq0 <= 0 || priv->irq1 <= 0) { |
1756 | dev_err(&pdev->dev, "invalid interrupts\n"); | 1756 | dev_err(&pdev->dev, "invalid interrupts\n"); |
1757 | ret = -EINVAL; | 1757 | ret = -EINVAL; |
1758 | goto err; | 1758 | goto err_free_netdev; |
1759 | } | 1759 | } |
1760 | 1760 | ||
1761 | priv->base = devm_ioremap_resource(&pdev->dev, r); | 1761 | priv->base = devm_ioremap_resource(&pdev->dev, r); |
1762 | if (IS_ERR(priv->base)) { | 1762 | if (IS_ERR(priv->base)) { |
1763 | ret = PTR_ERR(priv->base); | 1763 | ret = PTR_ERR(priv->base); |
1764 | goto err; | 1764 | goto err_free_netdev; |
1765 | } | 1765 | } |
1766 | 1766 | ||
1767 | priv->netdev = dev; | 1767 | priv->netdev = dev; |
@@ -1779,7 +1779,7 @@ static int bcm_sysport_probe(struct platform_device *pdev) | |||
1779 | ret = of_phy_register_fixed_link(dn); | 1779 | ret = of_phy_register_fixed_link(dn); |
1780 | if (ret) { | 1780 | if (ret) { |
1781 | dev_err(&pdev->dev, "failed to register fixed PHY\n"); | 1781 | dev_err(&pdev->dev, "failed to register fixed PHY\n"); |
1782 | goto err; | 1782 | goto err_free_netdev; |
1783 | } | 1783 | } |
1784 | 1784 | ||
1785 | priv->phy_dn = dn; | 1785 | priv->phy_dn = dn; |
@@ -1821,7 +1821,7 @@ static int bcm_sysport_probe(struct platform_device *pdev) | |||
1821 | ret = register_netdev(dev); | 1821 | ret = register_netdev(dev); |
1822 | if (ret) { | 1822 | if (ret) { |
1823 | dev_err(&pdev->dev, "failed to register net_device\n"); | 1823 | dev_err(&pdev->dev, "failed to register net_device\n"); |
1824 | goto err; | 1824 | goto err_deregister_fixed_link; |
1825 | } | 1825 | } |
1826 | 1826 | ||
1827 | priv->rev = topctrl_readl(priv, REV_CNTL) & REV_MASK; | 1827 | priv->rev = topctrl_readl(priv, REV_CNTL) & REV_MASK; |
@@ -1832,7 +1832,11 @@ static int bcm_sysport_probe(struct platform_device *pdev) | |||
1832 | priv->base, priv->irq0, priv->irq1, txq, rxq); | 1832 | priv->base, priv->irq0, priv->irq1, txq, rxq); |
1833 | 1833 | ||
1834 | return 0; | 1834 | return 0; |
1835 | err: | 1835 | |
1836 | err_deregister_fixed_link: | ||
1837 | if (of_phy_is_fixed_link(dn)) | ||
1838 | of_phy_deregister_fixed_link(dn); | ||
1839 | err_free_netdev: | ||
1836 | free_netdev(dev); | 1840 | free_netdev(dev); |
1837 | return ret; | 1841 | return ret; |
1838 | } | 1842 | } |
@@ -1840,11 +1844,14 @@ err: | |||
1840 | static int bcm_sysport_remove(struct platform_device *pdev) | 1844 | static int bcm_sysport_remove(struct platform_device *pdev) |
1841 | { | 1845 | { |
1842 | struct net_device *dev = dev_get_drvdata(&pdev->dev); | 1846 | struct net_device *dev = dev_get_drvdata(&pdev->dev); |
1847 | struct device_node *dn = pdev->dev.of_node; | ||
1843 | 1848 | ||
1844 | /* Not much to do, ndo_close has been called | 1849 | /* Not much to do, ndo_close has been called |
1845 | * and we use managed allocations | 1850 | * and we use managed allocations |
1846 | */ | 1851 | */ |
1847 | unregister_netdev(dev); | 1852 | unregister_netdev(dev); |
1853 | if (of_phy_is_fixed_link(dn)) | ||
1854 | of_phy_deregister_fixed_link(dn); | ||
1848 | free_netdev(dev); | 1855 | free_netdev(dev); |
1849 | dev_set_drvdata(&pdev->dev, NULL); | 1856 | dev_set_drvdata(&pdev->dev, NULL); |
1850 | 1857 | ||
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c index 4464bc5db934..a4e60e56c14f 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c | |||
@@ -1172,6 +1172,7 @@ static unsigned int __bcmgenet_tx_reclaim(struct net_device *dev, | |||
1172 | struct bcmgenet_tx_ring *ring) | 1172 | struct bcmgenet_tx_ring *ring) |
1173 | { | 1173 | { |
1174 | struct bcmgenet_priv *priv = netdev_priv(dev); | 1174 | struct bcmgenet_priv *priv = netdev_priv(dev); |
1175 | struct device *kdev = &priv->pdev->dev; | ||
1175 | struct enet_cb *tx_cb_ptr; | 1176 | struct enet_cb *tx_cb_ptr; |
1176 | struct netdev_queue *txq; | 1177 | struct netdev_queue *txq; |
1177 | unsigned int pkts_compl = 0; | 1178 | unsigned int pkts_compl = 0; |
@@ -1199,13 +1200,13 @@ static unsigned int __bcmgenet_tx_reclaim(struct net_device *dev, | |||
1199 | if (tx_cb_ptr->skb) { | 1200 | if (tx_cb_ptr->skb) { |
1200 | pkts_compl++; | 1201 | pkts_compl++; |
1201 | bytes_compl += GENET_CB(tx_cb_ptr->skb)->bytes_sent; | 1202 | bytes_compl += GENET_CB(tx_cb_ptr->skb)->bytes_sent; |
1202 | dma_unmap_single(&dev->dev, | 1203 | dma_unmap_single(kdev, |
1203 | dma_unmap_addr(tx_cb_ptr, dma_addr), | 1204 | dma_unmap_addr(tx_cb_ptr, dma_addr), |
1204 | dma_unmap_len(tx_cb_ptr, dma_len), | 1205 | dma_unmap_len(tx_cb_ptr, dma_len), |
1205 | DMA_TO_DEVICE); | 1206 | DMA_TO_DEVICE); |
1206 | bcmgenet_free_cb(tx_cb_ptr); | 1207 | bcmgenet_free_cb(tx_cb_ptr); |
1207 | } else if (dma_unmap_addr(tx_cb_ptr, dma_addr)) { | 1208 | } else if (dma_unmap_addr(tx_cb_ptr, dma_addr)) { |
1208 | dma_unmap_page(&dev->dev, | 1209 | dma_unmap_page(kdev, |
1209 | dma_unmap_addr(tx_cb_ptr, dma_addr), | 1210 | dma_unmap_addr(tx_cb_ptr, dma_addr), |
1210 | dma_unmap_len(tx_cb_ptr, dma_len), | 1211 | dma_unmap_len(tx_cb_ptr, dma_len), |
1211 | DMA_TO_DEVICE); | 1212 | DMA_TO_DEVICE); |
@@ -1775,6 +1776,7 @@ static int bcmgenet_alloc_rx_buffers(struct bcmgenet_priv *priv, | |||
1775 | 1776 | ||
1776 | static void bcmgenet_free_rx_buffers(struct bcmgenet_priv *priv) | 1777 | static void bcmgenet_free_rx_buffers(struct bcmgenet_priv *priv) |
1777 | { | 1778 | { |
1779 | struct device *kdev = &priv->pdev->dev; | ||
1778 | struct enet_cb *cb; | 1780 | struct enet_cb *cb; |
1779 | int i; | 1781 | int i; |
1780 | 1782 | ||
@@ -1782,7 +1784,7 @@ static void bcmgenet_free_rx_buffers(struct bcmgenet_priv *priv) | |||
1782 | cb = &priv->rx_cbs[i]; | 1784 | cb = &priv->rx_cbs[i]; |
1783 | 1785 | ||
1784 | if (dma_unmap_addr(cb, dma_addr)) { | 1786 | if (dma_unmap_addr(cb, dma_addr)) { |
1785 | dma_unmap_single(&priv->dev->dev, | 1787 | dma_unmap_single(kdev, |
1786 | dma_unmap_addr(cb, dma_addr), | 1788 | dma_unmap_addr(cb, dma_addr), |
1787 | priv->rx_buf_len, DMA_FROM_DEVICE); | 1789 | priv->rx_buf_len, DMA_FROM_DEVICE); |
1788 | dma_unmap_addr_set(cb, dma_addr, 0); | 1790 | dma_unmap_addr_set(cb, dma_addr, 0); |
diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c index 457c3bc8cfff..e87607621e62 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmmii.c +++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c | |||
@@ -542,8 +542,10 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv) | |||
542 | /* Make sure we initialize MoCA PHYs with a link down */ | 542 | /* Make sure we initialize MoCA PHYs with a link down */ |
543 | if (phy_mode == PHY_INTERFACE_MODE_MOCA) { | 543 | if (phy_mode == PHY_INTERFACE_MODE_MOCA) { |
544 | phydev = of_phy_find_device(dn); | 544 | phydev = of_phy_find_device(dn); |
545 | if (phydev) | 545 | if (phydev) { |
546 | phydev->link = 0; | 546 | phydev->link = 0; |
547 | put_device(&phydev->mdio.dev); | ||
548 | } | ||
547 | } | 549 | } |
548 | 550 | ||
549 | return 0; | 551 | return 0; |
@@ -625,6 +627,7 @@ static int bcmgenet_mii_bus_init(struct bcmgenet_priv *priv) | |||
625 | int bcmgenet_mii_init(struct net_device *dev) | 627 | int bcmgenet_mii_init(struct net_device *dev) |
626 | { | 628 | { |
627 | struct bcmgenet_priv *priv = netdev_priv(dev); | 629 | struct bcmgenet_priv *priv = netdev_priv(dev); |
630 | struct device_node *dn = priv->pdev->dev.of_node; | ||
628 | int ret; | 631 | int ret; |
629 | 632 | ||
630 | ret = bcmgenet_mii_alloc(priv); | 633 | ret = bcmgenet_mii_alloc(priv); |
@@ -638,6 +641,8 @@ int bcmgenet_mii_init(struct net_device *dev) | |||
638 | return 0; | 641 | return 0; |
639 | 642 | ||
640 | out: | 643 | out: |
644 | if (of_phy_is_fixed_link(dn)) | ||
645 | of_phy_deregister_fixed_link(dn); | ||
641 | of_node_put(priv->phy_dn); | 646 | of_node_put(priv->phy_dn); |
642 | mdiobus_unregister(priv->mii_bus); | 647 | mdiobus_unregister(priv->mii_bus); |
643 | mdiobus_free(priv->mii_bus); | 648 | mdiobus_free(priv->mii_bus); |
@@ -647,7 +652,10 @@ out: | |||
647 | void bcmgenet_mii_exit(struct net_device *dev) | 652 | void bcmgenet_mii_exit(struct net_device *dev) |
648 | { | 653 | { |
649 | struct bcmgenet_priv *priv = netdev_priv(dev); | 654 | struct bcmgenet_priv *priv = netdev_priv(dev); |
655 | struct device_node *dn = priv->pdev->dev.of_node; | ||
650 | 656 | ||
657 | if (of_phy_is_fixed_link(dn)) | ||
658 | of_phy_deregister_fixed_link(dn); | ||
651 | of_node_put(priv->phy_dn); | 659 | of_node_put(priv->phy_dn); |
652 | mdiobus_unregister(priv->mii_bus); | 660 | mdiobus_unregister(priv->mii_bus); |
653 | mdiobus_free(priv->mii_bus); | 661 | mdiobus_free(priv->mii_bus); |
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c index 533653bd7aec..ec09fcece711 100644 --- a/drivers/net/ethernet/cadence/macb.c +++ b/drivers/net/ethernet/cadence/macb.c | |||
@@ -975,6 +975,7 @@ static inline void macb_init_rx_ring(struct macb *bp) | |||
975 | addr += bp->rx_buffer_size; | 975 | addr += bp->rx_buffer_size; |
976 | } | 976 | } |
977 | bp->rx_ring[RX_RING_SIZE - 1].addr |= MACB_BIT(RX_WRAP); | 977 | bp->rx_ring[RX_RING_SIZE - 1].addr |= MACB_BIT(RX_WRAP); |
978 | bp->rx_tail = 0; | ||
978 | } | 979 | } |
979 | 980 | ||
980 | static int macb_rx(struct macb *bp, int budget) | 981 | static int macb_rx(struct macb *bp, int budget) |
@@ -1156,6 +1157,7 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id) | |||
1156 | if (status & MACB_BIT(RXUBR)) { | 1157 | if (status & MACB_BIT(RXUBR)) { |
1157 | ctrl = macb_readl(bp, NCR); | 1158 | ctrl = macb_readl(bp, NCR); |
1158 | macb_writel(bp, NCR, ctrl & ~MACB_BIT(RE)); | 1159 | macb_writel(bp, NCR, ctrl & ~MACB_BIT(RE)); |
1160 | wmb(); | ||
1159 | macb_writel(bp, NCR, ctrl | MACB_BIT(RE)); | 1161 | macb_writel(bp, NCR, ctrl | MACB_BIT(RE)); |
1160 | 1162 | ||
1161 | if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE) | 1163 | if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE) |
@@ -1616,8 +1618,6 @@ static void macb_init_rings(struct macb *bp) | |||
1616 | bp->queues[0].tx_head = 0; | 1618 | bp->queues[0].tx_head = 0; |
1617 | bp->queues[0].tx_tail = 0; | 1619 | bp->queues[0].tx_tail = 0; |
1618 | bp->queues[0].tx_ring[TX_RING_SIZE - 1].ctrl |= MACB_BIT(TX_WRAP); | 1620 | bp->queues[0].tx_ring[TX_RING_SIZE - 1].ctrl |= MACB_BIT(TX_WRAP); |
1619 | |||
1620 | bp->rx_tail = 0; | ||
1621 | } | 1621 | } |
1622 | 1622 | ||
1623 | static void macb_reset_hw(struct macb *bp) | 1623 | static void macb_reset_hw(struct macb *bp) |
@@ -2770,6 +2770,7 @@ static irqreturn_t at91ether_interrupt(int irq, void *dev_id) | |||
2770 | if (intstatus & MACB_BIT(RXUBR)) { | 2770 | if (intstatus & MACB_BIT(RXUBR)) { |
2771 | ctl = macb_readl(lp, NCR); | 2771 | ctl = macb_readl(lp, NCR); |
2772 | macb_writel(lp, NCR, ctl & ~MACB_BIT(RE)); | 2772 | macb_writel(lp, NCR, ctl & ~MACB_BIT(RE)); |
2773 | wmb(); | ||
2773 | macb_writel(lp, NCR, ctl | MACB_BIT(RE)); | 2774 | macb_writel(lp, NCR, ctl | MACB_BIT(RE)); |
2774 | } | 2775 | } |
2775 | 2776 | ||
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h b/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h index df1573c4a659..ecf3ccc257bc 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h | |||
@@ -168,6 +168,7 @@ CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN | |||
168 | CH_PCI_ID_TABLE_FENTRY(0x509a), /* Custom T520-CR */ | 168 | CH_PCI_ID_TABLE_FENTRY(0x509a), /* Custom T520-CR */ |
169 | CH_PCI_ID_TABLE_FENTRY(0x509b), /* Custom T540-CR LOM */ | 169 | CH_PCI_ID_TABLE_FENTRY(0x509b), /* Custom T540-CR LOM */ |
170 | CH_PCI_ID_TABLE_FENTRY(0x509c), /* Custom T520-CR*/ | 170 | CH_PCI_ID_TABLE_FENTRY(0x509c), /* Custom T520-CR*/ |
171 | CH_PCI_ID_TABLE_FENTRY(0x509d), /* Custom T540-CR*/ | ||
171 | 172 | ||
172 | /* T6 adapters: | 173 | /* T6 adapters: |
173 | */ | 174 | */ |
diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h index c865135f3cb9..5ea740b4cf14 100644 --- a/drivers/net/ethernet/freescale/fec.h +++ b/drivers/net/ethernet/freescale/fec.h | |||
@@ -574,6 +574,8 @@ struct fec_enet_private { | |||
574 | unsigned int reload_period; | 574 | unsigned int reload_period; |
575 | int pps_enable; | 575 | int pps_enable; |
576 | unsigned int next_counter; | 576 | unsigned int next_counter; |
577 | |||
578 | u64 ethtool_stats[0]; | ||
577 | }; | 579 | }; |
578 | 580 | ||
579 | void fec_ptp_init(struct platform_device *pdev); | 581 | void fec_ptp_init(struct platform_device *pdev); |
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 5aa9d4ded214..5f77caa59534 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c | |||
@@ -2313,14 +2313,24 @@ static const struct fec_stat { | |||
2313 | { "IEEE_rx_octets_ok", IEEE_R_OCTETS_OK }, | 2313 | { "IEEE_rx_octets_ok", IEEE_R_OCTETS_OK }, |
2314 | }; | 2314 | }; |
2315 | 2315 | ||
2316 | static void fec_enet_get_ethtool_stats(struct net_device *dev, | 2316 | static void fec_enet_update_ethtool_stats(struct net_device *dev) |
2317 | struct ethtool_stats *stats, u64 *data) | ||
2318 | { | 2317 | { |
2319 | struct fec_enet_private *fep = netdev_priv(dev); | 2318 | struct fec_enet_private *fep = netdev_priv(dev); |
2320 | int i; | 2319 | int i; |
2321 | 2320 | ||
2322 | for (i = 0; i < ARRAY_SIZE(fec_stats); i++) | 2321 | for (i = 0; i < ARRAY_SIZE(fec_stats); i++) |
2323 | data[i] = readl(fep->hwp + fec_stats[i].offset); | 2322 | fep->ethtool_stats[i] = readl(fep->hwp + fec_stats[i].offset); |
2323 | } | ||
2324 | |||
2325 | static void fec_enet_get_ethtool_stats(struct net_device *dev, | ||
2326 | struct ethtool_stats *stats, u64 *data) | ||
2327 | { | ||
2328 | struct fec_enet_private *fep = netdev_priv(dev); | ||
2329 | |||
2330 | if (netif_running(dev)) | ||
2331 | fec_enet_update_ethtool_stats(dev); | ||
2332 | |||
2333 | memcpy(data, fep->ethtool_stats, ARRAY_SIZE(fec_stats) * sizeof(u64)); | ||
2324 | } | 2334 | } |
2325 | 2335 | ||
2326 | static void fec_enet_get_strings(struct net_device *netdev, | 2336 | static void fec_enet_get_strings(struct net_device *netdev, |
@@ -2874,6 +2884,8 @@ fec_enet_close(struct net_device *ndev) | |||
2874 | if (fep->quirks & FEC_QUIRK_ERR006687) | 2884 | if (fep->quirks & FEC_QUIRK_ERR006687) |
2875 | imx6q_cpuidle_fec_irqs_unused(); | 2885 | imx6q_cpuidle_fec_irqs_unused(); |
2876 | 2886 | ||
2887 | fec_enet_update_ethtool_stats(ndev); | ||
2888 | |||
2877 | fec_enet_clk_enable(ndev, false); | 2889 | fec_enet_clk_enable(ndev, false); |
2878 | pinctrl_pm_select_sleep_state(&fep->pdev->dev); | 2890 | pinctrl_pm_select_sleep_state(&fep->pdev->dev); |
2879 | pm_runtime_mark_last_busy(&fep->pdev->dev); | 2891 | pm_runtime_mark_last_busy(&fep->pdev->dev); |
@@ -3180,6 +3192,8 @@ static int fec_enet_init(struct net_device *ndev) | |||
3180 | 3192 | ||
3181 | fec_restart(ndev); | 3193 | fec_restart(ndev); |
3182 | 3194 | ||
3195 | fec_enet_update_ethtool_stats(ndev); | ||
3196 | |||
3183 | return 0; | 3197 | return 0; |
3184 | } | 3198 | } |
3185 | 3199 | ||
@@ -3278,7 +3292,8 @@ fec_probe(struct platform_device *pdev) | |||
3278 | fec_enet_get_queue_num(pdev, &num_tx_qs, &num_rx_qs); | 3292 | fec_enet_get_queue_num(pdev, &num_tx_qs, &num_rx_qs); |
3279 | 3293 | ||
3280 | /* Init network device */ | 3294 | /* Init network device */ |
3281 | ndev = alloc_etherdev_mqs(sizeof(struct fec_enet_private), | 3295 | ndev = alloc_etherdev_mqs(sizeof(struct fec_enet_private) + |
3296 | ARRAY_SIZE(fec_stats) * sizeof(u64), | ||
3282 | num_tx_qs, num_rx_qs); | 3297 | num_tx_qs, num_rx_qs); |
3283 | if (!ndev) | 3298 | if (!ndev) |
3284 | return -ENOMEM; | 3299 | return -ENOMEM; |
@@ -3475,6 +3490,8 @@ failed_regulator: | |||
3475 | failed_clk_ipg: | 3490 | failed_clk_ipg: |
3476 | fec_enet_clk_enable(ndev, false); | 3491 | fec_enet_clk_enable(ndev, false); |
3477 | failed_clk: | 3492 | failed_clk: |
3493 | if (of_phy_is_fixed_link(np)) | ||
3494 | of_phy_deregister_fixed_link(np); | ||
3478 | failed_phy: | 3495 | failed_phy: |
3479 | of_node_put(phy_node); | 3496 | of_node_put(phy_node); |
3480 | failed_ioremap: | 3497 | failed_ioremap: |
@@ -3488,6 +3505,7 @@ fec_drv_remove(struct platform_device *pdev) | |||
3488 | { | 3505 | { |
3489 | struct net_device *ndev = platform_get_drvdata(pdev); | 3506 | struct net_device *ndev = platform_get_drvdata(pdev); |
3490 | struct fec_enet_private *fep = netdev_priv(ndev); | 3507 | struct fec_enet_private *fep = netdev_priv(ndev); |
3508 | struct device_node *np = pdev->dev.of_node; | ||
3491 | 3509 | ||
3492 | cancel_work_sync(&fep->tx_timeout_work); | 3510 | cancel_work_sync(&fep->tx_timeout_work); |
3493 | fec_ptp_stop(pdev); | 3511 | fec_ptp_stop(pdev); |
@@ -3495,6 +3513,8 @@ fec_drv_remove(struct platform_device *pdev) | |||
3495 | fec_enet_mii_remove(fep); | 3513 | fec_enet_mii_remove(fep); |
3496 | if (fep->reg_phy) | 3514 | if (fep->reg_phy) |
3497 | regulator_disable(fep->reg_phy); | 3515 | regulator_disable(fep->reg_phy); |
3516 | if (of_phy_is_fixed_link(np)) | ||
3517 | of_phy_deregister_fixed_link(np); | ||
3498 | of_node_put(fep->phy_node); | 3518 | of_node_put(fep->phy_node); |
3499 | free_netdev(ndev); | 3519 | free_netdev(ndev); |
3500 | 3520 | ||
diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c b/drivers/net/ethernet/freescale/fman/fman_memac.c index 53ef51e3bd9e..71a5ded9d1de 100644 --- a/drivers/net/ethernet/freescale/fman/fman_memac.c +++ b/drivers/net/ethernet/freescale/fman/fman_memac.c | |||
@@ -1107,6 +1107,9 @@ int memac_free(struct fman_mac *memac) | |||
1107 | { | 1107 | { |
1108 | free_init_resources(memac); | 1108 | free_init_resources(memac); |
1109 | 1109 | ||
1110 | if (memac->pcsphy) | ||
1111 | put_device(&memac->pcsphy->mdio.dev); | ||
1112 | |||
1110 | kfree(memac->memac_drv_param); | 1113 | kfree(memac->memac_drv_param); |
1111 | kfree(memac); | 1114 | kfree(memac); |
1112 | 1115 | ||
diff --git a/drivers/net/ethernet/freescale/fman/mac.c b/drivers/net/ethernet/freescale/fman/mac.c index 8fe6b3e253fa..736db9d9b0ad 100644 --- a/drivers/net/ethernet/freescale/fman/mac.c +++ b/drivers/net/ethernet/freescale/fman/mac.c | |||
@@ -892,6 +892,8 @@ static int mac_probe(struct platform_device *_of_dev) | |||
892 | priv->fixed_link->duplex = phy->duplex; | 892 | priv->fixed_link->duplex = phy->duplex; |
893 | priv->fixed_link->pause = phy->pause; | 893 | priv->fixed_link->pause = phy->pause; |
894 | priv->fixed_link->asym_pause = phy->asym_pause; | 894 | priv->fixed_link->asym_pause = phy->asym_pause; |
895 | |||
896 | put_device(&phy->mdio.dev); | ||
895 | } | 897 | } |
896 | 898 | ||
897 | err = mac_dev->init(mac_dev); | 899 | err = mac_dev->init(mac_dev); |
diff --git a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c index dc120c148d97..4b86260584a0 100644 --- a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c +++ b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c | |||
@@ -980,7 +980,7 @@ static int fs_enet_probe(struct platform_device *ofdev) | |||
980 | err = clk_prepare_enable(clk); | 980 | err = clk_prepare_enable(clk); |
981 | if (err) { | 981 | if (err) { |
982 | ret = err; | 982 | ret = err; |
983 | goto out_free_fpi; | 983 | goto out_deregister_fixed_link; |
984 | } | 984 | } |
985 | fpi->clk_per = clk; | 985 | fpi->clk_per = clk; |
986 | } | 986 | } |
@@ -1061,6 +1061,9 @@ out_put: | |||
1061 | of_node_put(fpi->phy_node); | 1061 | of_node_put(fpi->phy_node); |
1062 | if (fpi->clk_per) | 1062 | if (fpi->clk_per) |
1063 | clk_disable_unprepare(fpi->clk_per); | 1063 | clk_disable_unprepare(fpi->clk_per); |
1064 | out_deregister_fixed_link: | ||
1065 | if (of_phy_is_fixed_link(ofdev->dev.of_node)) | ||
1066 | of_phy_deregister_fixed_link(ofdev->dev.of_node); | ||
1064 | out_free_fpi: | 1067 | out_free_fpi: |
1065 | kfree(fpi); | 1068 | kfree(fpi); |
1066 | return ret; | 1069 | return ret; |
@@ -1079,6 +1082,8 @@ static int fs_enet_remove(struct platform_device *ofdev) | |||
1079 | of_node_put(fep->fpi->phy_node); | 1082 | of_node_put(fep->fpi->phy_node); |
1080 | if (fep->fpi->clk_per) | 1083 | if (fep->fpi->clk_per) |
1081 | clk_disable_unprepare(fep->fpi->clk_per); | 1084 | clk_disable_unprepare(fep->fpi->clk_per); |
1085 | if (of_phy_is_fixed_link(ofdev->dev.of_node)) | ||
1086 | of_phy_deregister_fixed_link(ofdev->dev.of_node); | ||
1082 | free_netdev(ndev); | 1087 | free_netdev(ndev); |
1083 | return 0; | 1088 | return 0; |
1084 | } | 1089 | } |
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index 4b4f5bc0e279..9061c2f82b9c 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c | |||
@@ -1312,6 +1312,7 @@ static void gfar_init_addr_hash_table(struct gfar_private *priv) | |||
1312 | */ | 1312 | */ |
1313 | static int gfar_probe(struct platform_device *ofdev) | 1313 | static int gfar_probe(struct platform_device *ofdev) |
1314 | { | 1314 | { |
1315 | struct device_node *np = ofdev->dev.of_node; | ||
1315 | struct net_device *dev = NULL; | 1316 | struct net_device *dev = NULL; |
1316 | struct gfar_private *priv = NULL; | 1317 | struct gfar_private *priv = NULL; |
1317 | int err = 0, i; | 1318 | int err = 0, i; |
@@ -1462,6 +1463,8 @@ static int gfar_probe(struct platform_device *ofdev) | |||
1462 | return 0; | 1463 | return 0; |
1463 | 1464 | ||
1464 | register_fail: | 1465 | register_fail: |
1466 | if (of_phy_is_fixed_link(np)) | ||
1467 | of_phy_deregister_fixed_link(np); | ||
1465 | unmap_group_regs(priv); | 1468 | unmap_group_regs(priv); |
1466 | gfar_free_rx_queues(priv); | 1469 | gfar_free_rx_queues(priv); |
1467 | gfar_free_tx_queues(priv); | 1470 | gfar_free_tx_queues(priv); |
@@ -1474,11 +1477,16 @@ register_fail: | |||
1474 | static int gfar_remove(struct platform_device *ofdev) | 1477 | static int gfar_remove(struct platform_device *ofdev) |
1475 | { | 1478 | { |
1476 | struct gfar_private *priv = platform_get_drvdata(ofdev); | 1479 | struct gfar_private *priv = platform_get_drvdata(ofdev); |
1480 | struct device_node *np = ofdev->dev.of_node; | ||
1477 | 1481 | ||
1478 | of_node_put(priv->phy_node); | 1482 | of_node_put(priv->phy_node); |
1479 | of_node_put(priv->tbi_node); | 1483 | of_node_put(priv->tbi_node); |
1480 | 1484 | ||
1481 | unregister_netdev(priv->ndev); | 1485 | unregister_netdev(priv->ndev); |
1486 | |||
1487 | if (of_phy_is_fixed_link(np)) | ||
1488 | of_phy_deregister_fixed_link(np); | ||
1489 | |||
1482 | unmap_group_regs(priv); | 1490 | unmap_group_regs(priv); |
1483 | gfar_free_rx_queues(priv); | 1491 | gfar_free_rx_queues(priv); |
1484 | gfar_free_tx_queues(priv); | 1492 | gfar_free_tx_queues(priv); |
diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c index 186ef8f16c80..f76d33279454 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.c +++ b/drivers/net/ethernet/freescale/ucc_geth.c | |||
@@ -3868,9 +3868,8 @@ static int ucc_geth_probe(struct platform_device* ofdev) | |||
3868 | dev = alloc_etherdev(sizeof(*ugeth)); | 3868 | dev = alloc_etherdev(sizeof(*ugeth)); |
3869 | 3869 | ||
3870 | if (dev == NULL) { | 3870 | if (dev == NULL) { |
3871 | of_node_put(ug_info->tbi_node); | 3871 | err = -ENOMEM; |
3872 | of_node_put(ug_info->phy_node); | 3872 | goto err_deregister_fixed_link; |
3873 | return -ENOMEM; | ||
3874 | } | 3873 | } |
3875 | 3874 | ||
3876 | ugeth = netdev_priv(dev); | 3875 | ugeth = netdev_priv(dev); |
@@ -3907,10 +3906,7 @@ static int ucc_geth_probe(struct platform_device* ofdev) | |||
3907 | if (netif_msg_probe(ugeth)) | 3906 | if (netif_msg_probe(ugeth)) |
3908 | pr_err("%s: Cannot register net device, aborting\n", | 3907 | pr_err("%s: Cannot register net device, aborting\n", |
3909 | dev->name); | 3908 | dev->name); |
3910 | free_netdev(dev); | 3909 | goto err_free_netdev; |
3911 | of_node_put(ug_info->tbi_node); | ||
3912 | of_node_put(ug_info->phy_node); | ||
3913 | return err; | ||
3914 | } | 3910 | } |
3915 | 3911 | ||
3916 | mac_addr = of_get_mac_address(np); | 3912 | mac_addr = of_get_mac_address(np); |
@@ -3923,16 +3919,29 @@ static int ucc_geth_probe(struct platform_device* ofdev) | |||
3923 | ugeth->node = np; | 3919 | ugeth->node = np; |
3924 | 3920 | ||
3925 | return 0; | 3921 | return 0; |
3922 | |||
3923 | err_free_netdev: | ||
3924 | free_netdev(dev); | ||
3925 | err_deregister_fixed_link: | ||
3926 | if (of_phy_is_fixed_link(np)) | ||
3927 | of_phy_deregister_fixed_link(np); | ||
3928 | of_node_put(ug_info->tbi_node); | ||
3929 | of_node_put(ug_info->phy_node); | ||
3930 | |||
3931 | return err; | ||
3926 | } | 3932 | } |
3927 | 3933 | ||
3928 | static int ucc_geth_remove(struct platform_device* ofdev) | 3934 | static int ucc_geth_remove(struct platform_device* ofdev) |
3929 | { | 3935 | { |
3930 | struct net_device *dev = platform_get_drvdata(ofdev); | 3936 | struct net_device *dev = platform_get_drvdata(ofdev); |
3931 | struct ucc_geth_private *ugeth = netdev_priv(dev); | 3937 | struct ucc_geth_private *ugeth = netdev_priv(dev); |
3938 | struct device_node *np = ofdev->dev.of_node; | ||
3932 | 3939 | ||
3933 | unregister_netdev(dev); | 3940 | unregister_netdev(dev); |
3934 | free_netdev(dev); | 3941 | free_netdev(dev); |
3935 | ucc_geth_memclean(ugeth); | 3942 | ucc_geth_memclean(ugeth); |
3943 | if (of_phy_is_fixed_link(np)) | ||
3944 | of_phy_deregister_fixed_link(np); | ||
3936 | of_node_put(ugeth->ug_info->tbi_node); | 3945 | of_node_put(ugeth->ug_info->tbi_node); |
3937 | of_node_put(ugeth->ug_info->phy_node); | 3946 | of_node_put(ugeth->ug_info->phy_node); |
3938 | 3947 | ||
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index edc9a6ac5169..9affd7c198bd 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c | |||
@@ -4931,11 +4931,15 @@ static int igb_tso(struct igb_ring *tx_ring, | |||
4931 | 4931 | ||
4932 | /* initialize outer IP header fields */ | 4932 | /* initialize outer IP header fields */ |
4933 | if (ip.v4->version == 4) { | 4933 | if (ip.v4->version == 4) { |
4934 | unsigned char *csum_start = skb_checksum_start(skb); | ||
4935 | unsigned char *trans_start = ip.hdr + (ip.v4->ihl * 4); | ||
4936 | |||
4934 | /* IP header will have to cancel out any data that | 4937 | /* IP header will have to cancel out any data that |
4935 | * is not a part of the outer IP header | 4938 | * is not a part of the outer IP header |
4936 | */ | 4939 | */ |
4937 | ip.v4->check = csum_fold(csum_add(lco_csum(skb), | 4940 | ip.v4->check = csum_fold(csum_partial(trans_start, |
4938 | csum_unfold(l4.tcp->check))); | 4941 | csum_start - trans_start, |
4942 | 0)); | ||
4939 | type_tucmd |= E1000_ADVTXD_TUCMD_IPV4; | 4943 | type_tucmd |= E1000_ADVTXD_TUCMD_IPV4; |
4940 | 4944 | ||
4941 | ip.v4->tot_len = 0; | 4945 | ip.v4->tot_len = 0; |
diff --git a/drivers/net/ethernet/intel/igbvf/netdev.c b/drivers/net/ethernet/intel/igbvf/netdev.c index 12bb877df860..7dff7f6239cd 100644 --- a/drivers/net/ethernet/intel/igbvf/netdev.c +++ b/drivers/net/ethernet/intel/igbvf/netdev.c | |||
@@ -1965,11 +1965,15 @@ static int igbvf_tso(struct igbvf_ring *tx_ring, | |||
1965 | 1965 | ||
1966 | /* initialize outer IP header fields */ | 1966 | /* initialize outer IP header fields */ |
1967 | if (ip.v4->version == 4) { | 1967 | if (ip.v4->version == 4) { |
1968 | unsigned char *csum_start = skb_checksum_start(skb); | ||
1969 | unsigned char *trans_start = ip.hdr + (ip.v4->ihl * 4); | ||
1970 | |||
1968 | /* IP header will have to cancel out any data that | 1971 | /* IP header will have to cancel out any data that |
1969 | * is not a part of the outer IP header | 1972 | * is not a part of the outer IP header |
1970 | */ | 1973 | */ |
1971 | ip.v4->check = csum_fold(csum_add(lco_csum(skb), | 1974 | ip.v4->check = csum_fold(csum_partial(trans_start, |
1972 | csum_unfold(l4.tcp->check))); | 1975 | csum_start - trans_start, |
1976 | 0)); | ||
1973 | type_tucmd |= E1000_ADVTXD_TUCMD_IPV4; | 1977 | type_tucmd |= E1000_ADVTXD_TUCMD_IPV4; |
1974 | 1978 | ||
1975 | ip.v4->tot_len = 0; | 1979 | ip.v4->tot_len = 0; |
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index bd93d823cc25..fee1f2918ead 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | |||
@@ -7277,11 +7277,15 @@ static int ixgbe_tso(struct ixgbe_ring *tx_ring, | |||
7277 | 7277 | ||
7278 | /* initialize outer IP header fields */ | 7278 | /* initialize outer IP header fields */ |
7279 | if (ip.v4->version == 4) { | 7279 | if (ip.v4->version == 4) { |
7280 | unsigned char *csum_start = skb_checksum_start(skb); | ||
7281 | unsigned char *trans_start = ip.hdr + (ip.v4->ihl * 4); | ||
7282 | |||
7280 | /* IP header will have to cancel out any data that | 7283 | /* IP header will have to cancel out any data that |
7281 | * is not a part of the outer IP header | 7284 | * is not a part of the outer IP header |
7282 | */ | 7285 | */ |
7283 | ip.v4->check = csum_fold(csum_add(lco_csum(skb), | 7286 | ip.v4->check = csum_fold(csum_partial(trans_start, |
7284 | csum_unfold(l4.tcp->check))); | 7287 | csum_start - trans_start, |
7288 | 0)); | ||
7285 | type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4; | 7289 | type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4; |
7286 | 7290 | ||
7287 | ip.v4->tot_len = 0; | 7291 | ip.v4->tot_len = 0; |
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c index 7eaac3234049..cbf70fe4028a 100644 --- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | |||
@@ -3329,11 +3329,15 @@ static int ixgbevf_tso(struct ixgbevf_ring *tx_ring, | |||
3329 | 3329 | ||
3330 | /* initialize outer IP header fields */ | 3330 | /* initialize outer IP header fields */ |
3331 | if (ip.v4->version == 4) { | 3331 | if (ip.v4->version == 4) { |
3332 | unsigned char *csum_start = skb_checksum_start(skb); | ||
3333 | unsigned char *trans_start = ip.hdr + (ip.v4->ihl * 4); | ||
3334 | |||
3332 | /* IP header will have to cancel out any data that | 3335 | /* IP header will have to cancel out any data that |
3333 | * is not a part of the outer IP header | 3336 | * is not a part of the outer IP header |
3334 | */ | 3337 | */ |
3335 | ip.v4->check = csum_fold(csum_add(lco_csum(skb), | 3338 | ip.v4->check = csum_fold(csum_partial(trans_start, |
3336 | csum_unfold(l4.tcp->check))); | 3339 | csum_start - trans_start, |
3340 | 0)); | ||
3337 | type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4; | 3341 | type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4; |
3338 | 3342 | ||
3339 | ip.v4->tot_len = 0; | 3343 | ip.v4->tot_len = 0; |
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c index 0c0a45af950f..707bc4680b9b 100644 --- a/drivers/net/ethernet/marvell/mvneta.c +++ b/drivers/net/ethernet/marvell/mvneta.c | |||
@@ -4191,6 +4191,8 @@ err_clk: | |||
4191 | clk_disable_unprepare(pp->clk); | 4191 | clk_disable_unprepare(pp->clk); |
4192 | err_put_phy_node: | 4192 | err_put_phy_node: |
4193 | of_node_put(phy_node); | 4193 | of_node_put(phy_node); |
4194 | if (of_phy_is_fixed_link(dn)) | ||
4195 | of_phy_deregister_fixed_link(dn); | ||
4194 | err_free_irq: | 4196 | err_free_irq: |
4195 | irq_dispose_mapping(dev->irq); | 4197 | irq_dispose_mapping(dev->irq); |
4196 | err_free_netdev: | 4198 | err_free_netdev: |
@@ -4202,6 +4204,7 @@ err_free_netdev: | |||
4202 | static int mvneta_remove(struct platform_device *pdev) | 4204 | static int mvneta_remove(struct platform_device *pdev) |
4203 | { | 4205 | { |
4204 | struct net_device *dev = platform_get_drvdata(pdev); | 4206 | struct net_device *dev = platform_get_drvdata(pdev); |
4207 | struct device_node *dn = pdev->dev.of_node; | ||
4205 | struct mvneta_port *pp = netdev_priv(dev); | 4208 | struct mvneta_port *pp = netdev_priv(dev); |
4206 | 4209 | ||
4207 | unregister_netdev(dev); | 4210 | unregister_netdev(dev); |
@@ -4209,6 +4212,8 @@ static int mvneta_remove(struct platform_device *pdev) | |||
4209 | clk_disable_unprepare(pp->clk); | 4212 | clk_disable_unprepare(pp->clk); |
4210 | free_percpu(pp->ports); | 4213 | free_percpu(pp->ports); |
4211 | free_percpu(pp->stats); | 4214 | free_percpu(pp->stats); |
4215 | if (of_phy_is_fixed_link(dn)) | ||
4216 | of_phy_deregister_fixed_link(dn); | ||
4212 | irq_dispose_mapping(dev->irq); | 4217 | irq_dispose_mapping(dev->irq); |
4213 | of_node_put(pp->phy_node); | 4218 | of_node_put(pp->phy_node); |
4214 | free_netdev(dev); | 4219 | free_netdev(dev); |
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 4a62ffd7729d..86a89cbd3ec9 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c | |||
@@ -318,6 +318,8 @@ static int mtk_phy_connect(struct net_device *dev) | |||
318 | return 0; | 318 | return 0; |
319 | 319 | ||
320 | err_phy: | 320 | err_phy: |
321 | if (of_phy_is_fixed_link(mac->of_node)) | ||
322 | of_phy_deregister_fixed_link(mac->of_node); | ||
321 | of_node_put(np); | 323 | of_node_put(np); |
322 | dev_err(eth->dev, "%s: invalid phy\n", __func__); | 324 | dev_err(eth->dev, "%s: invalid phy\n", __func__); |
323 | return -EINVAL; | 325 | return -EINVAL; |
@@ -1923,6 +1925,8 @@ static void mtk_uninit(struct net_device *dev) | |||
1923 | struct mtk_eth *eth = mac->hw; | 1925 | struct mtk_eth *eth = mac->hw; |
1924 | 1926 | ||
1925 | phy_disconnect(dev->phydev); | 1927 | phy_disconnect(dev->phydev); |
1928 | if (of_phy_is_fixed_link(mac->of_node)) | ||
1929 | of_phy_deregister_fixed_link(mac->of_node); | ||
1926 | mtk_irq_disable(eth, MTK_QDMA_INT_MASK, ~0); | 1930 | mtk_irq_disable(eth, MTK_QDMA_INT_MASK, ~0); |
1927 | mtk_irq_disable(eth, MTK_PDMA_INT_MASK, ~0); | 1931 | mtk_irq_disable(eth, MTK_PDMA_INT_MASK, ~0); |
1928 | } | 1932 | } |
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index a60f635da78b..fb8bb027b69c 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c | |||
@@ -2079,13 +2079,6 @@ err: | |||
2079 | return -ENOMEM; | 2079 | return -ENOMEM; |
2080 | } | 2080 | } |
2081 | 2081 | ||
2082 | static void mlx4_en_shutdown(struct net_device *dev) | ||
2083 | { | ||
2084 | rtnl_lock(); | ||
2085 | netif_device_detach(dev); | ||
2086 | mlx4_en_close(dev); | ||
2087 | rtnl_unlock(); | ||
2088 | } | ||
2089 | 2082 | ||
2090 | static int mlx4_en_copy_priv(struct mlx4_en_priv *dst, | 2083 | static int mlx4_en_copy_priv(struct mlx4_en_priv *dst, |
2091 | struct mlx4_en_priv *src, | 2084 | struct mlx4_en_priv *src, |
@@ -2162,8 +2155,6 @@ void mlx4_en_destroy_netdev(struct net_device *dev) | |||
2162 | { | 2155 | { |
2163 | struct mlx4_en_priv *priv = netdev_priv(dev); | 2156 | struct mlx4_en_priv *priv = netdev_priv(dev); |
2164 | struct mlx4_en_dev *mdev = priv->mdev; | 2157 | struct mlx4_en_dev *mdev = priv->mdev; |
2165 | bool shutdown = mdev->dev->persist->interface_state & | ||
2166 | MLX4_INTERFACE_STATE_SHUTDOWN; | ||
2167 | 2158 | ||
2168 | en_dbg(DRV, priv, "Destroying netdev on port:%d\n", priv->port); | 2159 | en_dbg(DRV, priv, "Destroying netdev on port:%d\n", priv->port); |
2169 | 2160 | ||
@@ -2171,10 +2162,7 @@ void mlx4_en_destroy_netdev(struct net_device *dev) | |||
2171 | if (priv->registered) { | 2162 | if (priv->registered) { |
2172 | devlink_port_type_clear(mlx4_get_devlink_port(mdev->dev, | 2163 | devlink_port_type_clear(mlx4_get_devlink_port(mdev->dev, |
2173 | priv->port)); | 2164 | priv->port)); |
2174 | if (shutdown) | 2165 | unregister_netdev(dev); |
2175 | mlx4_en_shutdown(dev); | ||
2176 | else | ||
2177 | unregister_netdev(dev); | ||
2178 | } | 2166 | } |
2179 | 2167 | ||
2180 | if (priv->allocated) | 2168 | if (priv->allocated) |
@@ -2203,8 +2191,7 @@ void mlx4_en_destroy_netdev(struct net_device *dev) | |||
2203 | kfree(priv->tx_ring); | 2191 | kfree(priv->tx_ring); |
2204 | kfree(priv->tx_cq); | 2192 | kfree(priv->tx_cq); |
2205 | 2193 | ||
2206 | if (!shutdown) | 2194 | free_netdev(dev); |
2207 | free_netdev(dev); | ||
2208 | } | 2195 | } |
2209 | 2196 | ||
2210 | static int mlx4_en_change_mtu(struct net_device *dev, int new_mtu) | 2197 | static int mlx4_en_change_mtu(struct net_device *dev, int new_mtu) |
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c index 6f4e67bc3538..75d07fa9d0b1 100644 --- a/drivers/net/ethernet/mellanox/mlx4/main.c +++ b/drivers/net/ethernet/mellanox/mlx4/main.c | |||
@@ -4147,11 +4147,8 @@ static void mlx4_shutdown(struct pci_dev *pdev) | |||
4147 | 4147 | ||
4148 | mlx4_info(persist->dev, "mlx4_shutdown was called\n"); | 4148 | mlx4_info(persist->dev, "mlx4_shutdown was called\n"); |
4149 | mutex_lock(&persist->interface_state_mutex); | 4149 | mutex_lock(&persist->interface_state_mutex); |
4150 | if (persist->interface_state & MLX4_INTERFACE_STATE_UP) { | 4150 | if (persist->interface_state & MLX4_INTERFACE_STATE_UP) |
4151 | /* Notify mlx4 clients that the kernel is being shut down */ | ||
4152 | persist->interface_state |= MLX4_INTERFACE_STATE_SHUTDOWN; | ||
4153 | mlx4_unload_one(pdev); | 4151 | mlx4_unload_one(pdev); |
4154 | } | ||
4155 | mutex_unlock(&persist->interface_state_mutex); | 4152 | mutex_unlock(&persist->interface_state_mutex); |
4156 | } | 4153 | } |
4157 | 4154 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx4/mcg.c b/drivers/net/ethernet/mellanox/mlx4/mcg.c index 94b891c118c1..1a670b681555 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mcg.c +++ b/drivers/net/ethernet/mellanox/mlx4/mcg.c | |||
@@ -1457,7 +1457,12 @@ EXPORT_SYMBOL_GPL(mlx4_multicast_detach); | |||
1457 | int mlx4_flow_steer_promisc_add(struct mlx4_dev *dev, u8 port, | 1457 | int mlx4_flow_steer_promisc_add(struct mlx4_dev *dev, u8 port, |
1458 | u32 qpn, enum mlx4_net_trans_promisc_mode mode) | 1458 | u32 qpn, enum mlx4_net_trans_promisc_mode mode) |
1459 | { | 1459 | { |
1460 | struct mlx4_net_trans_rule rule; | 1460 | struct mlx4_net_trans_rule rule = { |
1461 | .queue_mode = MLX4_NET_TRANS_Q_FIFO, | ||
1462 | .exclusive = 0, | ||
1463 | .allow_loopback = 1, | ||
1464 | }; | ||
1465 | |||
1461 | u64 *regid_p; | 1466 | u64 *regid_p; |
1462 | 1467 | ||
1463 | switch (mode) { | 1468 | switch (mode) { |
diff --git a/drivers/net/ethernet/qualcomm/emac/emac-phy.c b/drivers/net/ethernet/qualcomm/emac/emac-phy.c index da4e90db4d98..99a14df28b96 100644 --- a/drivers/net/ethernet/qualcomm/emac/emac-phy.c +++ b/drivers/net/ethernet/qualcomm/emac/emac-phy.c | |||
@@ -212,6 +212,7 @@ int emac_phy_config(struct platform_device *pdev, struct emac_adapter *adpt) | |||
212 | 212 | ||
213 | phy_np = of_parse_phandle(np, "phy-handle", 0); | 213 | phy_np = of_parse_phandle(np, "phy-handle", 0); |
214 | adpt->phydev = of_phy_find_device(phy_np); | 214 | adpt->phydev = of_phy_find_device(phy_np); |
215 | of_node_put(phy_np); | ||
215 | } | 216 | } |
216 | 217 | ||
217 | if (!adpt->phydev) { | 218 | if (!adpt->phydev) { |
diff --git a/drivers/net/ethernet/qualcomm/emac/emac.c b/drivers/net/ethernet/qualcomm/emac/emac.c index 4fede4b86538..57b35aeac51a 100644 --- a/drivers/net/ethernet/qualcomm/emac/emac.c +++ b/drivers/net/ethernet/qualcomm/emac/emac.c | |||
@@ -711,6 +711,8 @@ static int emac_probe(struct platform_device *pdev) | |||
711 | err_undo_napi: | 711 | err_undo_napi: |
712 | netif_napi_del(&adpt->rx_q.napi); | 712 | netif_napi_del(&adpt->rx_q.napi); |
713 | err_undo_mdiobus: | 713 | err_undo_mdiobus: |
714 | if (!has_acpi_companion(&pdev->dev)) | ||
715 | put_device(&adpt->phydev->mdio.dev); | ||
714 | mdiobus_unregister(adpt->mii_bus); | 716 | mdiobus_unregister(adpt->mii_bus); |
715 | err_undo_clocks: | 717 | err_undo_clocks: |
716 | emac_clks_teardown(adpt); | 718 | emac_clks_teardown(adpt); |
@@ -730,6 +732,8 @@ static int emac_remove(struct platform_device *pdev) | |||
730 | 732 | ||
731 | emac_clks_teardown(adpt); | 733 | emac_clks_teardown(adpt); |
732 | 734 | ||
735 | if (!has_acpi_companion(&pdev->dev)) | ||
736 | put_device(&adpt->phydev->mdio.dev); | ||
733 | mdiobus_unregister(adpt->mii_bus); | 737 | mdiobus_unregister(adpt->mii_bus); |
734 | free_netdev(netdev); | 738 | free_netdev(netdev); |
735 | 739 | ||
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 630536bc72f9..d6a217874a8b 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c | |||
@@ -1008,20 +1008,18 @@ static int ravb_phy_init(struct net_device *ndev) | |||
1008 | of_node_put(pn); | 1008 | of_node_put(pn); |
1009 | if (!phydev) { | 1009 | if (!phydev) { |
1010 | netdev_err(ndev, "failed to connect PHY\n"); | 1010 | netdev_err(ndev, "failed to connect PHY\n"); |
1011 | return -ENOENT; | 1011 | err = -ENOENT; |
1012 | goto err_deregister_fixed_link; | ||
1012 | } | 1013 | } |
1013 | 1014 | ||
1014 | /* This driver only support 10/100Mbit speeds on Gen3 | 1015 | /* This driver only support 10/100Mbit speeds on Gen3 |
1015 | * at this time. | 1016 | * at this time. |
1016 | */ | 1017 | */ |
1017 | if (priv->chip_id == RCAR_GEN3) { | 1018 | if (priv->chip_id == RCAR_GEN3) { |
1018 | int err; | ||
1019 | |||
1020 | err = phy_set_max_speed(phydev, SPEED_100); | 1019 | err = phy_set_max_speed(phydev, SPEED_100); |
1021 | if (err) { | 1020 | if (err) { |
1022 | netdev_err(ndev, "failed to limit PHY to 100Mbit/s\n"); | 1021 | netdev_err(ndev, "failed to limit PHY to 100Mbit/s\n"); |
1023 | phy_disconnect(phydev); | 1022 | goto err_phy_disconnect; |
1024 | return err; | ||
1025 | } | 1023 | } |
1026 | 1024 | ||
1027 | netdev_info(ndev, "limited PHY to 100Mbit/s\n"); | 1025 | netdev_info(ndev, "limited PHY to 100Mbit/s\n"); |
@@ -1033,6 +1031,14 @@ static int ravb_phy_init(struct net_device *ndev) | |||
1033 | phy_attached_info(phydev); | 1031 | phy_attached_info(phydev); |
1034 | 1032 | ||
1035 | return 0; | 1033 | return 0; |
1034 | |||
1035 | err_phy_disconnect: | ||
1036 | phy_disconnect(phydev); | ||
1037 | err_deregister_fixed_link: | ||
1038 | if (of_phy_is_fixed_link(np)) | ||
1039 | of_phy_deregister_fixed_link(np); | ||
1040 | |||
1041 | return err; | ||
1036 | } | 1042 | } |
1037 | 1043 | ||
1038 | /* PHY control start function */ | 1044 | /* PHY control start function */ |
@@ -1634,6 +1640,7 @@ static void ravb_set_rx_mode(struct net_device *ndev) | |||
1634 | /* Device close function for Ethernet AVB */ | 1640 | /* Device close function for Ethernet AVB */ |
1635 | static int ravb_close(struct net_device *ndev) | 1641 | static int ravb_close(struct net_device *ndev) |
1636 | { | 1642 | { |
1643 | struct device_node *np = ndev->dev.parent->of_node; | ||
1637 | struct ravb_private *priv = netdev_priv(ndev); | 1644 | struct ravb_private *priv = netdev_priv(ndev); |
1638 | struct ravb_tstamp_skb *ts_skb, *ts_skb2; | 1645 | struct ravb_tstamp_skb *ts_skb, *ts_skb2; |
1639 | 1646 | ||
@@ -1663,6 +1670,8 @@ static int ravb_close(struct net_device *ndev) | |||
1663 | if (ndev->phydev) { | 1670 | if (ndev->phydev) { |
1664 | phy_stop(ndev->phydev); | 1671 | phy_stop(ndev->phydev); |
1665 | phy_disconnect(ndev->phydev); | 1672 | phy_disconnect(ndev->phydev); |
1673 | if (of_phy_is_fixed_link(np)) | ||
1674 | of_phy_deregister_fixed_link(np); | ||
1666 | } | 1675 | } |
1667 | 1676 | ||
1668 | if (priv->chip_id != RCAR_GEN2) { | 1677 | if (priv->chip_id != RCAR_GEN2) { |
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 05b0dc55de77..1a92de705199 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c | |||
@@ -518,7 +518,7 @@ static struct sh_eth_cpu_data r7s72100_data = { | |||
518 | 518 | ||
519 | .ecsr_value = ECSR_ICD, | 519 | .ecsr_value = ECSR_ICD, |
520 | .ecsipr_value = ECSIPR_ICDIP, | 520 | .ecsipr_value = ECSIPR_ICDIP, |
521 | .eesipr_value = 0xff7f009f, | 521 | .eesipr_value = 0xe77f009f, |
522 | 522 | ||
523 | .tx_check = EESR_TC1 | EESR_FTC, | 523 | .tx_check = EESR_TC1 | EESR_FTC, |
524 | .eesr_err_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_RABT | | 524 | .eesr_err_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_RABT | |
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c index b1e5f24708c9..e6e6c2fcc4b7 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c | |||
@@ -50,10 +50,23 @@ static int dwmac_generic_probe(struct platform_device *pdev) | |||
50 | if (plat_dat->init) { | 50 | if (plat_dat->init) { |
51 | ret = plat_dat->init(pdev, plat_dat->bsp_priv); | 51 | ret = plat_dat->init(pdev, plat_dat->bsp_priv); |
52 | if (ret) | 52 | if (ret) |
53 | return ret; | 53 | goto err_remove_config_dt; |
54 | } | 54 | } |
55 | 55 | ||
56 | return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | 56 | ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); |
57 | if (ret) | ||
58 | goto err_exit; | ||
59 | |||
60 | return 0; | ||
61 | |||
62 | err_exit: | ||
63 | if (plat_dat->exit) | ||
64 | plat_dat->exit(pdev, plat_dat->bsp_priv); | ||
65 | err_remove_config_dt: | ||
66 | if (pdev->dev.of_node) | ||
67 | stmmac_remove_config_dt(pdev, plat_dat); | ||
68 | |||
69 | return ret; | ||
57 | } | 70 | } |
58 | 71 | ||
59 | static const struct of_device_id dwmac_generic_match[] = { | 72 | static const struct of_device_id dwmac_generic_match[] = { |
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c index 36d3355f2fb0..866444b6c82f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c | |||
@@ -271,15 +271,17 @@ static int ipq806x_gmac_probe(struct platform_device *pdev) | |||
271 | return PTR_ERR(plat_dat); | 271 | return PTR_ERR(plat_dat); |
272 | 272 | ||
273 | gmac = devm_kzalloc(dev, sizeof(*gmac), GFP_KERNEL); | 273 | gmac = devm_kzalloc(dev, sizeof(*gmac), GFP_KERNEL); |
274 | if (!gmac) | 274 | if (!gmac) { |
275 | return -ENOMEM; | 275 | err = -ENOMEM; |
276 | goto err_remove_config_dt; | ||
277 | } | ||
276 | 278 | ||
277 | gmac->pdev = pdev; | 279 | gmac->pdev = pdev; |
278 | 280 | ||
279 | err = ipq806x_gmac_of_parse(gmac); | 281 | err = ipq806x_gmac_of_parse(gmac); |
280 | if (err) { | 282 | if (err) { |
281 | dev_err(dev, "device tree parsing error\n"); | 283 | dev_err(dev, "device tree parsing error\n"); |
282 | return err; | 284 | goto err_remove_config_dt; |
283 | } | 285 | } |
284 | 286 | ||
285 | regmap_write(gmac->qsgmii_csr, QSGMII_PCS_CAL_LCKDT_CTL, | 287 | regmap_write(gmac->qsgmii_csr, QSGMII_PCS_CAL_LCKDT_CTL, |
@@ -300,7 +302,8 @@ static int ipq806x_gmac_probe(struct platform_device *pdev) | |||
300 | default: | 302 | default: |
301 | dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n", | 303 | dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n", |
302 | phy_modes(gmac->phy_mode)); | 304 | phy_modes(gmac->phy_mode)); |
303 | return -EINVAL; | 305 | err = -EINVAL; |
306 | goto err_remove_config_dt; | ||
304 | } | 307 | } |
305 | regmap_write(gmac->nss_common, NSS_COMMON_GMAC_CTL(gmac->id), val); | 308 | regmap_write(gmac->nss_common, NSS_COMMON_GMAC_CTL(gmac->id), val); |
306 | 309 | ||
@@ -319,7 +322,8 @@ static int ipq806x_gmac_probe(struct platform_device *pdev) | |||
319 | default: | 322 | default: |
320 | dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n", | 323 | dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n", |
321 | phy_modes(gmac->phy_mode)); | 324 | phy_modes(gmac->phy_mode)); |
322 | return -EINVAL; | 325 | err = -EINVAL; |
326 | goto err_remove_config_dt; | ||
323 | } | 327 | } |
324 | regmap_write(gmac->nss_common, NSS_COMMON_CLK_SRC_CTRL, val); | 328 | regmap_write(gmac->nss_common, NSS_COMMON_CLK_SRC_CTRL, val); |
325 | 329 | ||
@@ -346,7 +350,16 @@ static int ipq806x_gmac_probe(struct platform_device *pdev) | |||
346 | plat_dat->bsp_priv = gmac; | 350 | plat_dat->bsp_priv = gmac; |
347 | plat_dat->fix_mac_speed = ipq806x_gmac_fix_mac_speed; | 351 | plat_dat->fix_mac_speed = ipq806x_gmac_fix_mac_speed; |
348 | 352 | ||
349 | return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | 353 | err = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); |
354 | if (err) | ||
355 | goto err_remove_config_dt; | ||
356 | |||
357 | return 0; | ||
358 | |||
359 | err_remove_config_dt: | ||
360 | stmmac_remove_config_dt(pdev, plat_dat); | ||
361 | |||
362 | return err; | ||
350 | } | 363 | } |
351 | 364 | ||
352 | static const struct of_device_id ipq806x_gmac_dwmac_match[] = { | 365 | static const struct of_device_id ipq806x_gmac_dwmac_match[] = { |
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c index 78e9d1861896..3d3f43d91b98 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c | |||
@@ -46,7 +46,8 @@ static int lpc18xx_dwmac_probe(struct platform_device *pdev) | |||
46 | reg = syscon_regmap_lookup_by_compatible("nxp,lpc1850-creg"); | 46 | reg = syscon_regmap_lookup_by_compatible("nxp,lpc1850-creg"); |
47 | if (IS_ERR(reg)) { | 47 | if (IS_ERR(reg)) { |
48 | dev_err(&pdev->dev, "syscon lookup failed\n"); | 48 | dev_err(&pdev->dev, "syscon lookup failed\n"); |
49 | return PTR_ERR(reg); | 49 | ret = PTR_ERR(reg); |
50 | goto err_remove_config_dt; | ||
50 | } | 51 | } |
51 | 52 | ||
52 | if (plat_dat->interface == PHY_INTERFACE_MODE_MII) { | 53 | if (plat_dat->interface == PHY_INTERFACE_MODE_MII) { |
@@ -55,13 +56,23 @@ static int lpc18xx_dwmac_probe(struct platform_device *pdev) | |||
55 | ethmode = LPC18XX_CREG_CREG6_ETHMODE_RMII; | 56 | ethmode = LPC18XX_CREG_CREG6_ETHMODE_RMII; |
56 | } else { | 57 | } else { |
57 | dev_err(&pdev->dev, "Only MII and RMII mode supported\n"); | 58 | dev_err(&pdev->dev, "Only MII and RMII mode supported\n"); |
58 | return -EINVAL; | 59 | ret = -EINVAL; |
60 | goto err_remove_config_dt; | ||
59 | } | 61 | } |
60 | 62 | ||
61 | regmap_update_bits(reg, LPC18XX_CREG_CREG6, | 63 | regmap_update_bits(reg, LPC18XX_CREG_CREG6, |
62 | LPC18XX_CREG_CREG6_ETHMODE_MASK, ethmode); | 64 | LPC18XX_CREG_CREG6_ETHMODE_MASK, ethmode); |
63 | 65 | ||
64 | return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | 66 | ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); |
67 | if (ret) | ||
68 | goto err_remove_config_dt; | ||
69 | |||
70 | return 0; | ||
71 | |||
72 | err_remove_config_dt: | ||
73 | stmmac_remove_config_dt(pdev, plat_dat); | ||
74 | |||
75 | return ret; | ||
65 | } | 76 | } |
66 | 77 | ||
67 | static const struct of_device_id lpc18xx_dwmac_match[] = { | 78 | static const struct of_device_id lpc18xx_dwmac_match[] = { |
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c index 309d99536a2c..7fdd1760a74c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c | |||
@@ -64,18 +64,31 @@ static int meson6_dwmac_probe(struct platform_device *pdev) | |||
64 | return PTR_ERR(plat_dat); | 64 | return PTR_ERR(plat_dat); |
65 | 65 | ||
66 | dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); | 66 | dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); |
67 | if (!dwmac) | 67 | if (!dwmac) { |
68 | return -ENOMEM; | 68 | ret = -ENOMEM; |
69 | goto err_remove_config_dt; | ||
70 | } | ||
69 | 71 | ||
70 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 72 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
71 | dwmac->reg = devm_ioremap_resource(&pdev->dev, res); | 73 | dwmac->reg = devm_ioremap_resource(&pdev->dev, res); |
72 | if (IS_ERR(dwmac->reg)) | 74 | if (IS_ERR(dwmac->reg)) { |
73 | return PTR_ERR(dwmac->reg); | 75 | ret = PTR_ERR(dwmac->reg); |
76 | goto err_remove_config_dt; | ||
77 | } | ||
74 | 78 | ||
75 | plat_dat->bsp_priv = dwmac; | 79 | plat_dat->bsp_priv = dwmac; |
76 | plat_dat->fix_mac_speed = meson6_dwmac_fix_mac_speed; | 80 | plat_dat->fix_mac_speed = meson6_dwmac_fix_mac_speed; |
77 | 81 | ||
78 | return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | 82 | ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); |
83 | if (ret) | ||
84 | goto err_remove_config_dt; | ||
85 | |||
86 | return 0; | ||
87 | |||
88 | err_remove_config_dt: | ||
89 | stmmac_remove_config_dt(pdev, plat_dat); | ||
90 | |||
91 | return ret; | ||
79 | } | 92 | } |
80 | 93 | ||
81 | static const struct of_device_id meson6_dwmac_match[] = { | 94 | static const struct of_device_id meson6_dwmac_match[] = { |
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c index 250e4ceafc8d..ffaed1f35efe 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c | |||
@@ -264,32 +264,48 @@ static int meson8b_dwmac_probe(struct platform_device *pdev) | |||
264 | return PTR_ERR(plat_dat); | 264 | return PTR_ERR(plat_dat); |
265 | 265 | ||
266 | dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); | 266 | dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); |
267 | if (!dwmac) | 267 | if (!dwmac) { |
268 | return -ENOMEM; | 268 | ret = -ENOMEM; |
269 | goto err_remove_config_dt; | ||
270 | } | ||
269 | 271 | ||
270 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 272 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
271 | dwmac->regs = devm_ioremap_resource(&pdev->dev, res); | 273 | dwmac->regs = devm_ioremap_resource(&pdev->dev, res); |
272 | if (IS_ERR(dwmac->regs)) | 274 | if (IS_ERR(dwmac->regs)) { |
273 | return PTR_ERR(dwmac->regs); | 275 | ret = PTR_ERR(dwmac->regs); |
276 | goto err_remove_config_dt; | ||
277 | } | ||
274 | 278 | ||
275 | dwmac->pdev = pdev; | 279 | dwmac->pdev = pdev; |
276 | dwmac->phy_mode = of_get_phy_mode(pdev->dev.of_node); | 280 | dwmac->phy_mode = of_get_phy_mode(pdev->dev.of_node); |
277 | if (dwmac->phy_mode < 0) { | 281 | if (dwmac->phy_mode < 0) { |
278 | dev_err(&pdev->dev, "missing phy-mode property\n"); | 282 | dev_err(&pdev->dev, "missing phy-mode property\n"); |
279 | return -EINVAL; | 283 | ret = -EINVAL; |
284 | goto err_remove_config_dt; | ||
280 | } | 285 | } |
281 | 286 | ||
282 | ret = meson8b_init_clk(dwmac); | 287 | ret = meson8b_init_clk(dwmac); |
283 | if (ret) | 288 | if (ret) |
284 | return ret; | 289 | goto err_remove_config_dt; |
285 | 290 | ||
286 | ret = meson8b_init_prg_eth(dwmac); | 291 | ret = meson8b_init_prg_eth(dwmac); |
287 | if (ret) | 292 | if (ret) |
288 | return ret; | 293 | goto err_remove_config_dt; |
289 | 294 | ||
290 | plat_dat->bsp_priv = dwmac; | 295 | plat_dat->bsp_priv = dwmac; |
291 | 296 | ||
292 | return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | 297 | ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); |
298 | if (ret) | ||
299 | goto err_clk_disable; | ||
300 | |||
301 | return 0; | ||
302 | |||
303 | err_clk_disable: | ||
304 | clk_disable_unprepare(dwmac->m25_div_clk); | ||
305 | err_remove_config_dt: | ||
306 | stmmac_remove_config_dt(pdev, plat_dat); | ||
307 | |||
308 | return ret; | ||
293 | } | 309 | } |
294 | 310 | ||
295 | static int meson8b_dwmac_remove(struct platform_device *pdev) | 311 | static int meson8b_dwmac_remove(struct platform_device *pdev) |
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c index 3740a4417fa0..d80c88bd2bba 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | |||
@@ -981,14 +981,27 @@ static int rk_gmac_probe(struct platform_device *pdev) | |||
981 | plat_dat->resume = rk_gmac_resume; | 981 | plat_dat->resume = rk_gmac_resume; |
982 | 982 | ||
983 | plat_dat->bsp_priv = rk_gmac_setup(pdev, data); | 983 | plat_dat->bsp_priv = rk_gmac_setup(pdev, data); |
984 | if (IS_ERR(plat_dat->bsp_priv)) | 984 | if (IS_ERR(plat_dat->bsp_priv)) { |
985 | return PTR_ERR(plat_dat->bsp_priv); | 985 | ret = PTR_ERR(plat_dat->bsp_priv); |
986 | goto err_remove_config_dt; | ||
987 | } | ||
986 | 988 | ||
987 | ret = rk_gmac_init(pdev, plat_dat->bsp_priv); | 989 | ret = rk_gmac_init(pdev, plat_dat->bsp_priv); |
988 | if (ret) | 990 | if (ret) |
989 | return ret; | 991 | goto err_remove_config_dt; |
992 | |||
993 | ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | ||
994 | if (ret) | ||
995 | goto err_gmac_exit; | ||
996 | |||
997 | return 0; | ||
998 | |||
999 | err_gmac_exit: | ||
1000 | rk_gmac_exit(pdev, plat_dat->bsp_priv); | ||
1001 | err_remove_config_dt: | ||
1002 | stmmac_remove_config_dt(pdev, plat_dat); | ||
990 | 1003 | ||
991 | return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | 1004 | return ret; |
992 | } | 1005 | } |
993 | 1006 | ||
994 | static const struct of_device_id rk_gmac_dwmac_match[] = { | 1007 | static const struct of_device_id rk_gmac_dwmac_match[] = { |
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c index bec6963ac71e..0c420e97de1e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c | |||
@@ -304,6 +304,8 @@ static int socfpga_dwmac_probe(struct platform_device *pdev) | |||
304 | struct device *dev = &pdev->dev; | 304 | struct device *dev = &pdev->dev; |
305 | int ret; | 305 | int ret; |
306 | struct socfpga_dwmac *dwmac; | 306 | struct socfpga_dwmac *dwmac; |
307 | struct net_device *ndev; | ||
308 | struct stmmac_priv *stpriv; | ||
307 | 309 | ||
308 | ret = stmmac_get_platform_resources(pdev, &stmmac_res); | 310 | ret = stmmac_get_platform_resources(pdev, &stmmac_res); |
309 | if (ret) | 311 | if (ret) |
@@ -314,32 +316,43 @@ static int socfpga_dwmac_probe(struct platform_device *pdev) | |||
314 | return PTR_ERR(plat_dat); | 316 | return PTR_ERR(plat_dat); |
315 | 317 | ||
316 | dwmac = devm_kzalloc(dev, sizeof(*dwmac), GFP_KERNEL); | 318 | dwmac = devm_kzalloc(dev, sizeof(*dwmac), GFP_KERNEL); |
317 | if (!dwmac) | 319 | if (!dwmac) { |
318 | return -ENOMEM; | 320 | ret = -ENOMEM; |
321 | goto err_remove_config_dt; | ||
322 | } | ||
319 | 323 | ||
320 | ret = socfpga_dwmac_parse_data(dwmac, dev); | 324 | ret = socfpga_dwmac_parse_data(dwmac, dev); |
321 | if (ret) { | 325 | if (ret) { |
322 | dev_err(dev, "Unable to parse OF data\n"); | 326 | dev_err(dev, "Unable to parse OF data\n"); |
323 | return ret; | 327 | goto err_remove_config_dt; |
324 | } | 328 | } |
325 | 329 | ||
326 | plat_dat->bsp_priv = dwmac; | 330 | plat_dat->bsp_priv = dwmac; |
327 | plat_dat->fix_mac_speed = socfpga_dwmac_fix_mac_speed; | 331 | plat_dat->fix_mac_speed = socfpga_dwmac_fix_mac_speed; |
328 | 332 | ||
329 | ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | 333 | ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); |
334 | if (ret) | ||
335 | goto err_remove_config_dt; | ||
330 | 336 | ||
331 | if (!ret) { | 337 | ndev = platform_get_drvdata(pdev); |
332 | struct net_device *ndev = platform_get_drvdata(pdev); | 338 | stpriv = netdev_priv(ndev); |
333 | struct stmmac_priv *stpriv = netdev_priv(ndev); | ||
334 | 339 | ||
335 | /* The socfpga driver needs to control the stmmac reset to | 340 | /* The socfpga driver needs to control the stmmac reset to set the phy |
336 | * set the phy mode. Create a copy of the core reset handel | 341 | * mode. Create a copy of the core reset handle so it can be used by |
337 | * so it can be used by the driver later. | 342 | * the driver later. |
338 | */ | 343 | */ |
339 | dwmac->stmmac_rst = stpriv->stmmac_rst; | 344 | dwmac->stmmac_rst = stpriv->stmmac_rst; |
340 | 345 | ||
341 | ret = socfpga_dwmac_set_phy_mode(dwmac); | 346 | ret = socfpga_dwmac_set_phy_mode(dwmac); |
342 | } | 347 | if (ret) |
348 | goto err_dvr_remove; | ||
349 | |||
350 | return 0; | ||
351 | |||
352 | err_dvr_remove: | ||
353 | stmmac_dvr_remove(&pdev->dev); | ||
354 | err_remove_config_dt: | ||
355 | stmmac_remove_config_dt(pdev, plat_dat); | ||
343 | 356 | ||
344 | return ret; | 357 | return ret; |
345 | } | 358 | } |
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c index 58c05acc2aab..060b98c37a85 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c | |||
@@ -345,13 +345,15 @@ static int sti_dwmac_probe(struct platform_device *pdev) | |||
345 | return PTR_ERR(plat_dat); | 345 | return PTR_ERR(plat_dat); |
346 | 346 | ||
347 | dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); | 347 | dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); |
348 | if (!dwmac) | 348 | if (!dwmac) { |
349 | return -ENOMEM; | 349 | ret = -ENOMEM; |
350 | goto err_remove_config_dt; | ||
351 | } | ||
350 | 352 | ||
351 | ret = sti_dwmac_parse_data(dwmac, pdev); | 353 | ret = sti_dwmac_parse_data(dwmac, pdev); |
352 | if (ret) { | 354 | if (ret) { |
353 | dev_err(&pdev->dev, "Unable to parse OF data\n"); | 355 | dev_err(&pdev->dev, "Unable to parse OF data\n"); |
354 | return ret; | 356 | goto err_remove_config_dt; |
355 | } | 357 | } |
356 | 358 | ||
357 | dwmac->fix_retime_src = data->fix_retime_src; | 359 | dwmac->fix_retime_src = data->fix_retime_src; |
@@ -363,9 +365,20 @@ static int sti_dwmac_probe(struct platform_device *pdev) | |||
363 | 365 | ||
364 | ret = sti_dwmac_init(pdev, plat_dat->bsp_priv); | 366 | ret = sti_dwmac_init(pdev, plat_dat->bsp_priv); |
365 | if (ret) | 367 | if (ret) |
366 | return ret; | 368 | goto err_remove_config_dt; |
369 | |||
370 | ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | ||
371 | if (ret) | ||
372 | goto err_dwmac_exit; | ||
373 | |||
374 | return 0; | ||
375 | |||
376 | err_dwmac_exit: | ||
377 | sti_dwmac_exit(pdev, plat_dat->bsp_priv); | ||
378 | err_remove_config_dt: | ||
379 | stmmac_remove_config_dt(pdev, plat_dat); | ||
367 | 380 | ||
368 | return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | 381 | return ret; |
369 | } | 382 | } |
370 | 383 | ||
371 | static const struct sti_dwmac_of_data stih4xx_dwmac_data = { | 384 | static const struct sti_dwmac_of_data stih4xx_dwmac_data = { |
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c index e5a926b8bee7..61cb24810d10 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c | |||
@@ -107,24 +107,33 @@ static int stm32_dwmac_probe(struct platform_device *pdev) | |||
107 | return PTR_ERR(plat_dat); | 107 | return PTR_ERR(plat_dat); |
108 | 108 | ||
109 | dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); | 109 | dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); |
110 | if (!dwmac) | 110 | if (!dwmac) { |
111 | return -ENOMEM; | 111 | ret = -ENOMEM; |
112 | goto err_remove_config_dt; | ||
113 | } | ||
112 | 114 | ||
113 | ret = stm32_dwmac_parse_data(dwmac, &pdev->dev); | 115 | ret = stm32_dwmac_parse_data(dwmac, &pdev->dev); |
114 | if (ret) { | 116 | if (ret) { |
115 | dev_err(&pdev->dev, "Unable to parse OF data\n"); | 117 | dev_err(&pdev->dev, "Unable to parse OF data\n"); |
116 | return ret; | 118 | goto err_remove_config_dt; |
117 | } | 119 | } |
118 | 120 | ||
119 | plat_dat->bsp_priv = dwmac; | 121 | plat_dat->bsp_priv = dwmac; |
120 | 122 | ||
121 | ret = stm32_dwmac_init(plat_dat); | 123 | ret = stm32_dwmac_init(plat_dat); |
122 | if (ret) | 124 | if (ret) |
123 | return ret; | 125 | goto err_remove_config_dt; |
124 | 126 | ||
125 | ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | 127 | ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); |
126 | if (ret) | 128 | if (ret) |
127 | stm32_dwmac_clk_disable(dwmac); | 129 | goto err_clk_disable; |
130 | |||
131 | return 0; | ||
132 | |||
133 | err_clk_disable: | ||
134 | stm32_dwmac_clk_disable(dwmac); | ||
135 | err_remove_config_dt: | ||
136 | stmmac_remove_config_dt(pdev, plat_dat); | ||
128 | 137 | ||
129 | return ret; | 138 | return ret; |
130 | } | 139 | } |
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c index adff46375a32..d07520fb969e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c | |||
@@ -120,22 +120,27 @@ static int sun7i_gmac_probe(struct platform_device *pdev) | |||
120 | return PTR_ERR(plat_dat); | 120 | return PTR_ERR(plat_dat); |
121 | 121 | ||
122 | gmac = devm_kzalloc(dev, sizeof(*gmac), GFP_KERNEL); | 122 | gmac = devm_kzalloc(dev, sizeof(*gmac), GFP_KERNEL); |
123 | if (!gmac) | 123 | if (!gmac) { |
124 | return -ENOMEM; | 124 | ret = -ENOMEM; |
125 | goto err_remove_config_dt; | ||
126 | } | ||
125 | 127 | ||
126 | gmac->interface = of_get_phy_mode(dev->of_node); | 128 | gmac->interface = of_get_phy_mode(dev->of_node); |
127 | 129 | ||
128 | gmac->tx_clk = devm_clk_get(dev, "allwinner_gmac_tx"); | 130 | gmac->tx_clk = devm_clk_get(dev, "allwinner_gmac_tx"); |
129 | if (IS_ERR(gmac->tx_clk)) { | 131 | if (IS_ERR(gmac->tx_clk)) { |
130 | dev_err(dev, "could not get tx clock\n"); | 132 | dev_err(dev, "could not get tx clock\n"); |
131 | return PTR_ERR(gmac->tx_clk); | 133 | ret = PTR_ERR(gmac->tx_clk); |
134 | goto err_remove_config_dt; | ||
132 | } | 135 | } |
133 | 136 | ||
134 | /* Optional regulator for PHY */ | 137 | /* Optional regulator for PHY */ |
135 | gmac->regulator = devm_regulator_get_optional(dev, "phy"); | 138 | gmac->regulator = devm_regulator_get_optional(dev, "phy"); |
136 | if (IS_ERR(gmac->regulator)) { | 139 | if (IS_ERR(gmac->regulator)) { |
137 | if (PTR_ERR(gmac->regulator) == -EPROBE_DEFER) | 140 | if (PTR_ERR(gmac->regulator) == -EPROBE_DEFER) { |
138 | return -EPROBE_DEFER; | 141 | ret = -EPROBE_DEFER; |
142 | goto err_remove_config_dt; | ||
143 | } | ||
139 | dev_info(dev, "no regulator found\n"); | 144 | dev_info(dev, "no regulator found\n"); |
140 | gmac->regulator = NULL; | 145 | gmac->regulator = NULL; |
141 | } | 146 | } |
@@ -151,11 +156,18 @@ static int sun7i_gmac_probe(struct platform_device *pdev) | |||
151 | 156 | ||
152 | ret = sun7i_gmac_init(pdev, plat_dat->bsp_priv); | 157 | ret = sun7i_gmac_init(pdev, plat_dat->bsp_priv); |
153 | if (ret) | 158 | if (ret) |
154 | return ret; | 159 | goto err_remove_config_dt; |
155 | 160 | ||
156 | ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | 161 | ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); |
157 | if (ret) | 162 | if (ret) |
158 | sun7i_gmac_exit(pdev, plat_dat->bsp_priv); | 163 | goto err_gmac_exit; |
164 | |||
165 | return 0; | ||
166 | |||
167 | err_gmac_exit: | ||
168 | sun7i_gmac_exit(pdev, plat_dat->bsp_priv); | ||
169 | err_remove_config_dt: | ||
170 | stmmac_remove_config_dt(pdev, plat_dat); | ||
159 | 171 | ||
160 | return ret; | 172 | return ret; |
161 | } | 173 | } |
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 1f9ec02fa7f8..caf069a465f2 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | |||
@@ -3416,7 +3416,6 @@ int stmmac_dvr_remove(struct device *dev) | |||
3416 | stmmac_set_mac(priv->ioaddr, false); | 3416 | stmmac_set_mac(priv->ioaddr, false); |
3417 | netif_carrier_off(ndev); | 3417 | netif_carrier_off(ndev); |
3418 | unregister_netdev(ndev); | 3418 | unregister_netdev(ndev); |
3419 | of_node_put(priv->plat->phy_node); | ||
3420 | if (priv->stmmac_rst) | 3419 | if (priv->stmmac_rst) |
3421 | reset_control_assert(priv->stmmac_rst); | 3420 | reset_control_assert(priv->stmmac_rst); |
3422 | clk_disable_unprepare(priv->pclk); | 3421 | clk_disable_unprepare(priv->pclk); |
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index 0a0d6a86f397..a840818bf4df 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | |||
@@ -200,7 +200,6 @@ static int stmmac_dt_phy(struct plat_stmmacenet_data *plat, | |||
200 | /** | 200 | /** |
201 | * stmmac_probe_config_dt - parse device-tree driver parameters | 201 | * stmmac_probe_config_dt - parse device-tree driver parameters |
202 | * @pdev: platform_device structure | 202 | * @pdev: platform_device structure |
203 | * @plat: driver data platform structure | ||
204 | * @mac: MAC address to use | 203 | * @mac: MAC address to use |
205 | * Description: | 204 | * Description: |
206 | * this function is to read the driver parameters from device-tree and | 205 | * this function is to read the driver parameters from device-tree and |
@@ -306,7 +305,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) | |||
306 | dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*dma_cfg), | 305 | dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*dma_cfg), |
307 | GFP_KERNEL); | 306 | GFP_KERNEL); |
308 | if (!dma_cfg) { | 307 | if (!dma_cfg) { |
309 | of_node_put(plat->phy_node); | 308 | stmmac_remove_config_dt(pdev, plat); |
310 | return ERR_PTR(-ENOMEM); | 309 | return ERR_PTR(-ENOMEM); |
311 | } | 310 | } |
312 | plat->dma_cfg = dma_cfg; | 311 | plat->dma_cfg = dma_cfg; |
@@ -329,14 +328,37 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) | |||
329 | 328 | ||
330 | return plat; | 329 | return plat; |
331 | } | 330 | } |
331 | |||
332 | /** | ||
333 | * stmmac_remove_config_dt - undo the effects of stmmac_probe_config_dt() | ||
334 | * @pdev: platform_device structure | ||
335 | * @plat: driver data platform structure | ||
336 | * | ||
337 | * Release resources claimed by stmmac_probe_config_dt(). | ||
338 | */ | ||
339 | void stmmac_remove_config_dt(struct platform_device *pdev, | ||
340 | struct plat_stmmacenet_data *plat) | ||
341 | { | ||
342 | struct device_node *np = pdev->dev.of_node; | ||
343 | |||
344 | if (of_phy_is_fixed_link(np)) | ||
345 | of_phy_deregister_fixed_link(np); | ||
346 | of_node_put(plat->phy_node); | ||
347 | } | ||
332 | #else | 348 | #else |
333 | struct plat_stmmacenet_data * | 349 | struct plat_stmmacenet_data * |
334 | stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) | 350 | stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) |
335 | { | 351 | { |
336 | return ERR_PTR(-ENOSYS); | 352 | return ERR_PTR(-ENOSYS); |
337 | } | 353 | } |
354 | |||
355 | void stmmac_remove_config_dt(struct platform_device *pdev, | ||
356 | struct plat_stmmacenet_data *plat) | ||
357 | { | ||
358 | } | ||
338 | #endif /* CONFIG_OF */ | 359 | #endif /* CONFIG_OF */ |
339 | EXPORT_SYMBOL_GPL(stmmac_probe_config_dt); | 360 | EXPORT_SYMBOL_GPL(stmmac_probe_config_dt); |
361 | EXPORT_SYMBOL_GPL(stmmac_remove_config_dt); | ||
340 | 362 | ||
341 | int stmmac_get_platform_resources(struct platform_device *pdev, | 363 | int stmmac_get_platform_resources(struct platform_device *pdev, |
342 | struct stmmac_resources *stmmac_res) | 364 | struct stmmac_resources *stmmac_res) |
@@ -392,10 +414,13 @@ int stmmac_pltfr_remove(struct platform_device *pdev) | |||
392 | { | 414 | { |
393 | struct net_device *ndev = platform_get_drvdata(pdev); | 415 | struct net_device *ndev = platform_get_drvdata(pdev); |
394 | struct stmmac_priv *priv = netdev_priv(ndev); | 416 | struct stmmac_priv *priv = netdev_priv(ndev); |
417 | struct plat_stmmacenet_data *plat = priv->plat; | ||
395 | int ret = stmmac_dvr_remove(&pdev->dev); | 418 | int ret = stmmac_dvr_remove(&pdev->dev); |
396 | 419 | ||
397 | if (priv->plat->exit) | 420 | if (plat->exit) |
398 | priv->plat->exit(pdev, priv->plat->bsp_priv); | 421 | plat->exit(pdev, plat->bsp_priv); |
422 | |||
423 | stmmac_remove_config_dt(pdev, plat); | ||
399 | 424 | ||
400 | return ret; | 425 | return ret; |
401 | } | 426 | } |
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h index 64e147f53a9c..b72eb0de57b7 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h | |||
@@ -23,6 +23,8 @@ | |||
23 | 23 | ||
24 | struct plat_stmmacenet_data * | 24 | struct plat_stmmacenet_data * |
25 | stmmac_probe_config_dt(struct platform_device *pdev, const char **mac); | 25 | stmmac_probe_config_dt(struct platform_device *pdev, const char **mac); |
26 | void stmmac_remove_config_dt(struct platform_device *pdev, | ||
27 | struct plat_stmmacenet_data *plat); | ||
26 | 28 | ||
27 | int stmmac_get_platform_resources(struct platform_device *pdev, | 29 | int stmmac_get_platform_resources(struct platform_device *pdev, |
28 | struct stmmac_resources *stmmac_res); | 30 | struct stmmac_resources *stmmac_res); |
diff --git a/drivers/net/ethernet/synopsys/dwc_eth_qos.c b/drivers/net/ethernet/synopsys/dwc_eth_qos.c index 4ba2421e625d..97d64bfed465 100644 --- a/drivers/net/ethernet/synopsys/dwc_eth_qos.c +++ b/drivers/net/ethernet/synopsys/dwc_eth_qos.c | |||
@@ -2881,7 +2881,7 @@ static int dwceqos_probe(struct platform_device *pdev) | |||
2881 | ret = of_get_phy_mode(lp->pdev->dev.of_node); | 2881 | ret = of_get_phy_mode(lp->pdev->dev.of_node); |
2882 | if (ret < 0) { | 2882 | if (ret < 0) { |
2883 | dev_err(&lp->pdev->dev, "error in getting phy i/f\n"); | 2883 | dev_err(&lp->pdev->dev, "error in getting phy i/f\n"); |
2884 | goto err_out_clk_dis_phy; | 2884 | goto err_out_deregister_fixed_link; |
2885 | } | 2885 | } |
2886 | 2886 | ||
2887 | lp->phy_interface = ret; | 2887 | lp->phy_interface = ret; |
@@ -2889,14 +2889,14 @@ static int dwceqos_probe(struct platform_device *pdev) | |||
2889 | ret = dwceqos_mii_init(lp); | 2889 | ret = dwceqos_mii_init(lp); |
2890 | if (ret) { | 2890 | if (ret) { |
2891 | dev_err(&lp->pdev->dev, "error in dwceqos_mii_init\n"); | 2891 | dev_err(&lp->pdev->dev, "error in dwceqos_mii_init\n"); |
2892 | goto err_out_clk_dis_phy; | 2892 | goto err_out_deregister_fixed_link; |
2893 | } | 2893 | } |
2894 | 2894 | ||
2895 | ret = dwceqos_mii_probe(ndev); | 2895 | ret = dwceqos_mii_probe(ndev); |
2896 | if (ret != 0) { | 2896 | if (ret != 0) { |
2897 | netdev_err(ndev, "mii_probe fail.\n"); | 2897 | netdev_err(ndev, "mii_probe fail.\n"); |
2898 | ret = -ENXIO; | 2898 | ret = -ENXIO; |
2899 | goto err_out_clk_dis_phy; | 2899 | goto err_out_deregister_fixed_link; |
2900 | } | 2900 | } |
2901 | 2901 | ||
2902 | dwceqos_set_umac_addr(lp, lp->ndev->dev_addr, 0); | 2902 | dwceqos_set_umac_addr(lp, lp->ndev->dev_addr, 0); |
@@ -2914,7 +2914,7 @@ static int dwceqos_probe(struct platform_device *pdev) | |||
2914 | if (ret) { | 2914 | if (ret) { |
2915 | dev_err(&lp->pdev->dev, "Unable to retrieve DT, error %d\n", | 2915 | dev_err(&lp->pdev->dev, "Unable to retrieve DT, error %d\n", |
2916 | ret); | 2916 | ret); |
2917 | goto err_out_clk_dis_phy; | 2917 | goto err_out_deregister_fixed_link; |
2918 | } | 2918 | } |
2919 | dev_info(&lp->pdev->dev, "pdev->id %d, baseaddr 0x%08lx, irq %d\n", | 2919 | dev_info(&lp->pdev->dev, "pdev->id %d, baseaddr 0x%08lx, irq %d\n", |
2920 | pdev->id, ndev->base_addr, ndev->irq); | 2920 | pdev->id, ndev->base_addr, ndev->irq); |
@@ -2924,7 +2924,7 @@ static int dwceqos_probe(struct platform_device *pdev) | |||
2924 | if (ret) { | 2924 | if (ret) { |
2925 | dev_err(&lp->pdev->dev, "Unable to request IRQ %d, error %d\n", | 2925 | dev_err(&lp->pdev->dev, "Unable to request IRQ %d, error %d\n", |
2926 | ndev->irq, ret); | 2926 | ndev->irq, ret); |
2927 | goto err_out_clk_dis_phy; | 2927 | goto err_out_deregister_fixed_link; |
2928 | } | 2928 | } |
2929 | 2929 | ||
2930 | if (netif_msg_probe(lp)) | 2930 | if (netif_msg_probe(lp)) |
@@ -2935,11 +2935,14 @@ static int dwceqos_probe(struct platform_device *pdev) | |||
2935 | ret = register_netdev(ndev); | 2935 | ret = register_netdev(ndev); |
2936 | if (ret) { | 2936 | if (ret) { |
2937 | dev_err(&pdev->dev, "Cannot register net device, aborting.\n"); | 2937 | dev_err(&pdev->dev, "Cannot register net device, aborting.\n"); |
2938 | goto err_out_clk_dis_phy; | 2938 | goto err_out_deregister_fixed_link; |
2939 | } | 2939 | } |
2940 | 2940 | ||
2941 | return 0; | 2941 | return 0; |
2942 | 2942 | ||
2943 | err_out_deregister_fixed_link: | ||
2944 | if (of_phy_is_fixed_link(pdev->dev.of_node)) | ||
2945 | of_phy_deregister_fixed_link(pdev->dev.of_node); | ||
2943 | err_out_clk_dis_phy: | 2946 | err_out_clk_dis_phy: |
2944 | clk_disable_unprepare(lp->phy_ref_clk); | 2947 | clk_disable_unprepare(lp->phy_ref_clk); |
2945 | err_out_clk_dis_aper: | 2948 | err_out_clk_dis_aper: |
@@ -2959,8 +2962,11 @@ static int dwceqos_remove(struct platform_device *pdev) | |||
2959 | if (ndev) { | 2962 | if (ndev) { |
2960 | lp = netdev_priv(ndev); | 2963 | lp = netdev_priv(ndev); |
2961 | 2964 | ||
2962 | if (ndev->phydev) | 2965 | if (ndev->phydev) { |
2963 | phy_disconnect(ndev->phydev); | 2966 | phy_disconnect(ndev->phydev); |
2967 | if (of_phy_is_fixed_link(pdev->dev.of_node)) | ||
2968 | of_phy_deregister_fixed_link(pdev->dev.of_node); | ||
2969 | } | ||
2964 | mdiobus_unregister(lp->mii_bus); | 2970 | mdiobus_unregister(lp->mii_bus); |
2965 | mdiobus_free(lp->mii_bus); | 2971 | mdiobus_free(lp->mii_bus); |
2966 | 2972 | ||
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 58947aae31c7..b9087b828eff 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c | |||
@@ -2459,20 +2459,8 @@ static void cpsw_remove_dt(struct platform_device *pdev) | |||
2459 | if (strcmp(slave_node->name, "slave")) | 2459 | if (strcmp(slave_node->name, "slave")) |
2460 | continue; | 2460 | continue; |
2461 | 2461 | ||
2462 | if (of_phy_is_fixed_link(slave_node)) { | 2462 | if (of_phy_is_fixed_link(slave_node)) |
2463 | struct phy_device *phydev; | 2463 | of_phy_deregister_fixed_link(slave_node); |
2464 | |||
2465 | phydev = of_phy_find_device(slave_node); | ||
2466 | if (phydev) { | ||
2467 | fixed_phy_unregister(phydev); | ||
2468 | /* Put references taken by | ||
2469 | * of_phy_find_device() and | ||
2470 | * of_phy_register_fixed_link(). | ||
2471 | */ | ||
2472 | phy_device_free(phydev); | ||
2473 | phy_device_free(phydev); | ||
2474 | } | ||
2475 | } | ||
2476 | 2464 | ||
2477 | of_node_put(slave_data->phy_node); | 2465 | of_node_put(slave_data->phy_node); |
2478 | 2466 | ||
@@ -2942,6 +2930,8 @@ static int cpsw_resume(struct device *dev) | |||
2942 | /* Select default pin state */ | 2930 | /* Select default pin state */ |
2943 | pinctrl_pm_select_default_state(dev); | 2931 | pinctrl_pm_select_default_state(dev); |
2944 | 2932 | ||
2933 | /* shut up ASSERT_RTNL() warning in netif_set_real_num_tx/rx_queues */ | ||
2934 | rtnl_lock(); | ||
2945 | if (cpsw->data.dual_emac) { | 2935 | if (cpsw->data.dual_emac) { |
2946 | int i; | 2936 | int i; |
2947 | 2937 | ||
@@ -2953,6 +2943,8 @@ static int cpsw_resume(struct device *dev) | |||
2953 | if (netif_running(ndev)) | 2943 | if (netif_running(ndev)) |
2954 | cpsw_ndo_open(ndev); | 2944 | cpsw_ndo_open(ndev); |
2955 | } | 2945 | } |
2946 | rtnl_unlock(); | ||
2947 | |||
2956 | return 0; | 2948 | return 0; |
2957 | } | 2949 | } |
2958 | #endif | 2950 | #endif |
diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c index 84fbe5714f8b..481c7bf0395b 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c | |||
@@ -1767,6 +1767,7 @@ static int davinci_emac_try_get_mac(struct platform_device *pdev, | |||
1767 | */ | 1767 | */ |
1768 | static int davinci_emac_probe(struct platform_device *pdev) | 1768 | static int davinci_emac_probe(struct platform_device *pdev) |
1769 | { | 1769 | { |
1770 | struct device_node *np = pdev->dev.of_node; | ||
1770 | int rc = 0; | 1771 | int rc = 0; |
1771 | struct resource *res, *res_ctrl; | 1772 | struct resource *res, *res_ctrl; |
1772 | struct net_device *ndev; | 1773 | struct net_device *ndev; |
@@ -1805,7 +1806,7 @@ static int davinci_emac_probe(struct platform_device *pdev) | |||
1805 | if (!pdata) { | 1806 | if (!pdata) { |
1806 | dev_err(&pdev->dev, "no platform data\n"); | 1807 | dev_err(&pdev->dev, "no platform data\n"); |
1807 | rc = -ENODEV; | 1808 | rc = -ENODEV; |
1808 | goto no_pdata; | 1809 | goto err_free_netdev; |
1809 | } | 1810 | } |
1810 | 1811 | ||
1811 | /* MAC addr and PHY mask , RMII enable info from platform_data */ | 1812 | /* MAC addr and PHY mask , RMII enable info from platform_data */ |
@@ -1941,6 +1942,10 @@ no_cpdma_chan: | |||
1941 | cpdma_chan_destroy(priv->rxchan); | 1942 | cpdma_chan_destroy(priv->rxchan); |
1942 | cpdma_ctlr_destroy(priv->dma); | 1943 | cpdma_ctlr_destroy(priv->dma); |
1943 | no_pdata: | 1944 | no_pdata: |
1945 | if (of_phy_is_fixed_link(np)) | ||
1946 | of_phy_deregister_fixed_link(np); | ||
1947 | of_node_put(priv->phy_node); | ||
1948 | err_free_netdev: | ||
1944 | free_netdev(ndev); | 1949 | free_netdev(ndev); |
1945 | return rc; | 1950 | return rc; |
1946 | } | 1951 | } |
@@ -1956,6 +1961,7 @@ static int davinci_emac_remove(struct platform_device *pdev) | |||
1956 | { | 1961 | { |
1957 | struct net_device *ndev = platform_get_drvdata(pdev); | 1962 | struct net_device *ndev = platform_get_drvdata(pdev); |
1958 | struct emac_priv *priv = netdev_priv(ndev); | 1963 | struct emac_priv *priv = netdev_priv(ndev); |
1964 | struct device_node *np = pdev->dev.of_node; | ||
1959 | 1965 | ||
1960 | dev_notice(&ndev->dev, "DaVinci EMAC: davinci_emac_remove()\n"); | 1966 | dev_notice(&ndev->dev, "DaVinci EMAC: davinci_emac_remove()\n"); |
1961 | 1967 | ||
@@ -1968,6 +1974,8 @@ static int davinci_emac_remove(struct platform_device *pdev) | |||
1968 | unregister_netdev(ndev); | 1974 | unregister_netdev(ndev); |
1969 | of_node_put(priv->phy_node); | 1975 | of_node_put(priv->phy_node); |
1970 | pm_runtime_disable(&pdev->dev); | 1976 | pm_runtime_disable(&pdev->dev); |
1977 | if (of_phy_is_fixed_link(np)) | ||
1978 | of_phy_deregister_fixed_link(np); | ||
1971 | free_netdev(ndev); | 1979 | free_netdev(ndev); |
1972 | 1980 | ||
1973 | return 0; | 1981 | return 0; |
diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c index 42edd7b7902f..8b4822ad27cb 100644 --- a/drivers/net/geneve.c +++ b/drivers/net/geneve.c | |||
@@ -859,7 +859,6 @@ static netdev_tx_t geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev, | |||
859 | struct geneve_dev *geneve = netdev_priv(dev); | 859 | struct geneve_dev *geneve = netdev_priv(dev); |
860 | struct geneve_sock *gs4; | 860 | struct geneve_sock *gs4; |
861 | struct rtable *rt = NULL; | 861 | struct rtable *rt = NULL; |
862 | const struct iphdr *iip; /* interior IP header */ | ||
863 | int err = -EINVAL; | 862 | int err = -EINVAL; |
864 | struct flowi4 fl4; | 863 | struct flowi4 fl4; |
865 | __u8 tos, ttl; | 864 | __u8 tos, ttl; |
@@ -890,8 +889,6 @@ static netdev_tx_t geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev, | |||
890 | sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true); | 889 | sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true); |
891 | skb_reset_mac_header(skb); | 890 | skb_reset_mac_header(skb); |
892 | 891 | ||
893 | iip = ip_hdr(skb); | ||
894 | |||
895 | if (info) { | 892 | if (info) { |
896 | const struct ip_tunnel_key *key = &info->key; | 893 | const struct ip_tunnel_key *key = &info->key; |
897 | u8 *opts = NULL; | 894 | u8 *opts = NULL; |
@@ -911,7 +908,7 @@ static netdev_tx_t geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev, | |||
911 | if (unlikely(err)) | 908 | if (unlikely(err)) |
912 | goto tx_error; | 909 | goto tx_error; |
913 | 910 | ||
914 | tos = ip_tunnel_ecn_encap(key->tos, iip, skb); | 911 | tos = ip_tunnel_ecn_encap(key->tos, ip_hdr(skb), skb); |
915 | ttl = key->ttl; | 912 | ttl = key->ttl; |
916 | df = key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0; | 913 | df = key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0; |
917 | } else { | 914 | } else { |
@@ -920,7 +917,7 @@ static netdev_tx_t geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev, | |||
920 | if (unlikely(err)) | 917 | if (unlikely(err)) |
921 | goto tx_error; | 918 | goto tx_error; |
922 | 919 | ||
923 | tos = ip_tunnel_ecn_encap(fl4.flowi4_tos, iip, skb); | 920 | tos = ip_tunnel_ecn_encap(fl4.flowi4_tos, ip_hdr(skb), skb); |
924 | ttl = geneve->ttl; | 921 | ttl = geneve->ttl; |
925 | if (!ttl && IN_MULTICAST(ntohl(fl4.daddr))) | 922 | if (!ttl && IN_MULTICAST(ntohl(fl4.daddr))) |
926 | ttl = 1; | 923 | ttl = 1; |
@@ -952,7 +949,6 @@ static netdev_tx_t geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev, | |||
952 | { | 949 | { |
953 | struct geneve_dev *geneve = netdev_priv(dev); | 950 | struct geneve_dev *geneve = netdev_priv(dev); |
954 | struct dst_entry *dst = NULL; | 951 | struct dst_entry *dst = NULL; |
955 | const struct iphdr *iip; /* interior IP header */ | ||
956 | struct geneve_sock *gs6; | 952 | struct geneve_sock *gs6; |
957 | int err = -EINVAL; | 953 | int err = -EINVAL; |
958 | struct flowi6 fl6; | 954 | struct flowi6 fl6; |
@@ -982,8 +978,6 @@ static netdev_tx_t geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev, | |||
982 | sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true); | 978 | sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true); |
983 | skb_reset_mac_header(skb); | 979 | skb_reset_mac_header(skb); |
984 | 980 | ||
985 | iip = ip_hdr(skb); | ||
986 | |||
987 | if (info) { | 981 | if (info) { |
988 | const struct ip_tunnel_key *key = &info->key; | 982 | const struct ip_tunnel_key *key = &info->key; |
989 | u8 *opts = NULL; | 983 | u8 *opts = NULL; |
@@ -1004,7 +998,7 @@ static netdev_tx_t geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev, | |||
1004 | if (unlikely(err)) | 998 | if (unlikely(err)) |
1005 | goto tx_error; | 999 | goto tx_error; |
1006 | 1000 | ||
1007 | prio = ip_tunnel_ecn_encap(key->tos, iip, skb); | 1001 | prio = ip_tunnel_ecn_encap(key->tos, ip_hdr(skb), skb); |
1008 | ttl = key->ttl; | 1002 | ttl = key->ttl; |
1009 | label = info->key.label; | 1003 | label = info->key.label; |
1010 | } else { | 1004 | } else { |
@@ -1014,7 +1008,7 @@ static netdev_tx_t geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev, | |||
1014 | goto tx_error; | 1008 | goto tx_error; |
1015 | 1009 | ||
1016 | prio = ip_tunnel_ecn_encap(ip6_tclass(fl6.flowlabel), | 1010 | prio = ip_tunnel_ecn_encap(ip6_tclass(fl6.flowlabel), |
1017 | iip, skb); | 1011 | ip_hdr(skb), skb); |
1018 | ttl = geneve->ttl; | 1012 | ttl = geneve->ttl; |
1019 | if (!ttl && ipv6_addr_is_multicast(&fl6.daddr)) | 1013 | if (!ttl && ipv6_addr_is_multicast(&fl6.daddr)) |
1020 | ttl = 1; | 1014 | ttl = 1; |
diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c index f442eb366863..0fef17874d50 100644 --- a/drivers/net/ipvlan/ipvlan_main.c +++ b/drivers/net/ipvlan/ipvlan_main.c | |||
@@ -497,6 +497,7 @@ static int ipvlan_link_new(struct net *src_net, struct net_device *dev, | |||
497 | struct net_device *phy_dev; | 497 | struct net_device *phy_dev; |
498 | int err; | 498 | int err; |
499 | u16 mode = IPVLAN_MODE_L3; | 499 | u16 mode = IPVLAN_MODE_L3; |
500 | bool create = false; | ||
500 | 501 | ||
501 | if (!tb[IFLA_LINK]) | 502 | if (!tb[IFLA_LINK]) |
502 | return -EINVAL; | 503 | return -EINVAL; |
@@ -513,6 +514,7 @@ static int ipvlan_link_new(struct net *src_net, struct net_device *dev, | |||
513 | err = ipvlan_port_create(phy_dev); | 514 | err = ipvlan_port_create(phy_dev); |
514 | if (err < 0) | 515 | if (err < 0) |
515 | return err; | 516 | return err; |
517 | create = true; | ||
516 | } | 518 | } |
517 | 519 | ||
518 | if (data && data[IFLA_IPVLAN_MODE]) | 520 | if (data && data[IFLA_IPVLAN_MODE]) |
@@ -536,22 +538,27 @@ static int ipvlan_link_new(struct net *src_net, struct net_device *dev, | |||
536 | 538 | ||
537 | err = register_netdevice(dev); | 539 | err = register_netdevice(dev); |
538 | if (err < 0) | 540 | if (err < 0) |
539 | return err; | 541 | goto destroy_ipvlan_port; |
540 | 542 | ||
541 | err = netdev_upper_dev_link(phy_dev, dev); | 543 | err = netdev_upper_dev_link(phy_dev, dev); |
542 | if (err) { | 544 | if (err) { |
543 | unregister_netdevice(dev); | 545 | goto unregister_netdev; |
544 | return err; | ||
545 | } | 546 | } |
546 | err = ipvlan_set_port_mode(port, mode); | 547 | err = ipvlan_set_port_mode(port, mode); |
547 | if (err) { | 548 | if (err) { |
548 | unregister_netdevice(dev); | 549 | goto unregister_netdev; |
549 | return err; | ||
550 | } | 550 | } |
551 | 551 | ||
552 | list_add_tail_rcu(&ipvlan->pnode, &port->ipvlans); | 552 | list_add_tail_rcu(&ipvlan->pnode, &port->ipvlans); |
553 | netif_stacked_transfer_operstate(phy_dev, dev); | 553 | netif_stacked_transfer_operstate(phy_dev, dev); |
554 | return 0; | 554 | return 0; |
555 | |||
556 | unregister_netdev: | ||
557 | unregister_netdevice(dev); | ||
558 | destroy_ipvlan_port: | ||
559 | if (create) | ||
560 | ipvlan_port_destroy(phy_dev); | ||
561 | return err; | ||
555 | } | 562 | } |
556 | 563 | ||
557 | static void ipvlan_link_delete(struct net_device *dev, struct list_head *head) | 564 | static void ipvlan_link_delete(struct net_device *dev, struct list_head *head) |
diff --git a/drivers/net/irda/w83977af_ir.c b/drivers/net/irda/w83977af_ir.c index 4e3d2e7c697c..e8c3a8c32534 100644 --- a/drivers/net/irda/w83977af_ir.c +++ b/drivers/net/irda/w83977af_ir.c | |||
@@ -518,7 +518,9 @@ static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb, | |||
518 | 518 | ||
519 | mtt = irda_get_mtt(skb); | 519 | mtt = irda_get_mtt(skb); |
520 | pr_debug("%s(%ld), mtt=%d\n", __func__ , jiffies, mtt); | 520 | pr_debug("%s(%ld), mtt=%d\n", __func__ , jiffies, mtt); |
521 | if (mtt) | 521 | if (mtt > 1000) |
522 | mdelay(mtt/1000); | ||
523 | else if (mtt) | ||
522 | udelay(mtt); | 524 | udelay(mtt); |
523 | 525 | ||
524 | /* Enable DMA interrupt */ | 526 | /* Enable DMA interrupt */ |
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c index 070e3290aa6e..7869b0651576 100644 --- a/drivers/net/macvtap.c +++ b/drivers/net/macvtap.c | |||
@@ -491,7 +491,13 @@ static int macvtap_newlink(struct net *src_net, | |||
491 | /* Don't put anything that may fail after macvlan_common_newlink | 491 | /* Don't put anything that may fail after macvlan_common_newlink |
492 | * because we can't undo what it does. | 492 | * because we can't undo what it does. |
493 | */ | 493 | */ |
494 | return macvlan_common_newlink(src_net, dev, tb, data); | 494 | err = macvlan_common_newlink(src_net, dev, tb, data); |
495 | if (err) { | ||
496 | netdev_rx_handler_unregister(dev); | ||
497 | return err; | ||
498 | } | ||
499 | |||
500 | return 0; | ||
495 | } | 501 | } |
496 | 502 | ||
497 | static void macvtap_dellink(struct net_device *dev, | 503 | static void macvtap_dellink(struct net_device *dev, |
@@ -736,13 +742,8 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, | |||
736 | 742 | ||
737 | if (zerocopy) | 743 | if (zerocopy) |
738 | err = zerocopy_sg_from_iter(skb, from); | 744 | err = zerocopy_sg_from_iter(skb, from); |
739 | else { | 745 | else |
740 | err = skb_copy_datagram_from_iter(skb, 0, from, len); | 746 | err = skb_copy_datagram_from_iter(skb, 0, from, len); |
741 | if (!err && m && m->msg_control) { | ||
742 | struct ubuf_info *uarg = m->msg_control; | ||
743 | uarg->callback(uarg, false); | ||
744 | } | ||
745 | } | ||
746 | 747 | ||
747 | if (err) | 748 | if (err) |
748 | goto err_kfree; | 749 | goto err_kfree; |
@@ -773,7 +774,11 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, | |||
773 | skb_shinfo(skb)->destructor_arg = m->msg_control; | 774 | skb_shinfo(skb)->destructor_arg = m->msg_control; |
774 | skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY; | 775 | skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY; |
775 | skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG; | 776 | skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG; |
777 | } else if (m && m->msg_control) { | ||
778 | struct ubuf_info *uarg = m->msg_control; | ||
779 | uarg->callback(uarg, false); | ||
776 | } | 780 | } |
781 | |||
777 | if (vlan) { | 782 | if (vlan) { |
778 | skb->dev = vlan->dev; | 783 | skb->dev = vlan->dev; |
779 | dev_queue_xmit(skb); | 784 | dev_queue_xmit(skb); |
diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index aadd6e9f54ad..9cbe645e3d89 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c | |||
@@ -102,15 +102,19 @@ static int rtl8211f_config_init(struct phy_device *phydev) | |||
102 | if (ret < 0) | 102 | if (ret < 0) |
103 | return ret; | 103 | return ret; |
104 | 104 | ||
105 | if (phydev->interface == PHY_INTERFACE_MODE_RGMII) { | 105 | phy_write(phydev, RTL8211F_PAGE_SELECT, 0xd08); |
106 | /* enable TXDLY */ | 106 | reg = phy_read(phydev, 0x11); |
107 | phy_write(phydev, RTL8211F_PAGE_SELECT, 0xd08); | 107 | |
108 | reg = phy_read(phydev, 0x11); | 108 | /* enable TX-delay for rgmii-id and rgmii-txid, otherwise disable it */ |
109 | if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || | ||
110 | phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) | ||
109 | reg |= RTL8211F_TX_DELAY; | 111 | reg |= RTL8211F_TX_DELAY; |
110 | phy_write(phydev, 0x11, reg); | 112 | else |
111 | /* restore to default page 0 */ | 113 | reg &= ~RTL8211F_TX_DELAY; |
112 | phy_write(phydev, RTL8211F_PAGE_SELECT, 0x0); | 114 | |
113 | } | 115 | phy_write(phydev, 0x11, reg); |
116 | /* restore to default page 0 */ | ||
117 | phy_write(phydev, RTL8211F_PAGE_SELECT, 0x0); | ||
114 | 118 | ||
115 | return 0; | 119 | return 0; |
116 | } | 120 | } |
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 8093e39ae263..db6acecabeaa 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c | |||
@@ -1246,13 +1246,8 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, | |||
1246 | 1246 | ||
1247 | if (zerocopy) | 1247 | if (zerocopy) |
1248 | err = zerocopy_sg_from_iter(skb, from); | 1248 | err = zerocopy_sg_from_iter(skb, from); |
1249 | else { | 1249 | else |
1250 | err = skb_copy_datagram_from_iter(skb, 0, from, len); | 1250 | err = skb_copy_datagram_from_iter(skb, 0, from, len); |
1251 | if (!err && msg_control) { | ||
1252 | struct ubuf_info *uarg = msg_control; | ||
1253 | uarg->callback(uarg, false); | ||
1254 | } | ||
1255 | } | ||
1256 | 1251 | ||
1257 | if (err) { | 1252 | if (err) { |
1258 | this_cpu_inc(tun->pcpu_stats->rx_dropped); | 1253 | this_cpu_inc(tun->pcpu_stats->rx_dropped); |
@@ -1298,6 +1293,9 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, | |||
1298 | skb_shinfo(skb)->destructor_arg = msg_control; | 1293 | skb_shinfo(skb)->destructor_arg = msg_control; |
1299 | skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY; | 1294 | skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY; |
1300 | skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG; | 1295 | skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG; |
1296 | } else if (msg_control) { | ||
1297 | struct ubuf_info *uarg = msg_control; | ||
1298 | uarg->callback(uarg, false); | ||
1301 | } | 1299 | } |
1302 | 1300 | ||
1303 | skb_reset_network_header(skb); | 1301 | skb_reset_network_header(skb); |
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c index cce24950a0ab..dc7b6392e75a 100644 --- a/drivers/net/usb/asix_devices.c +++ b/drivers/net/usb/asix_devices.c | |||
@@ -603,12 +603,12 @@ static void ax88772_suspend(struct usbnet *dev) | |||
603 | u16 medium; | 603 | u16 medium; |
604 | 604 | ||
605 | /* Stop MAC operation */ | 605 | /* Stop MAC operation */ |
606 | medium = asix_read_medium_status(dev, 0); | 606 | medium = asix_read_medium_status(dev, 1); |
607 | medium &= ~AX_MEDIUM_RE; | 607 | medium &= ~AX_MEDIUM_RE; |
608 | asix_write_medium_mode(dev, medium, 0); | 608 | asix_write_medium_mode(dev, medium, 1); |
609 | 609 | ||
610 | netdev_dbg(dev->net, "ax88772_suspend: medium=0x%04x\n", | 610 | netdev_dbg(dev->net, "ax88772_suspend: medium=0x%04x\n", |
611 | asix_read_medium_status(dev, 0)); | 611 | asix_read_medium_status(dev, 1)); |
612 | 612 | ||
613 | /* Preserve BMCR for restoring */ | 613 | /* Preserve BMCR for restoring */ |
614 | priv->presvd_phy_bmcr = | 614 | priv->presvd_phy_bmcr = |
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c index c47ec0a04c8e..dd623f674487 100644 --- a/drivers/net/usb/cdc_ether.c +++ b/drivers/net/usb/cdc_ether.c | |||
@@ -388,12 +388,6 @@ void usbnet_cdc_status(struct usbnet *dev, struct urb *urb) | |||
388 | case USB_CDC_NOTIFY_NETWORK_CONNECTION: | 388 | case USB_CDC_NOTIFY_NETWORK_CONNECTION: |
389 | netif_dbg(dev, timer, dev->net, "CDC: carrier %s\n", | 389 | netif_dbg(dev, timer, dev->net, "CDC: carrier %s\n", |
390 | event->wValue ? "on" : "off"); | 390 | event->wValue ? "on" : "off"); |
391 | |||
392 | /* Work-around for devices with broken off-notifications */ | ||
393 | if (event->wValue && | ||
394 | !test_bit(__LINK_STATE_NOCARRIER, &dev->net->state)) | ||
395 | usbnet_link_change(dev, 0, 0); | ||
396 | |||
397 | usbnet_link_change(dev, !!event->wValue, 0); | 391 | usbnet_link_change(dev, !!event->wValue, 0); |
398 | break; | 392 | break; |
399 | case USB_CDC_NOTIFY_SPEED_CHANGE: /* tx/rx rates */ | 393 | case USB_CDC_NOTIFY_SPEED_CHANGE: /* tx/rx rates */ |
@@ -466,6 +460,36 @@ static int usbnet_cdc_zte_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | |||
466 | return 1; | 460 | return 1; |
467 | } | 461 | } |
468 | 462 | ||
463 | /* Ensure correct link state | ||
464 | * | ||
465 | * Some devices (ZTE MF823/831/910) export two carrier on notifications when | ||
466 | * connected. This causes the link state to be incorrect. Work around this by | ||
467 | * always setting the state to off, then on. | ||
468 | */ | ||
469 | void usbnet_cdc_zte_status(struct usbnet *dev, struct urb *urb) | ||
470 | { | ||
471 | struct usb_cdc_notification *event; | ||
472 | |||
473 | if (urb->actual_length < sizeof(*event)) | ||
474 | return; | ||
475 | |||
476 | event = urb->transfer_buffer; | ||
477 | |||
478 | if (event->bNotificationType != USB_CDC_NOTIFY_NETWORK_CONNECTION) { | ||
479 | usbnet_cdc_status(dev, urb); | ||
480 | return; | ||
481 | } | ||
482 | |||
483 | netif_dbg(dev, timer, dev->net, "CDC: carrier %s\n", | ||
484 | event->wValue ? "on" : "off"); | ||
485 | |||
486 | if (event->wValue && | ||
487 | netif_carrier_ok(dev->net)) | ||
488 | netif_carrier_off(dev->net); | ||
489 | |||
490 | usbnet_link_change(dev, !!event->wValue, 0); | ||
491 | } | ||
492 | |||
469 | static const struct driver_info cdc_info = { | 493 | static const struct driver_info cdc_info = { |
470 | .description = "CDC Ethernet Device", | 494 | .description = "CDC Ethernet Device", |
471 | .flags = FLAG_ETHER | FLAG_POINTTOPOINT, | 495 | .flags = FLAG_ETHER | FLAG_POINTTOPOINT, |
@@ -481,7 +505,7 @@ static const struct driver_info zte_cdc_info = { | |||
481 | .flags = FLAG_ETHER | FLAG_POINTTOPOINT, | 505 | .flags = FLAG_ETHER | FLAG_POINTTOPOINT, |
482 | .bind = usbnet_cdc_zte_bind, | 506 | .bind = usbnet_cdc_zte_bind, |
483 | .unbind = usbnet_cdc_unbind, | 507 | .unbind = usbnet_cdc_unbind, |
484 | .status = usbnet_cdc_status, | 508 | .status = usbnet_cdc_zte_status, |
485 | .set_rx_mode = usbnet_cdc_update_filter, | 509 | .set_rx_mode = usbnet_cdc_update_filter, |
486 | .manage_power = usbnet_manage_power, | 510 | .manage_power = usbnet_manage_power, |
487 | .rx_fixup = usbnet_cdc_zte_rx_fixup, | 511 | .rx_fixup = usbnet_cdc_zte_rx_fixup, |
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c index 3ff76c6db4f6..6fe1cdb0174f 100644 --- a/drivers/net/usb/qmi_wwan.c +++ b/drivers/net/usb/qmi_wwan.c | |||
@@ -894,6 +894,7 @@ static const struct usb_device_id products[] = { | |||
894 | {QMI_FIXED_INTF(0x1bbb, 0x0203, 2)}, /* Alcatel L800MA */ | 894 | {QMI_FIXED_INTF(0x1bbb, 0x0203, 2)}, /* Alcatel L800MA */ |
895 | {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */ | 895 | {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */ |
896 | {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */ | 896 | {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */ |
897 | {QMI_QUIRK_SET_DTR(0x1bc7, 0x1040, 2)}, /* Telit LE922A */ | ||
897 | {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */ | 898 | {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */ |
898 | {QMI_FIXED_INTF(0x1bc7, 0x1201, 2)}, /* Telit LE920 */ | 899 | {QMI_FIXED_INTF(0x1bc7, 0x1201, 2)}, /* Telit LE920 */ |
899 | {QMI_FIXED_INTF(0x1c9e, 0x9b01, 3)}, /* XS Stick W100-2 from 4G Systems */ | 900 | {QMI_FIXED_INTF(0x1c9e, 0x9b01, 3)}, /* XS Stick W100-2 from 4G Systems */ |
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index 24532cdebb00..2ba01ca02c9c 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c | |||
@@ -611,6 +611,7 @@ static int vxlan_fdb_create(struct vxlan_dev *vxlan, | |||
611 | struct vxlan_rdst *rd = NULL; | 611 | struct vxlan_rdst *rd = NULL; |
612 | struct vxlan_fdb *f; | 612 | struct vxlan_fdb *f; |
613 | int notify = 0; | 613 | int notify = 0; |
614 | int rc; | ||
614 | 615 | ||
615 | f = __vxlan_find_mac(vxlan, mac); | 616 | f = __vxlan_find_mac(vxlan, mac); |
616 | if (f) { | 617 | if (f) { |
@@ -641,8 +642,7 @@ static int vxlan_fdb_create(struct vxlan_dev *vxlan, | |||
641 | if ((flags & NLM_F_APPEND) && | 642 | if ((flags & NLM_F_APPEND) && |
642 | (is_multicast_ether_addr(f->eth_addr) || | 643 | (is_multicast_ether_addr(f->eth_addr) || |
643 | is_zero_ether_addr(f->eth_addr))) { | 644 | is_zero_ether_addr(f->eth_addr))) { |
644 | int rc = vxlan_fdb_append(f, ip, port, vni, ifindex, | 645 | rc = vxlan_fdb_append(f, ip, port, vni, ifindex, &rd); |
645 | &rd); | ||
646 | 646 | ||
647 | if (rc < 0) | 647 | if (rc < 0) |
648 | return rc; | 648 | return rc; |
@@ -673,7 +673,11 @@ static int vxlan_fdb_create(struct vxlan_dev *vxlan, | |||
673 | INIT_LIST_HEAD(&f->remotes); | 673 | INIT_LIST_HEAD(&f->remotes); |
674 | memcpy(f->eth_addr, mac, ETH_ALEN); | 674 | memcpy(f->eth_addr, mac, ETH_ALEN); |
675 | 675 | ||
676 | vxlan_fdb_append(f, ip, port, vni, ifindex, &rd); | 676 | rc = vxlan_fdb_append(f, ip, port, vni, ifindex, &rd); |
677 | if (rc < 0) { | ||
678 | kfree(f); | ||
679 | return rc; | ||
680 | } | ||
677 | 681 | ||
678 | ++vxlan->addrcnt; | 682 | ++vxlan->addrcnt; |
679 | hlist_add_head_rcu(&f->hlist, | 683 | hlist_add_head_rcu(&f->hlist, |
diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c index 39ce76ad00bc..16241d21727b 100644 --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c | |||
@@ -2222,8 +2222,9 @@ done: | |||
2222 | is_scanning_required = 1; | 2222 | is_scanning_required = 1; |
2223 | } else { | 2223 | } else { |
2224 | mwifiex_dbg(priv->adapter, MSG, | 2224 | mwifiex_dbg(priv->adapter, MSG, |
2225 | "info: trying to associate to '%s' bssid %pM\n", | 2225 | "info: trying to associate to '%.*s' bssid %pM\n", |
2226 | (char *)req_ssid.ssid, bss->bssid); | 2226 | req_ssid.ssid_len, (char *)req_ssid.ssid, |
2227 | bss->bssid); | ||
2227 | memcpy(&priv->cfg_bssid, bss->bssid, ETH_ALEN); | 2228 | memcpy(&priv->cfg_bssid, bss->bssid, ETH_ALEN); |
2228 | break; | 2229 | break; |
2229 | } | 2230 | } |
@@ -2283,8 +2284,8 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, | |||
2283 | } | 2284 | } |
2284 | 2285 | ||
2285 | mwifiex_dbg(adapter, INFO, | 2286 | mwifiex_dbg(adapter, INFO, |
2286 | "info: Trying to associate to %s and bssid %pM\n", | 2287 | "info: Trying to associate to %.*s and bssid %pM\n", |
2287 | (char *)sme->ssid, sme->bssid); | 2288 | (int)sme->ssid_len, (char *)sme->ssid, sme->bssid); |
2288 | 2289 | ||
2289 | if (!mwifiex_stop_bg_scan(priv)) | 2290 | if (!mwifiex_stop_bg_scan(priv)) |
2290 | cfg80211_sched_scan_stopped_rtnl(priv->wdev.wiphy); | 2291 | cfg80211_sched_scan_stopped_rtnl(priv->wdev.wiphy); |
@@ -2417,8 +2418,8 @@ mwifiex_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, | |||
2417 | } | 2418 | } |
2418 | 2419 | ||
2419 | mwifiex_dbg(priv->adapter, MSG, | 2420 | mwifiex_dbg(priv->adapter, MSG, |
2420 | "info: trying to join to %s and bssid %pM\n", | 2421 | "info: trying to join to %.*s and bssid %pM\n", |
2421 | (char *)params->ssid, params->bssid); | 2422 | params->ssid_len, (char *)params->ssid, params->bssid); |
2422 | 2423 | ||
2423 | mwifiex_set_ibss_params(priv, params); | 2424 | mwifiex_set_ibss_params(priv, params); |
2424 | 2425 | ||
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c index 5a3145a02547..262281bd68fa 100644 --- a/drivers/of/of_mdio.c +++ b/drivers/of/of_mdio.c | |||
@@ -490,3 +490,18 @@ int of_phy_register_fixed_link(struct device_node *np) | |||
490 | return -ENODEV; | 490 | return -ENODEV; |
491 | } | 491 | } |
492 | EXPORT_SYMBOL(of_phy_register_fixed_link); | 492 | EXPORT_SYMBOL(of_phy_register_fixed_link); |
493 | |||
494 | void of_phy_deregister_fixed_link(struct device_node *np) | ||
495 | { | ||
496 | struct phy_device *phydev; | ||
497 | |||
498 | phydev = of_phy_find_device(np); | ||
499 | if (!phydev) | ||
500 | return; | ||
501 | |||
502 | fixed_phy_unregister(phydev); | ||
503 | |||
504 | put_device(&phydev->mdio.dev); /* of_phy_find_device() */ | ||
505 | phy_device_free(phydev); /* fixed_phy_register() */ | ||
506 | } | ||
507 | EXPORT_SYMBOL(of_phy_deregister_fixed_link); | ||
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h index 3be7abd6e722..c9f379689dd0 100644 --- a/include/linux/mlx4/device.h +++ b/include/linux/mlx4/device.h | |||
@@ -476,7 +476,6 @@ enum { | |||
476 | enum { | 476 | enum { |
477 | MLX4_INTERFACE_STATE_UP = 1 << 0, | 477 | MLX4_INTERFACE_STATE_UP = 1 << 0, |
478 | MLX4_INTERFACE_STATE_DELETION = 1 << 1, | 478 | MLX4_INTERFACE_STATE_DELETION = 1 << 1, |
479 | MLX4_INTERFACE_STATE_SHUTDOWN = 1 << 2, | ||
480 | }; | 479 | }; |
481 | 480 | ||
482 | #define MSTR_SM_CHANGE_MASK (MLX4_EQ_PORT_INFO_MSTR_SM_SL_CHANGE_MASK | \ | 481 | #define MSTR_SM_CHANGE_MASK (MLX4_EQ_PORT_INFO_MSTR_SM_SL_CHANGE_MASK | \ |
diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h index 2ab233661ae5..a58cca8bcb29 100644 --- a/include/linux/of_mdio.h +++ b/include/linux/of_mdio.h | |||
@@ -29,6 +29,7 @@ struct phy_device *of_phy_attach(struct net_device *dev, | |||
29 | extern struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np); | 29 | extern struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np); |
30 | extern int of_mdio_parse_addr(struct device *dev, const struct device_node *np); | 30 | extern int of_mdio_parse_addr(struct device *dev, const struct device_node *np); |
31 | extern int of_phy_register_fixed_link(struct device_node *np); | 31 | extern int of_phy_register_fixed_link(struct device_node *np); |
32 | extern void of_phy_deregister_fixed_link(struct device_node *np); | ||
32 | extern bool of_phy_is_fixed_link(struct device_node *np); | 33 | extern bool of_phy_is_fixed_link(struct device_node *np); |
33 | 34 | ||
34 | #else /* CONFIG_OF */ | 35 | #else /* CONFIG_OF */ |
@@ -83,6 +84,9 @@ static inline int of_phy_register_fixed_link(struct device_node *np) | |||
83 | { | 84 | { |
84 | return -ENOSYS; | 85 | return -ENOSYS; |
85 | } | 86 | } |
87 | static inline void of_phy_deregister_fixed_link(struct device_node *np) | ||
88 | { | ||
89 | } | ||
86 | static inline bool of_phy_is_fixed_link(struct device_node *np) | 90 | static inline bool of_phy_is_fixed_link(struct device_node *np) |
87 | { | 91 | { |
88 | return false; | 92 | return false; |
diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 8fed1cd78658..f11ca837361b 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h | |||
@@ -970,6 +970,8 @@ int compat_ipv6_setsockopt(struct sock *sk, int level, int optname, | |||
970 | int compat_ipv6_getsockopt(struct sock *sk, int level, int optname, | 970 | int compat_ipv6_getsockopt(struct sock *sk, int level, int optname, |
971 | char __user *optval, int __user *optlen); | 971 | char __user *optval, int __user *optlen); |
972 | 972 | ||
973 | int __ip6_datagram_connect(struct sock *sk, struct sockaddr *addr, | ||
974 | int addr_len); | ||
973 | int ip6_datagram_connect(struct sock *sk, struct sockaddr *addr, int addr_len); | 975 | int ip6_datagram_connect(struct sock *sk, struct sockaddr *addr, int addr_len); |
974 | int ip6_datagram_connect_v6_only(struct sock *sk, struct sockaddr *addr, | 976 | int ip6_datagram_connect_v6_only(struct sock *sk, struct sockaddr *addr, |
975 | int addr_len); | 977 | int addr_len); |
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h index 50418052a520..d9d52c020a70 100644 --- a/include/net/netfilter/nf_conntrack.h +++ b/include/net/netfilter/nf_conntrack.h | |||
@@ -100,6 +100,9 @@ struct nf_conn { | |||
100 | 100 | ||
101 | possible_net_t ct_net; | 101 | possible_net_t ct_net; |
102 | 102 | ||
103 | #if IS_ENABLED(CONFIG_NF_NAT) | ||
104 | struct rhlist_head nat_bysource; | ||
105 | #endif | ||
103 | /* all members below initialized via memset */ | 106 | /* all members below initialized via memset */ |
104 | u8 __nfct_init_offset[0]; | 107 | u8 __nfct_init_offset[0]; |
105 | 108 | ||
@@ -117,9 +120,6 @@ struct nf_conn { | |||
117 | /* Extensions */ | 120 | /* Extensions */ |
118 | struct nf_ct_ext *ext; | 121 | struct nf_ct_ext *ext; |
119 | 122 | ||
120 | #if IS_ENABLED(CONFIG_NF_NAT) | ||
121 | struct rhash_head nat_bysource; | ||
122 | #endif | ||
123 | /* Storage reserved for other modules, must be the last member */ | 123 | /* Storage reserved for other modules, must be the last member */ |
124 | union nf_conntrack_proto proto; | 124 | union nf_conntrack_proto proto; |
125 | }; | 125 | }; |
diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h index d79d1e9b9546..b02af0bf5777 100644 --- a/include/net/netfilter/nf_tables.h +++ b/include/net/netfilter/nf_tables.h | |||
@@ -313,7 +313,7 @@ void nft_unregister_set(struct nft_set_ops *ops); | |||
313 | * @size: maximum set size | 313 | * @size: maximum set size |
314 | * @nelems: number of elements | 314 | * @nelems: number of elements |
315 | * @ndeact: number of deactivated elements queued for removal | 315 | * @ndeact: number of deactivated elements queued for removal |
316 | * @timeout: default timeout value in msecs | 316 | * @timeout: default timeout value in jiffies |
317 | * @gc_int: garbage collection interval in msecs | 317 | * @gc_int: garbage collection interval in msecs |
318 | * @policy: set parameterization (see enum nft_set_policies) | 318 | * @policy: set parameterization (see enum nft_set_policies) |
319 | * @udlen: user data length | 319 | * @udlen: user data length |
diff --git a/include/uapi/linux/tc_act/Kbuild b/include/uapi/linux/tc_act/Kbuild index e3969bd939e4..9611c7b6c18f 100644 --- a/include/uapi/linux/tc_act/Kbuild +++ b/include/uapi/linux/tc_act/Kbuild | |||
@@ -11,3 +11,4 @@ header-y += tc_vlan.h | |||
11 | header-y += tc_bpf.h | 11 | header-y += tc_bpf.h |
12 | header-y += tc_connmark.h | 12 | header-y += tc_connmark.h |
13 | header-y += tc_ife.h | 13 | header-y += tc_ife.h |
14 | header-y += tc_tunnel_key.h | ||
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 6a936159c6e0..8199821f54cf 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c | |||
@@ -2454,6 +2454,7 @@ static bool states_equal(struct bpf_verifier_env *env, | |||
2454 | struct bpf_verifier_state *old, | 2454 | struct bpf_verifier_state *old, |
2455 | struct bpf_verifier_state *cur) | 2455 | struct bpf_verifier_state *cur) |
2456 | { | 2456 | { |
2457 | bool varlen_map_access = env->varlen_map_value_access; | ||
2457 | struct bpf_reg_state *rold, *rcur; | 2458 | struct bpf_reg_state *rold, *rcur; |
2458 | int i; | 2459 | int i; |
2459 | 2460 | ||
@@ -2467,12 +2468,17 @@ static bool states_equal(struct bpf_verifier_env *env, | |||
2467 | /* If the ranges were not the same, but everything else was and | 2468 | /* If the ranges were not the same, but everything else was and |
2468 | * we didn't do a variable access into a map then we are a-ok. | 2469 | * we didn't do a variable access into a map then we are a-ok. |
2469 | */ | 2470 | */ |
2470 | if (!env->varlen_map_value_access && | 2471 | if (!varlen_map_access && |
2471 | rold->type == rcur->type && rold->imm == rcur->imm) | 2472 | rold->type == rcur->type && rold->imm == rcur->imm) |
2472 | continue; | 2473 | continue; |
2473 | 2474 | ||
2475 | /* If we didn't map access then again we don't care about the | ||
2476 | * mismatched range values and it's ok if our old type was | ||
2477 | * UNKNOWN and we didn't go to a NOT_INIT'ed reg. | ||
2478 | */ | ||
2474 | if (rold->type == NOT_INIT || | 2479 | if (rold->type == NOT_INIT || |
2475 | (rold->type == UNKNOWN_VALUE && rcur->type != NOT_INIT)) | 2480 | (!varlen_map_access && rold->type == UNKNOWN_VALUE && |
2481 | rcur->type != NOT_INIT)) | ||
2476 | continue; | 2482 | continue; |
2477 | 2483 | ||
2478 | if (rold->type == PTR_TO_PACKET && rcur->type == PTR_TO_PACKET && | 2484 | if (rold->type == PTR_TO_PACKET && rcur->type == PTR_TO_PACKET && |
diff --git a/net/core/flow.c b/net/core/flow.c index 3937b1b68d5b..18e8893d4be5 100644 --- a/net/core/flow.c +++ b/net/core/flow.c | |||
@@ -95,7 +95,6 @@ static void flow_cache_gc_task(struct work_struct *work) | |||
95 | list_for_each_entry_safe(fce, n, &gc_list, u.gc_list) { | 95 | list_for_each_entry_safe(fce, n, &gc_list, u.gc_list) { |
96 | flow_entry_kill(fce, xfrm); | 96 | flow_entry_kill(fce, xfrm); |
97 | atomic_dec(&xfrm->flow_cache_gc_count); | 97 | atomic_dec(&xfrm->flow_cache_gc_count); |
98 | WARN_ON(atomic_read(&xfrm->flow_cache_gc_count) < 0); | ||
99 | } | 98 | } |
100 | } | 99 | } |
101 | 100 | ||
@@ -236,9 +235,8 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir, | |||
236 | if (fcp->hash_count > fc->high_watermark) | 235 | if (fcp->hash_count > fc->high_watermark) |
237 | flow_cache_shrink(fc, fcp); | 236 | flow_cache_shrink(fc, fcp); |
238 | 237 | ||
239 | if (fcp->hash_count > 2 * fc->high_watermark || | 238 | if (atomic_read(&net->xfrm.flow_cache_gc_count) > |
240 | atomic_read(&net->xfrm.flow_cache_gc_count) > fc->high_watermark) { | 239 | 2 * num_online_cpus() * fc->high_watermark) { |
241 | atomic_inc(&net->xfrm.flow_cache_genid); | ||
242 | flo = ERR_PTR(-ENOBUFS); | 240 | flo = ERR_PTR(-ENOBUFS); |
243 | goto ret_object; | 241 | goto ret_object; |
244 | } | 242 | } |
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index deb35acbefd0..a6196cf844f6 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
@@ -931,8 +931,8 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev, | |||
931 | + nla_total_size(4) /* IFLA_PROMISCUITY */ | 931 | + nla_total_size(4) /* IFLA_PROMISCUITY */ |
932 | + nla_total_size(4) /* IFLA_NUM_TX_QUEUES */ | 932 | + nla_total_size(4) /* IFLA_NUM_TX_QUEUES */ |
933 | + nla_total_size(4) /* IFLA_NUM_RX_QUEUES */ | 933 | + nla_total_size(4) /* IFLA_NUM_RX_QUEUES */ |
934 | + nla_total_size(4) /* IFLA_MAX_GSO_SEGS */ | 934 | + nla_total_size(4) /* IFLA_GSO_MAX_SEGS */ |
935 | + nla_total_size(4) /* IFLA_MAX_GSO_SIZE */ | 935 | + nla_total_size(4) /* IFLA_GSO_MAX_SIZE */ |
936 | + nla_total_size(1) /* IFLA_OPERSTATE */ | 936 | + nla_total_size(1) /* IFLA_OPERSTATE */ |
937 | + nla_total_size(1) /* IFLA_LINKMODE */ | 937 | + nla_total_size(1) /* IFLA_LINKMODE */ |
938 | + nla_total_size(4) /* IFLA_CARRIER_CHANGES */ | 938 | + nla_total_size(4) /* IFLA_CARRIER_CHANGES */ |
diff --git a/net/core/sock.c b/net/core/sock.c index 5e3ca414357e..00a074dbfe9b 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -715,7 +715,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname, | |||
715 | val = min_t(u32, val, sysctl_wmem_max); | 715 | val = min_t(u32, val, sysctl_wmem_max); |
716 | set_sndbuf: | 716 | set_sndbuf: |
717 | sk->sk_userlocks |= SOCK_SNDBUF_LOCK; | 717 | sk->sk_userlocks |= SOCK_SNDBUF_LOCK; |
718 | sk->sk_sndbuf = max_t(u32, val * 2, SOCK_MIN_SNDBUF); | 718 | sk->sk_sndbuf = max_t(int, val * 2, SOCK_MIN_SNDBUF); |
719 | /* Wake up sending tasks if we upped the value. */ | 719 | /* Wake up sending tasks if we upped the value. */ |
720 | sk->sk_write_space(sk); | 720 | sk->sk_write_space(sk); |
721 | break; | 721 | break; |
@@ -751,7 +751,7 @@ set_rcvbuf: | |||
751 | * returning the value we actually used in getsockopt | 751 | * returning the value we actually used in getsockopt |
752 | * is the most desirable behavior. | 752 | * is the most desirable behavior. |
753 | */ | 753 | */ |
754 | sk->sk_rcvbuf = max_t(u32, val * 2, SOCK_MIN_RCVBUF); | 754 | sk->sk_rcvbuf = max_t(int, val * 2, SOCK_MIN_RCVBUF); |
755 | break; | 755 | break; |
756 | 756 | ||
757 | case SO_RCVBUFFORCE: | 757 | case SO_RCVBUFFORCE: |
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index b567c8725aea..edbe59d203ef 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c | |||
@@ -700,6 +700,7 @@ int dccp_invalid_packet(struct sk_buff *skb) | |||
700 | { | 700 | { |
701 | const struct dccp_hdr *dh; | 701 | const struct dccp_hdr *dh; |
702 | unsigned int cscov; | 702 | unsigned int cscov; |
703 | u8 dccph_doff; | ||
703 | 704 | ||
704 | if (skb->pkt_type != PACKET_HOST) | 705 | if (skb->pkt_type != PACKET_HOST) |
705 | return 1; | 706 | return 1; |
@@ -721,18 +722,19 @@ int dccp_invalid_packet(struct sk_buff *skb) | |||
721 | /* | 722 | /* |
722 | * If P.Data Offset is too small for packet type, drop packet and return | 723 | * If P.Data Offset is too small for packet type, drop packet and return |
723 | */ | 724 | */ |
724 | if (dh->dccph_doff < dccp_hdr_len(skb) / sizeof(u32)) { | 725 | dccph_doff = dh->dccph_doff; |
725 | DCCP_WARN("P.Data Offset(%u) too small\n", dh->dccph_doff); | 726 | if (dccph_doff < dccp_hdr_len(skb) / sizeof(u32)) { |
727 | DCCP_WARN("P.Data Offset(%u) too small\n", dccph_doff); | ||
726 | return 1; | 728 | return 1; |
727 | } | 729 | } |
728 | /* | 730 | /* |
729 | * If P.Data Offset is too too large for packet, drop packet and return | 731 | * If P.Data Offset is too too large for packet, drop packet and return |
730 | */ | 732 | */ |
731 | if (!pskb_may_pull(skb, dh->dccph_doff * sizeof(u32))) { | 733 | if (!pskb_may_pull(skb, dccph_doff * sizeof(u32))) { |
732 | DCCP_WARN("P.Data Offset(%u) too large\n", dh->dccph_doff); | 734 | DCCP_WARN("P.Data Offset(%u) too large\n", dccph_doff); |
733 | return 1; | 735 | return 1; |
734 | } | 736 | } |
735 | 737 | dh = dccp_hdr(skb); | |
736 | /* | 738 | /* |
737 | * If P.type is not Data, Ack, or DataAck and P.X == 0 (the packet | 739 | * If P.type is not Data, Ack, or DataAck and P.X == 0 (the packet |
738 | * has short sequence numbers), drop packet and return | 740 | * has short sequence numbers), drop packet and return |
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index a6902c1e2f28..7899919cd9f0 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c | |||
@@ -233,6 +233,8 @@ int dsa_cpu_dsa_setup(struct dsa_switch *ds, struct device *dev, | |||
233 | genphy_read_status(phydev); | 233 | genphy_read_status(phydev); |
234 | if (ds->ops->adjust_link) | 234 | if (ds->ops->adjust_link) |
235 | ds->ops->adjust_link(ds, port, phydev); | 235 | ds->ops->adjust_link(ds, port, phydev); |
236 | |||
237 | put_device(&phydev->mdio.dev); | ||
236 | } | 238 | } |
237 | 239 | ||
238 | return 0; | 240 | return 0; |
@@ -504,15 +506,8 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index, | |||
504 | 506 | ||
505 | void dsa_cpu_dsa_destroy(struct device_node *port_dn) | 507 | void dsa_cpu_dsa_destroy(struct device_node *port_dn) |
506 | { | 508 | { |
507 | struct phy_device *phydev; | 509 | if (of_phy_is_fixed_link(port_dn)) |
508 | 510 | of_phy_deregister_fixed_link(port_dn); | |
509 | if (of_phy_is_fixed_link(port_dn)) { | ||
510 | phydev = of_phy_find_device(port_dn); | ||
511 | if (phydev) { | ||
512 | phy_device_free(phydev); | ||
513 | fixed_phy_unregister(phydev); | ||
514 | } | ||
515 | } | ||
516 | } | 511 | } |
517 | 512 | ||
518 | static void dsa_switch_destroy(struct dsa_switch *ds) | 513 | static void dsa_switch_destroy(struct dsa_switch *ds) |
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index f8a7d9aab437..5fff951a0a49 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c | |||
@@ -28,8 +28,10 @@ static struct dsa_switch_tree *dsa_get_dst(u32 tree) | |||
28 | struct dsa_switch_tree *dst; | 28 | struct dsa_switch_tree *dst; |
29 | 29 | ||
30 | list_for_each_entry(dst, &dsa_switch_trees, list) | 30 | list_for_each_entry(dst, &dsa_switch_trees, list) |
31 | if (dst->tree == tree) | 31 | if (dst->tree == tree) { |
32 | kref_get(&dst->refcount); | ||
32 | return dst; | 33 | return dst; |
34 | } | ||
33 | return NULL; | 35 | return NULL; |
34 | } | 36 | } |
35 | 37 | ||
diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 6b1282c006b1..30e2e21d7619 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c | |||
@@ -1125,7 +1125,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, | |||
1125 | p->phy_interface = mode; | 1125 | p->phy_interface = mode; |
1126 | 1126 | ||
1127 | phy_dn = of_parse_phandle(port_dn, "phy-handle", 0); | 1127 | phy_dn = of_parse_phandle(port_dn, "phy-handle", 0); |
1128 | if (of_phy_is_fixed_link(port_dn)) { | 1128 | if (!phy_dn && of_phy_is_fixed_link(port_dn)) { |
1129 | /* In the case of a fixed PHY, the DT node associated | 1129 | /* In the case of a fixed PHY, the DT node associated |
1130 | * to the fixed PHY is the Port DT node | 1130 | * to the fixed PHY is the Port DT node |
1131 | */ | 1131 | */ |
@@ -1135,7 +1135,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, | |||
1135 | return ret; | 1135 | return ret; |
1136 | } | 1136 | } |
1137 | phy_is_fixed = true; | 1137 | phy_is_fixed = true; |
1138 | phy_dn = port_dn; | 1138 | phy_dn = of_node_get(port_dn); |
1139 | } | 1139 | } |
1140 | 1140 | ||
1141 | if (ds->ops->get_phy_flags) | 1141 | if (ds->ops->get_phy_flags) |
@@ -1154,6 +1154,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, | |||
1154 | ret = dsa_slave_phy_connect(p, slave_dev, phy_id); | 1154 | ret = dsa_slave_phy_connect(p, slave_dev, phy_id); |
1155 | if (ret) { | 1155 | if (ret) { |
1156 | netdev_err(slave_dev, "failed to connect to phy%d: %d\n", phy_id, ret); | 1156 | netdev_err(slave_dev, "failed to connect to phy%d: %d\n", phy_id, ret); |
1157 | of_node_put(phy_dn); | ||
1157 | return ret; | 1158 | return ret; |
1158 | } | 1159 | } |
1159 | } else { | 1160 | } else { |
@@ -1162,6 +1163,8 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, | |||
1162 | phy_flags, | 1163 | phy_flags, |
1163 | p->phy_interface); | 1164 | p->phy_interface); |
1164 | } | 1165 | } |
1166 | |||
1167 | of_node_put(phy_dn); | ||
1165 | } | 1168 | } |
1166 | 1169 | ||
1167 | if (p->phy && phy_is_fixed) | 1170 | if (p->phy && phy_is_fixed) |
@@ -1174,6 +1177,8 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, | |||
1174 | ret = dsa_slave_phy_connect(p, slave_dev, p->port); | 1177 | ret = dsa_slave_phy_connect(p, slave_dev, p->port); |
1175 | if (ret) { | 1178 | if (ret) { |
1176 | netdev_err(slave_dev, "failed to connect to port %d: %d\n", p->port, ret); | 1179 | netdev_err(slave_dev, "failed to connect to port %d: %d\n", p->port, ret); |
1180 | if (phy_is_fixed) | ||
1181 | of_phy_deregister_fixed_link(port_dn); | ||
1177 | return ret; | 1182 | return ret; |
1178 | } | 1183 | } |
1179 | } | 1184 | } |
@@ -1289,10 +1294,18 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent, | |||
1289 | void dsa_slave_destroy(struct net_device *slave_dev) | 1294 | void dsa_slave_destroy(struct net_device *slave_dev) |
1290 | { | 1295 | { |
1291 | struct dsa_slave_priv *p = netdev_priv(slave_dev); | 1296 | struct dsa_slave_priv *p = netdev_priv(slave_dev); |
1297 | struct dsa_switch *ds = p->parent; | ||
1298 | struct device_node *port_dn; | ||
1299 | |||
1300 | port_dn = ds->ports[p->port].dn; | ||
1292 | 1301 | ||
1293 | netif_carrier_off(slave_dev); | 1302 | netif_carrier_off(slave_dev); |
1294 | if (p->phy) | 1303 | if (p->phy) { |
1295 | phy_disconnect(p->phy); | 1304 | phy_disconnect(p->phy); |
1305 | |||
1306 | if (of_phy_is_fixed_link(port_dn)) | ||
1307 | of_phy_deregister_fixed_link(port_dn); | ||
1308 | } | ||
1296 | unregister_netdev(slave_dev); | 1309 | unregister_netdev(slave_dev); |
1297 | free_netdev(slave_dev); | 1310 | free_netdev(slave_dev); |
1298 | } | 1311 | } |
diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig index 300b06888fdf..b54b3ca939db 100644 --- a/net/ipv4/Kconfig +++ b/net/ipv4/Kconfig | |||
@@ -715,6 +715,7 @@ config DEFAULT_TCP_CONG | |||
715 | default "reno" if DEFAULT_RENO | 715 | default "reno" if DEFAULT_RENO |
716 | default "dctcp" if DEFAULT_DCTCP | 716 | default "dctcp" if DEFAULT_DCTCP |
717 | default "cdg" if DEFAULT_CDG | 717 | default "cdg" if DEFAULT_CDG |
718 | default "bbr" if DEFAULT_BBR | ||
718 | default "cubic" | 719 | default "cubic" |
719 | 720 | ||
720 | config TCP_MD5SIG | 721 | config TCP_MD5SIG |
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 5ddf5cda07f4..215143246e4b 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -1233,7 +1233,7 @@ struct sk_buff *inet_gso_segment(struct sk_buff *skb, | |||
1233 | fixedid = !!(skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID); | 1233 | fixedid = !!(skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID); |
1234 | 1234 | ||
1235 | /* fixed ID is invalid if DF bit is not set */ | 1235 | /* fixed ID is invalid if DF bit is not set */ |
1236 | if (fixedid && !(iph->frag_off & htons(IP_DF))) | 1236 | if (fixedid && !(ip_hdr(skb)->frag_off & htons(IP_DF))) |
1237 | goto out; | 1237 | goto out; |
1238 | } | 1238 | } |
1239 | 1239 | ||
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c index d95631d09248..20fb25e3027b 100644 --- a/net/ipv4/esp4.c +++ b/net/ipv4/esp4.c | |||
@@ -476,7 +476,7 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb) | |||
476 | esph = (void *)skb_push(skb, 4); | 476 | esph = (void *)skb_push(skb, 4); |
477 | *seqhi = esph->spi; | 477 | *seqhi = esph->spi; |
478 | esph->spi = esph->seq_no; | 478 | esph->spi = esph->seq_no; |
479 | esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq.input.hi); | 479 | esph->seq_no = XFRM_SKB_CB(skb)->seq.input.hi; |
480 | aead_request_set_callback(req, 0, esp_input_done_esn, skb); | 480 | aead_request_set_callback(req, 0, esp_input_done_esn, skb); |
481 | } | 481 | } |
482 | 482 | ||
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 105908d841a3..877bdb02e887 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c | |||
@@ -107,6 +107,8 @@ int __ip_local_out(struct net *net, struct sock *sk, struct sk_buff *skb) | |||
107 | if (unlikely(!skb)) | 107 | if (unlikely(!skb)) |
108 | return 0; | 108 | return 0; |
109 | 109 | ||
110 | skb->protocol = htons(ETH_P_IP); | ||
111 | |||
110 | return nf_hook(NFPROTO_IPV4, NF_INET_LOCAL_OUT, | 112 | return nf_hook(NFPROTO_IPV4, NF_INET_LOCAL_OUT, |
111 | net, sk, skb, NULL, skb_dst(skb)->dev, | 113 | net, sk, skb, NULL, skb_dst(skb)->dev, |
112 | dst_output); | 114 | dst_output); |
diff --git a/net/ipv4/netfilter.c b/net/ipv4/netfilter.c index c3776ff6749f..b3cc1335adbc 100644 --- a/net/ipv4/netfilter.c +++ b/net/ipv4/netfilter.c | |||
@@ -24,10 +24,11 @@ int ip_route_me_harder(struct net *net, struct sk_buff *skb, unsigned int addr_t | |||
24 | struct flowi4 fl4 = {}; | 24 | struct flowi4 fl4 = {}; |
25 | __be32 saddr = iph->saddr; | 25 | __be32 saddr = iph->saddr; |
26 | __u8 flags = skb->sk ? inet_sk_flowi_flags(skb->sk) : 0; | 26 | __u8 flags = skb->sk ? inet_sk_flowi_flags(skb->sk) : 0; |
27 | struct net_device *dev = skb_dst(skb)->dev; | ||
27 | unsigned int hh_len; | 28 | unsigned int hh_len; |
28 | 29 | ||
29 | if (addr_type == RTN_UNSPEC) | 30 | if (addr_type == RTN_UNSPEC) |
30 | addr_type = inet_addr_type(net, saddr); | 31 | addr_type = inet_addr_type_dev_table(net, dev, saddr); |
31 | if (addr_type == RTN_LOCAL || addr_type == RTN_UNICAST) | 32 | if (addr_type == RTN_LOCAL || addr_type == RTN_UNICAST) |
32 | flags |= FLOWI_FLAG_ANYSRC; | 33 | flags |= FLOWI_FLAG_ANYSRC; |
33 | else | 34 | else |
@@ -40,6 +41,8 @@ int ip_route_me_harder(struct net *net, struct sk_buff *skb, unsigned int addr_t | |||
40 | fl4.saddr = saddr; | 41 | fl4.saddr = saddr; |
41 | fl4.flowi4_tos = RT_TOS(iph->tos); | 42 | fl4.flowi4_tos = RT_TOS(iph->tos); |
42 | fl4.flowi4_oif = skb->sk ? skb->sk->sk_bound_dev_if : 0; | 43 | fl4.flowi4_oif = skb->sk ? skb->sk->sk_bound_dev_if : 0; |
44 | if (!fl4.flowi4_oif) | ||
45 | fl4.flowi4_oif = l3mdev_master_ifindex(dev); | ||
43 | fl4.flowi4_mark = skb->mark; | 46 | fl4.flowi4_mark = skb->mark; |
44 | fl4.flowi4_flags = flags; | 47 | fl4.flowi4_flags = flags; |
45 | rt = ip_route_output_key(net, &fl4); | 48 | rt = ip_route_output_key(net, &fl4); |
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c index b31df597fd37..697538464e6e 100644 --- a/net/ipv4/netfilter/arp_tables.c +++ b/net/ipv4/netfilter/arp_tables.c | |||
@@ -1201,8 +1201,8 @@ static int translate_compat_table(struct xt_table_info **pinfo, | |||
1201 | 1201 | ||
1202 | newinfo->number = compatr->num_entries; | 1202 | newinfo->number = compatr->num_entries; |
1203 | for (i = 0; i < NF_ARP_NUMHOOKS; i++) { | 1203 | for (i = 0; i < NF_ARP_NUMHOOKS; i++) { |
1204 | newinfo->hook_entry[i] = info->hook_entry[i]; | 1204 | newinfo->hook_entry[i] = compatr->hook_entry[i]; |
1205 | newinfo->underflow[i] = info->underflow[i]; | 1205 | newinfo->underflow[i] = compatr->underflow[i]; |
1206 | } | 1206 | } |
1207 | entry1 = newinfo->entries; | 1207 | entry1 = newinfo->entries; |
1208 | pos = entry1; | 1208 | pos = entry1; |
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index 37874e2f30ed..ccf40550c475 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c | |||
@@ -139,7 +139,8 @@ void ip6_datagram_release_cb(struct sock *sk) | |||
139 | } | 139 | } |
140 | EXPORT_SYMBOL_GPL(ip6_datagram_release_cb); | 140 | EXPORT_SYMBOL_GPL(ip6_datagram_release_cb); |
141 | 141 | ||
142 | static int __ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) | 142 | int __ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, |
143 | int addr_len) | ||
143 | { | 144 | { |
144 | struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr; | 145 | struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr; |
145 | struct inet_sock *inet = inet_sk(sk); | 146 | struct inet_sock *inet = inet_sk(sk); |
@@ -252,6 +253,7 @@ ipv4_connected: | |||
252 | out: | 253 | out: |
253 | return err; | 254 | return err; |
254 | } | 255 | } |
256 | EXPORT_SYMBOL_GPL(__ip6_datagram_connect); | ||
255 | 257 | ||
256 | int ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) | 258 | int ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) |
257 | { | 259 | { |
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c index 060a60b2f8a6..111ba55fd512 100644 --- a/net/ipv6/esp6.c +++ b/net/ipv6/esp6.c | |||
@@ -418,7 +418,7 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb) | |||
418 | esph = (void *)skb_push(skb, 4); | 418 | esph = (void *)skb_push(skb, 4); |
419 | *seqhi = esph->spi; | 419 | *seqhi = esph->spi; |
420 | esph->spi = esph->seq_no; | 420 | esph->spi = esph->seq_no; |
421 | esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq.input.hi); | 421 | esph->seq_no = XFRM_SKB_CB(skb)->seq.input.hi; |
422 | aead_request_set_callback(req, 0, esp_input_done_esn, skb); | 422 | aead_request_set_callback(req, 0, esp_input_done_esn, skb); |
423 | } | 423 | } |
424 | 424 | ||
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index 7370ad2e693a..2772004ba5a1 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c | |||
@@ -447,8 +447,10 @@ static void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, | |||
447 | 447 | ||
448 | if (__ipv6_addr_needs_scope_id(addr_type)) | 448 | if (__ipv6_addr_needs_scope_id(addr_type)) |
449 | iif = skb->dev->ifindex; | 449 | iif = skb->dev->ifindex; |
450 | else | 450 | else { |
451 | iif = l3mdev_master_ifindex(skb_dst(skb)->dev); | 451 | dst = skb_dst(skb); |
452 | iif = l3mdev_master_ifindex(dst ? dst->dev : skb->dev); | ||
453 | } | ||
452 | 454 | ||
453 | /* | 455 | /* |
454 | * Must not send error if the source does not uniquely | 456 | * Must not send error if the source does not uniquely |
diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c index 1fcf61f1cbc3..89c59e656f44 100644 --- a/net/ipv6/ip6_offload.c +++ b/net/ipv6/ip6_offload.c | |||
@@ -99,7 +99,7 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, | |||
99 | segs = ops->callbacks.gso_segment(skb, features); | 99 | segs = ops->callbacks.gso_segment(skb, features); |
100 | } | 100 | } |
101 | 101 | ||
102 | if (IS_ERR(segs)) | 102 | if (IS_ERR_OR_NULL(segs)) |
103 | goto out; | 103 | goto out; |
104 | 104 | ||
105 | gso_partial = !!(skb_shinfo(segs)->gso_type & SKB_GSO_PARTIAL); | 105 | gso_partial = !!(skb_shinfo(segs)->gso_type & SKB_GSO_PARTIAL); |
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index 0a4759b89da2..d76674efe523 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c | |||
@@ -1181,7 +1181,6 @@ route_lookup: | |||
1181 | if (err) | 1181 | if (err) |
1182 | return err; | 1182 | return err; |
1183 | 1183 | ||
1184 | skb->protocol = htons(ETH_P_IPV6); | ||
1185 | skb_push(skb, sizeof(struct ipv6hdr)); | 1184 | skb_push(skb, sizeof(struct ipv6hdr)); |
1186 | skb_reset_network_header(skb); | 1185 | skb_reset_network_header(skb); |
1187 | ipv6h = ipv6_hdr(skb); | 1186 | ipv6h = ipv6_hdr(skb); |
diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c index 8a02ca8a11af..c299c1e2bbf0 100644 --- a/net/ipv6/ip6_vti.c +++ b/net/ipv6/ip6_vti.c | |||
@@ -1138,6 +1138,33 @@ static struct xfrm6_protocol vti_ipcomp6_protocol __read_mostly = { | |||
1138 | .priority = 100, | 1138 | .priority = 100, |
1139 | }; | 1139 | }; |
1140 | 1140 | ||
1141 | static bool is_vti6_tunnel(const struct net_device *dev) | ||
1142 | { | ||
1143 | return dev->netdev_ops == &vti6_netdev_ops; | ||
1144 | } | ||
1145 | |||
1146 | static int vti6_device_event(struct notifier_block *unused, | ||
1147 | unsigned long event, void *ptr) | ||
1148 | { | ||
1149 | struct net_device *dev = netdev_notifier_info_to_dev(ptr); | ||
1150 | struct ip6_tnl *t = netdev_priv(dev); | ||
1151 | |||
1152 | if (!is_vti6_tunnel(dev)) | ||
1153 | return NOTIFY_DONE; | ||
1154 | |||
1155 | switch (event) { | ||
1156 | case NETDEV_DOWN: | ||
1157 | if (!net_eq(t->net, dev_net(dev))) | ||
1158 | xfrm_garbage_collect(t->net); | ||
1159 | break; | ||
1160 | } | ||
1161 | return NOTIFY_DONE; | ||
1162 | } | ||
1163 | |||
1164 | static struct notifier_block vti6_notifier_block __read_mostly = { | ||
1165 | .notifier_call = vti6_device_event, | ||
1166 | }; | ||
1167 | |||
1141 | /** | 1168 | /** |
1142 | * vti6_tunnel_init - register protocol and reserve needed resources | 1169 | * vti6_tunnel_init - register protocol and reserve needed resources |
1143 | * | 1170 | * |
@@ -1148,6 +1175,8 @@ static int __init vti6_tunnel_init(void) | |||
1148 | const char *msg; | 1175 | const char *msg; |
1149 | int err; | 1176 | int err; |
1150 | 1177 | ||
1178 | register_netdevice_notifier(&vti6_notifier_block); | ||
1179 | |||
1151 | msg = "tunnel device"; | 1180 | msg = "tunnel device"; |
1152 | err = register_pernet_device(&vti6_net_ops); | 1181 | err = register_pernet_device(&vti6_net_ops); |
1153 | if (err < 0) | 1182 | if (err < 0) |
@@ -1180,6 +1209,7 @@ xfrm_proto_ah_failed: | |||
1180 | xfrm_proto_esp_failed: | 1209 | xfrm_proto_esp_failed: |
1181 | unregister_pernet_device(&vti6_net_ops); | 1210 | unregister_pernet_device(&vti6_net_ops); |
1182 | pernet_dev_failed: | 1211 | pernet_dev_failed: |
1212 | unregister_netdevice_notifier(&vti6_notifier_block); | ||
1183 | pr_err("vti6 init: failed to register %s\n", msg); | 1213 | pr_err("vti6 init: failed to register %s\n", msg); |
1184 | return err; | 1214 | return err; |
1185 | } | 1215 | } |
@@ -1194,6 +1224,7 @@ static void __exit vti6_tunnel_cleanup(void) | |||
1194 | xfrm6_protocol_deregister(&vti_ah6_protocol, IPPROTO_AH); | 1224 | xfrm6_protocol_deregister(&vti_ah6_protocol, IPPROTO_AH); |
1195 | xfrm6_protocol_deregister(&vti_esp6_protocol, IPPROTO_ESP); | 1225 | xfrm6_protocol_deregister(&vti_esp6_protocol, IPPROTO_ESP); |
1196 | unregister_pernet_device(&vti6_net_ops); | 1226 | unregister_pernet_device(&vti6_net_ops); |
1227 | unregister_netdevice_notifier(&vti6_notifier_block); | ||
1197 | } | 1228 | } |
1198 | 1229 | ||
1199 | module_init(vti6_tunnel_init); | 1230 | module_init(vti6_tunnel_init); |
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c index e4347aeb2e65..9948b5ce52da 100644 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c | |||
@@ -576,11 +576,11 @@ int nf_ct_frag6_gather(struct net *net, struct sk_buff *skb, u32 user) | |||
576 | /* Jumbo payload inhibits frag. header */ | 576 | /* Jumbo payload inhibits frag. header */ |
577 | if (ipv6_hdr(skb)->payload_len == 0) { | 577 | if (ipv6_hdr(skb)->payload_len == 0) { |
578 | pr_debug("payload len = 0\n"); | 578 | pr_debug("payload len = 0\n"); |
579 | return -EINVAL; | 579 | return 0; |
580 | } | 580 | } |
581 | 581 | ||
582 | if (find_prev_fhdr(skb, &prevhdr, &nhoff, &fhoff) < 0) | 582 | if (find_prev_fhdr(skb, &prevhdr, &nhoff, &fhoff) < 0) |
583 | return -EINVAL; | 583 | return 0; |
584 | 584 | ||
585 | if (!pskb_may_pull(skb, fhoff + sizeof(*fhdr))) | 585 | if (!pskb_may_pull(skb, fhoff + sizeof(*fhdr))) |
586 | return -ENOMEM; | 586 | return -ENOMEM; |
diff --git a/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c b/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c index f7aab5ab93a5..f06b0471f39f 100644 --- a/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c +++ b/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c | |||
@@ -69,7 +69,7 @@ static unsigned int ipv6_defrag(void *priv, | |||
69 | if (err == -EINPROGRESS) | 69 | if (err == -EINPROGRESS) |
70 | return NF_STOLEN; | 70 | return NF_STOLEN; |
71 | 71 | ||
72 | return NF_ACCEPT; | 72 | return err == 0 ? NF_ACCEPT : NF_DROP; |
73 | } | 73 | } |
74 | 74 | ||
75 | static struct nf_hook_ops ipv6_defrag_ops[] = { | 75 | static struct nf_hook_ops ipv6_defrag_ops[] = { |
diff --git a/net/ipv6/netfilter/nf_reject_ipv6.c b/net/ipv6/netfilter/nf_reject_ipv6.c index a5400223fd74..10090400c72f 100644 --- a/net/ipv6/netfilter/nf_reject_ipv6.c +++ b/net/ipv6/netfilter/nf_reject_ipv6.c | |||
@@ -156,6 +156,7 @@ void nf_send_reset6(struct net *net, struct sk_buff *oldskb, int hook) | |||
156 | fl6.daddr = oip6h->saddr; | 156 | fl6.daddr = oip6h->saddr; |
157 | fl6.fl6_sport = otcph->dest; | 157 | fl6.fl6_sport = otcph->dest; |
158 | fl6.fl6_dport = otcph->source; | 158 | fl6.fl6_dport = otcph->source; |
159 | fl6.flowi6_oif = l3mdev_master_ifindex(skb_dst(oldskb)->dev); | ||
159 | security_skb_classify_flow(oldskb, flowi6_to_flowi(&fl6)); | 160 | security_skb_classify_flow(oldskb, flowi6_to_flowi(&fl6)); |
160 | dst = ip6_route_output(net, NULL, &fl6); | 161 | dst = ip6_route_output(net, NULL, &fl6); |
161 | if (dst->error) { | 162 | if (dst->error) { |
diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c index 7cca8ac66fe9..cd4252346a32 100644 --- a/net/ipv6/output_core.c +++ b/net/ipv6/output_core.c | |||
@@ -155,6 +155,8 @@ int __ip6_local_out(struct net *net, struct sock *sk, struct sk_buff *skb) | |||
155 | if (unlikely(!skb)) | 155 | if (unlikely(!skb)) |
156 | return 0; | 156 | return 0; |
157 | 157 | ||
158 | skb->protocol = htons(ETH_P_IPV6); | ||
159 | |||
158 | return nf_hook(NFPROTO_IPV6, NF_INET_LOCAL_OUT, | 160 | return nf_hook(NFPROTO_IPV6, NF_INET_LOCAL_OUT, |
159 | net, sk, skb, NULL, skb_dst(skb)->dev, | 161 | net, sk, skb, NULL, skb_dst(skb)->dev, |
160 | dst_output); | 162 | dst_output); |
diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c index 982f6c44ea01..8938b6ba57a0 100644 --- a/net/l2tp/l2tp_ip.c +++ b/net/l2tp/l2tp_ip.c | |||
@@ -61,7 +61,8 @@ static struct sock *__l2tp_ip_bind_lookup(struct net *net, __be32 laddr, int dif | |||
61 | if ((l2tp->conn_id == tunnel_id) && | 61 | if ((l2tp->conn_id == tunnel_id) && |
62 | net_eq(sock_net(sk), net) && | 62 | net_eq(sock_net(sk), net) && |
63 | !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) && | 63 | !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) && |
64 | !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif)) | 64 | (!sk->sk_bound_dev_if || !dif || |
65 | sk->sk_bound_dev_if == dif)) | ||
65 | goto found; | 66 | goto found; |
66 | } | 67 | } |
67 | 68 | ||
@@ -182,15 +183,17 @@ pass_up: | |||
182 | struct iphdr *iph = (struct iphdr *) skb_network_header(skb); | 183 | struct iphdr *iph = (struct iphdr *) skb_network_header(skb); |
183 | 184 | ||
184 | read_lock_bh(&l2tp_ip_lock); | 185 | read_lock_bh(&l2tp_ip_lock); |
185 | sk = __l2tp_ip_bind_lookup(net, iph->daddr, 0, tunnel_id); | 186 | sk = __l2tp_ip_bind_lookup(net, iph->daddr, inet_iif(skb), |
187 | tunnel_id); | ||
188 | if (!sk) { | ||
189 | read_unlock_bh(&l2tp_ip_lock); | ||
190 | goto discard; | ||
191 | } | ||
192 | |||
193 | sock_hold(sk); | ||
186 | read_unlock_bh(&l2tp_ip_lock); | 194 | read_unlock_bh(&l2tp_ip_lock); |
187 | } | 195 | } |
188 | 196 | ||
189 | if (sk == NULL) | ||
190 | goto discard; | ||
191 | |||
192 | sock_hold(sk); | ||
193 | |||
194 | if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) | 197 | if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) |
195 | goto discard_put; | 198 | goto discard_put; |
196 | 199 | ||
@@ -256,15 +259,9 @@ static int l2tp_ip_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
256 | if (addr->l2tp_family != AF_INET) | 259 | if (addr->l2tp_family != AF_INET) |
257 | return -EINVAL; | 260 | return -EINVAL; |
258 | 261 | ||
259 | ret = -EADDRINUSE; | ||
260 | read_lock_bh(&l2tp_ip_lock); | ||
261 | if (__l2tp_ip_bind_lookup(net, addr->l2tp_addr.s_addr, | ||
262 | sk->sk_bound_dev_if, addr->l2tp_conn_id)) | ||
263 | goto out_in_use; | ||
264 | |||
265 | read_unlock_bh(&l2tp_ip_lock); | ||
266 | |||
267 | lock_sock(sk); | 262 | lock_sock(sk); |
263 | |||
264 | ret = -EINVAL; | ||
268 | if (!sock_flag(sk, SOCK_ZAPPED)) | 265 | if (!sock_flag(sk, SOCK_ZAPPED)) |
269 | goto out; | 266 | goto out; |
270 | 267 | ||
@@ -281,14 +278,22 @@ static int l2tp_ip_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
281 | inet->inet_rcv_saddr = inet->inet_saddr = addr->l2tp_addr.s_addr; | 278 | inet->inet_rcv_saddr = inet->inet_saddr = addr->l2tp_addr.s_addr; |
282 | if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST) | 279 | if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST) |
283 | inet->inet_saddr = 0; /* Use device */ | 280 | inet->inet_saddr = 0; /* Use device */ |
284 | sk_dst_reset(sk); | ||
285 | 281 | ||
282 | write_lock_bh(&l2tp_ip_lock); | ||
283 | if (__l2tp_ip_bind_lookup(net, addr->l2tp_addr.s_addr, | ||
284 | sk->sk_bound_dev_if, addr->l2tp_conn_id)) { | ||
285 | write_unlock_bh(&l2tp_ip_lock); | ||
286 | ret = -EADDRINUSE; | ||
287 | goto out; | ||
288 | } | ||
289 | |||
290 | sk_dst_reset(sk); | ||
286 | l2tp_ip_sk(sk)->conn_id = addr->l2tp_conn_id; | 291 | l2tp_ip_sk(sk)->conn_id = addr->l2tp_conn_id; |
287 | 292 | ||
288 | write_lock_bh(&l2tp_ip_lock); | ||
289 | sk_add_bind_node(sk, &l2tp_ip_bind_table); | 293 | sk_add_bind_node(sk, &l2tp_ip_bind_table); |
290 | sk_del_node_init(sk); | 294 | sk_del_node_init(sk); |
291 | write_unlock_bh(&l2tp_ip_lock); | 295 | write_unlock_bh(&l2tp_ip_lock); |
296 | |||
292 | ret = 0; | 297 | ret = 0; |
293 | sock_reset_flag(sk, SOCK_ZAPPED); | 298 | sock_reset_flag(sk, SOCK_ZAPPED); |
294 | 299 | ||
@@ -296,11 +301,6 @@ out: | |||
296 | release_sock(sk); | 301 | release_sock(sk); |
297 | 302 | ||
298 | return ret; | 303 | return ret; |
299 | |||
300 | out_in_use: | ||
301 | read_unlock_bh(&l2tp_ip_lock); | ||
302 | |||
303 | return ret; | ||
304 | } | 304 | } |
305 | 305 | ||
306 | static int l2tp_ip_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) | 306 | static int l2tp_ip_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) |
@@ -308,21 +308,24 @@ static int l2tp_ip_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len | |||
308 | struct sockaddr_l2tpip *lsa = (struct sockaddr_l2tpip *) uaddr; | 308 | struct sockaddr_l2tpip *lsa = (struct sockaddr_l2tpip *) uaddr; |
309 | int rc; | 309 | int rc; |
310 | 310 | ||
311 | if (sock_flag(sk, SOCK_ZAPPED)) /* Must bind first - autobinding does not work */ | ||
312 | return -EINVAL; | ||
313 | |||
314 | if (addr_len < sizeof(*lsa)) | 311 | if (addr_len < sizeof(*lsa)) |
315 | return -EINVAL; | 312 | return -EINVAL; |
316 | 313 | ||
317 | if (ipv4_is_multicast(lsa->l2tp_addr.s_addr)) | 314 | if (ipv4_is_multicast(lsa->l2tp_addr.s_addr)) |
318 | return -EINVAL; | 315 | return -EINVAL; |
319 | 316 | ||
320 | rc = ip4_datagram_connect(sk, uaddr, addr_len); | ||
321 | if (rc < 0) | ||
322 | return rc; | ||
323 | |||
324 | lock_sock(sk); | 317 | lock_sock(sk); |
325 | 318 | ||
319 | /* Must bind first - autobinding does not work */ | ||
320 | if (sock_flag(sk, SOCK_ZAPPED)) { | ||
321 | rc = -EINVAL; | ||
322 | goto out_sk; | ||
323 | } | ||
324 | |||
325 | rc = __ip4_datagram_connect(sk, uaddr, addr_len); | ||
326 | if (rc < 0) | ||
327 | goto out_sk; | ||
328 | |||
326 | l2tp_ip_sk(sk)->peer_conn_id = lsa->l2tp_conn_id; | 329 | l2tp_ip_sk(sk)->peer_conn_id = lsa->l2tp_conn_id; |
327 | 330 | ||
328 | write_lock_bh(&l2tp_ip_lock); | 331 | write_lock_bh(&l2tp_ip_lock); |
@@ -330,7 +333,9 @@ static int l2tp_ip_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len | |||
330 | sk_add_bind_node(sk, &l2tp_ip_bind_table); | 333 | sk_add_bind_node(sk, &l2tp_ip_bind_table); |
331 | write_unlock_bh(&l2tp_ip_lock); | 334 | write_unlock_bh(&l2tp_ip_lock); |
332 | 335 | ||
336 | out_sk: | ||
333 | release_sock(sk); | 337 | release_sock(sk); |
338 | |||
334 | return rc; | 339 | return rc; |
335 | } | 340 | } |
336 | 341 | ||
diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c index 9978d01ba0ba..aa821cb639e5 100644 --- a/net/l2tp/l2tp_ip6.c +++ b/net/l2tp/l2tp_ip6.c | |||
@@ -72,8 +72,9 @@ static struct sock *__l2tp_ip6_bind_lookup(struct net *net, | |||
72 | 72 | ||
73 | if ((l2tp->conn_id == tunnel_id) && | 73 | if ((l2tp->conn_id == tunnel_id) && |
74 | net_eq(sock_net(sk), net) && | 74 | net_eq(sock_net(sk), net) && |
75 | !(addr && ipv6_addr_equal(addr, laddr)) && | 75 | (!addr || ipv6_addr_equal(addr, laddr)) && |
76 | !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif)) | 76 | (!sk->sk_bound_dev_if || !dif || |
77 | sk->sk_bound_dev_if == dif)) | ||
77 | goto found; | 78 | goto found; |
78 | } | 79 | } |
79 | 80 | ||
@@ -196,16 +197,17 @@ pass_up: | |||
196 | struct ipv6hdr *iph = ipv6_hdr(skb); | 197 | struct ipv6hdr *iph = ipv6_hdr(skb); |
197 | 198 | ||
198 | read_lock_bh(&l2tp_ip6_lock); | 199 | read_lock_bh(&l2tp_ip6_lock); |
199 | sk = __l2tp_ip6_bind_lookup(net, &iph->daddr, | 200 | sk = __l2tp_ip6_bind_lookup(net, &iph->daddr, inet6_iif(skb), |
200 | 0, tunnel_id); | 201 | tunnel_id); |
202 | if (!sk) { | ||
203 | read_unlock_bh(&l2tp_ip6_lock); | ||
204 | goto discard; | ||
205 | } | ||
206 | |||
207 | sock_hold(sk); | ||
201 | read_unlock_bh(&l2tp_ip6_lock); | 208 | read_unlock_bh(&l2tp_ip6_lock); |
202 | } | 209 | } |
203 | 210 | ||
204 | if (sk == NULL) | ||
205 | goto discard; | ||
206 | |||
207 | sock_hold(sk); | ||
208 | |||
209 | if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) | 211 | if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) |
210 | goto discard_put; | 212 | goto discard_put; |
211 | 213 | ||
@@ -266,6 +268,7 @@ static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
266 | struct sockaddr_l2tpip6 *addr = (struct sockaddr_l2tpip6 *) uaddr; | 268 | struct sockaddr_l2tpip6 *addr = (struct sockaddr_l2tpip6 *) uaddr; |
267 | struct net *net = sock_net(sk); | 269 | struct net *net = sock_net(sk); |
268 | __be32 v4addr = 0; | 270 | __be32 v4addr = 0; |
271 | int bound_dev_if; | ||
269 | int addr_type; | 272 | int addr_type; |
270 | int err; | 273 | int err; |
271 | 274 | ||
@@ -284,13 +287,6 @@ static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
284 | if (addr_type & IPV6_ADDR_MULTICAST) | 287 | if (addr_type & IPV6_ADDR_MULTICAST) |
285 | return -EADDRNOTAVAIL; | 288 | return -EADDRNOTAVAIL; |
286 | 289 | ||
287 | err = -EADDRINUSE; | ||
288 | read_lock_bh(&l2tp_ip6_lock); | ||
289 | if (__l2tp_ip6_bind_lookup(net, &addr->l2tp_addr, | ||
290 | sk->sk_bound_dev_if, addr->l2tp_conn_id)) | ||
291 | goto out_in_use; | ||
292 | read_unlock_bh(&l2tp_ip6_lock); | ||
293 | |||
294 | lock_sock(sk); | 290 | lock_sock(sk); |
295 | 291 | ||
296 | err = -EINVAL; | 292 | err = -EINVAL; |
@@ -300,28 +296,25 @@ static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
300 | if (sk->sk_state != TCP_CLOSE) | 296 | if (sk->sk_state != TCP_CLOSE) |
301 | goto out_unlock; | 297 | goto out_unlock; |
302 | 298 | ||
299 | bound_dev_if = sk->sk_bound_dev_if; | ||
300 | |||
303 | /* Check if the address belongs to the host. */ | 301 | /* Check if the address belongs to the host. */ |
304 | rcu_read_lock(); | 302 | rcu_read_lock(); |
305 | if (addr_type != IPV6_ADDR_ANY) { | 303 | if (addr_type != IPV6_ADDR_ANY) { |
306 | struct net_device *dev = NULL; | 304 | struct net_device *dev = NULL; |
307 | 305 | ||
308 | if (addr_type & IPV6_ADDR_LINKLOCAL) { | 306 | if (addr_type & IPV6_ADDR_LINKLOCAL) { |
309 | if (addr_len >= sizeof(struct sockaddr_in6) && | 307 | if (addr->l2tp_scope_id) |
310 | addr->l2tp_scope_id) { | 308 | bound_dev_if = addr->l2tp_scope_id; |
311 | /* Override any existing binding, if another | ||
312 | * one is supplied by user. | ||
313 | */ | ||
314 | sk->sk_bound_dev_if = addr->l2tp_scope_id; | ||
315 | } | ||
316 | 309 | ||
317 | /* Binding to link-local address requires an | 310 | /* Binding to link-local address requires an |
318 | interface */ | 311 | * interface. |
319 | if (!sk->sk_bound_dev_if) | 312 | */ |
313 | if (!bound_dev_if) | ||
320 | goto out_unlock_rcu; | 314 | goto out_unlock_rcu; |
321 | 315 | ||
322 | err = -ENODEV; | 316 | err = -ENODEV; |
323 | dev = dev_get_by_index_rcu(sock_net(sk), | 317 | dev = dev_get_by_index_rcu(sock_net(sk), bound_dev_if); |
324 | sk->sk_bound_dev_if); | ||
325 | if (!dev) | 318 | if (!dev) |
326 | goto out_unlock_rcu; | 319 | goto out_unlock_rcu; |
327 | } | 320 | } |
@@ -336,13 +329,22 @@ static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
336 | } | 329 | } |
337 | rcu_read_unlock(); | 330 | rcu_read_unlock(); |
338 | 331 | ||
339 | inet->inet_rcv_saddr = inet->inet_saddr = v4addr; | 332 | write_lock_bh(&l2tp_ip6_lock); |
333 | if (__l2tp_ip6_bind_lookup(net, &addr->l2tp_addr, bound_dev_if, | ||
334 | addr->l2tp_conn_id)) { | ||
335 | write_unlock_bh(&l2tp_ip6_lock); | ||
336 | err = -EADDRINUSE; | ||
337 | goto out_unlock; | ||
338 | } | ||
339 | |||
340 | inet->inet_saddr = v4addr; | ||
341 | inet->inet_rcv_saddr = v4addr; | ||
342 | sk->sk_bound_dev_if = bound_dev_if; | ||
340 | sk->sk_v6_rcv_saddr = addr->l2tp_addr; | 343 | sk->sk_v6_rcv_saddr = addr->l2tp_addr; |
341 | np->saddr = addr->l2tp_addr; | 344 | np->saddr = addr->l2tp_addr; |
342 | 345 | ||
343 | l2tp_ip6_sk(sk)->conn_id = addr->l2tp_conn_id; | 346 | l2tp_ip6_sk(sk)->conn_id = addr->l2tp_conn_id; |
344 | 347 | ||
345 | write_lock_bh(&l2tp_ip6_lock); | ||
346 | sk_add_bind_node(sk, &l2tp_ip6_bind_table); | 348 | sk_add_bind_node(sk, &l2tp_ip6_bind_table); |
347 | sk_del_node_init(sk); | 349 | sk_del_node_init(sk); |
348 | write_unlock_bh(&l2tp_ip6_lock); | 350 | write_unlock_bh(&l2tp_ip6_lock); |
@@ -355,10 +357,7 @@ out_unlock_rcu: | |||
355 | rcu_read_unlock(); | 357 | rcu_read_unlock(); |
356 | out_unlock: | 358 | out_unlock: |
357 | release_sock(sk); | 359 | release_sock(sk); |
358 | return err; | ||
359 | 360 | ||
360 | out_in_use: | ||
361 | read_unlock_bh(&l2tp_ip6_lock); | ||
362 | return err; | 361 | return err; |
363 | } | 362 | } |
364 | 363 | ||
@@ -371,9 +370,6 @@ static int l2tp_ip6_connect(struct sock *sk, struct sockaddr *uaddr, | |||
371 | int addr_type; | 370 | int addr_type; |
372 | int rc; | 371 | int rc; |
373 | 372 | ||
374 | if (sock_flag(sk, SOCK_ZAPPED)) /* Must bind first - autobinding does not work */ | ||
375 | return -EINVAL; | ||
376 | |||
377 | if (addr_len < sizeof(*lsa)) | 373 | if (addr_len < sizeof(*lsa)) |
378 | return -EINVAL; | 374 | return -EINVAL; |
379 | 375 | ||
@@ -390,10 +386,18 @@ static int l2tp_ip6_connect(struct sock *sk, struct sockaddr *uaddr, | |||
390 | return -EINVAL; | 386 | return -EINVAL; |
391 | } | 387 | } |
392 | 388 | ||
393 | rc = ip6_datagram_connect(sk, uaddr, addr_len); | ||
394 | |||
395 | lock_sock(sk); | 389 | lock_sock(sk); |
396 | 390 | ||
391 | /* Must bind first - autobinding does not work */ | ||
392 | if (sock_flag(sk, SOCK_ZAPPED)) { | ||
393 | rc = -EINVAL; | ||
394 | goto out_sk; | ||
395 | } | ||
396 | |||
397 | rc = __ip6_datagram_connect(sk, uaddr, addr_len); | ||
398 | if (rc < 0) | ||
399 | goto out_sk; | ||
400 | |||
397 | l2tp_ip6_sk(sk)->peer_conn_id = lsa->l2tp_conn_id; | 401 | l2tp_ip6_sk(sk)->peer_conn_id = lsa->l2tp_conn_id; |
398 | 402 | ||
399 | write_lock_bh(&l2tp_ip6_lock); | 403 | write_lock_bh(&l2tp_ip6_lock); |
@@ -401,6 +405,7 @@ static int l2tp_ip6_connect(struct sock *sk, struct sockaddr *uaddr, | |||
401 | sk_add_bind_node(sk, &l2tp_ip6_bind_table); | 405 | sk_add_bind_node(sk, &l2tp_ip6_bind_table); |
402 | write_unlock_bh(&l2tp_ip6_lock); | 406 | write_unlock_bh(&l2tp_ip6_lock); |
403 | 407 | ||
408 | out_sk: | ||
404 | release_sock(sk); | 409 | release_sock(sk); |
405 | 410 | ||
406 | return rc; | 411 | return rc; |
diff --git a/net/netfilter/nf_nat_core.c b/net/netfilter/nf_nat_core.c index bbb8f3df79f7..5b9c884a452e 100644 --- a/net/netfilter/nf_nat_core.c +++ b/net/netfilter/nf_nat_core.c | |||
@@ -42,7 +42,7 @@ struct nf_nat_conn_key { | |||
42 | const struct nf_conntrack_zone *zone; | 42 | const struct nf_conntrack_zone *zone; |
43 | }; | 43 | }; |
44 | 44 | ||
45 | static struct rhashtable nf_nat_bysource_table; | 45 | static struct rhltable nf_nat_bysource_table; |
46 | 46 | ||
47 | inline const struct nf_nat_l3proto * | 47 | inline const struct nf_nat_l3proto * |
48 | __nf_nat_l3proto_find(u8 family) | 48 | __nf_nat_l3proto_find(u8 family) |
@@ -193,9 +193,12 @@ static int nf_nat_bysource_cmp(struct rhashtable_compare_arg *arg, | |||
193 | const struct nf_nat_conn_key *key = arg->key; | 193 | const struct nf_nat_conn_key *key = arg->key; |
194 | const struct nf_conn *ct = obj; | 194 | const struct nf_conn *ct = obj; |
195 | 195 | ||
196 | return same_src(ct, key->tuple) && | 196 | if (!same_src(ct, key->tuple) || |
197 | net_eq(nf_ct_net(ct), key->net) && | 197 | !net_eq(nf_ct_net(ct), key->net) || |
198 | nf_ct_zone_equal(ct, key->zone, IP_CT_DIR_ORIGINAL); | 198 | !nf_ct_zone_equal(ct, key->zone, IP_CT_DIR_ORIGINAL)) |
199 | return 1; | ||
200 | |||
201 | return 0; | ||
199 | } | 202 | } |
200 | 203 | ||
201 | static struct rhashtable_params nf_nat_bysource_params = { | 204 | static struct rhashtable_params nf_nat_bysource_params = { |
@@ -204,7 +207,6 @@ static struct rhashtable_params nf_nat_bysource_params = { | |||
204 | .obj_cmpfn = nf_nat_bysource_cmp, | 207 | .obj_cmpfn = nf_nat_bysource_cmp, |
205 | .nelem_hint = 256, | 208 | .nelem_hint = 256, |
206 | .min_size = 1024, | 209 | .min_size = 1024, |
207 | .nulls_base = (1U << RHT_BASE_SHIFT), | ||
208 | }; | 210 | }; |
209 | 211 | ||
210 | /* Only called for SRC manip */ | 212 | /* Only called for SRC manip */ |
@@ -223,12 +225,15 @@ find_appropriate_src(struct net *net, | |||
223 | .tuple = tuple, | 225 | .tuple = tuple, |
224 | .zone = zone | 226 | .zone = zone |
225 | }; | 227 | }; |
228 | struct rhlist_head *hl; | ||
226 | 229 | ||
227 | ct = rhashtable_lookup_fast(&nf_nat_bysource_table, &key, | 230 | hl = rhltable_lookup(&nf_nat_bysource_table, &key, |
228 | nf_nat_bysource_params); | 231 | nf_nat_bysource_params); |
229 | if (!ct) | 232 | if (!hl) |
230 | return 0; | 233 | return 0; |
231 | 234 | ||
235 | ct = container_of(hl, typeof(*ct), nat_bysource); | ||
236 | |||
232 | nf_ct_invert_tuplepr(result, | 237 | nf_ct_invert_tuplepr(result, |
233 | &ct->tuplehash[IP_CT_DIR_REPLY].tuple); | 238 | &ct->tuplehash[IP_CT_DIR_REPLY].tuple); |
234 | result->dst = tuple->dst; | 239 | result->dst = tuple->dst; |
@@ -446,11 +451,17 @@ nf_nat_setup_info(struct nf_conn *ct, | |||
446 | } | 451 | } |
447 | 452 | ||
448 | if (maniptype == NF_NAT_MANIP_SRC) { | 453 | if (maniptype == NF_NAT_MANIP_SRC) { |
454 | struct nf_nat_conn_key key = { | ||
455 | .net = nf_ct_net(ct), | ||
456 | .tuple = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple, | ||
457 | .zone = nf_ct_zone(ct), | ||
458 | }; | ||
449 | int err; | 459 | int err; |
450 | 460 | ||
451 | err = rhashtable_insert_fast(&nf_nat_bysource_table, | 461 | err = rhltable_insert_key(&nf_nat_bysource_table, |
452 | &ct->nat_bysource, | 462 | &key, |
453 | nf_nat_bysource_params); | 463 | &ct->nat_bysource, |
464 | nf_nat_bysource_params); | ||
454 | if (err) | 465 | if (err) |
455 | return NF_DROP; | 466 | return NF_DROP; |
456 | } | 467 | } |
@@ -567,8 +578,8 @@ static int nf_nat_proto_clean(struct nf_conn *ct, void *data) | |||
567 | * will delete entry from already-freed table. | 578 | * will delete entry from already-freed table. |
568 | */ | 579 | */ |
569 | ct->status &= ~IPS_NAT_DONE_MASK; | 580 | ct->status &= ~IPS_NAT_DONE_MASK; |
570 | rhashtable_remove_fast(&nf_nat_bysource_table, &ct->nat_bysource, | 581 | rhltable_remove(&nf_nat_bysource_table, &ct->nat_bysource, |
571 | nf_nat_bysource_params); | 582 | nf_nat_bysource_params); |
572 | 583 | ||
573 | /* don't delete conntrack. Although that would make things a lot | 584 | /* don't delete conntrack. Although that would make things a lot |
574 | * simpler, we'd end up flushing all conntracks on nat rmmod. | 585 | * simpler, we'd end up flushing all conntracks on nat rmmod. |
@@ -698,8 +709,8 @@ static void nf_nat_cleanup_conntrack(struct nf_conn *ct) | |||
698 | if (!nat) | 709 | if (!nat) |
699 | return; | 710 | return; |
700 | 711 | ||
701 | rhashtable_remove_fast(&nf_nat_bysource_table, &ct->nat_bysource, | 712 | rhltable_remove(&nf_nat_bysource_table, &ct->nat_bysource, |
702 | nf_nat_bysource_params); | 713 | nf_nat_bysource_params); |
703 | } | 714 | } |
704 | 715 | ||
705 | static struct nf_ct_ext_type nat_extend __read_mostly = { | 716 | static struct nf_ct_ext_type nat_extend __read_mostly = { |
@@ -834,13 +845,13 @@ static int __init nf_nat_init(void) | |||
834 | { | 845 | { |
835 | int ret; | 846 | int ret; |
836 | 847 | ||
837 | ret = rhashtable_init(&nf_nat_bysource_table, &nf_nat_bysource_params); | 848 | ret = rhltable_init(&nf_nat_bysource_table, &nf_nat_bysource_params); |
838 | if (ret) | 849 | if (ret) |
839 | return ret; | 850 | return ret; |
840 | 851 | ||
841 | ret = nf_ct_extend_register(&nat_extend); | 852 | ret = nf_ct_extend_register(&nat_extend); |
842 | if (ret < 0) { | 853 | if (ret < 0) { |
843 | rhashtable_destroy(&nf_nat_bysource_table); | 854 | rhltable_destroy(&nf_nat_bysource_table); |
844 | printk(KERN_ERR "nf_nat_core: Unable to register extension\n"); | 855 | printk(KERN_ERR "nf_nat_core: Unable to register extension\n"); |
845 | return ret; | 856 | return ret; |
846 | } | 857 | } |
@@ -864,7 +875,7 @@ static int __init nf_nat_init(void) | |||
864 | return 0; | 875 | return 0; |
865 | 876 | ||
866 | cleanup_extend: | 877 | cleanup_extend: |
867 | rhashtable_destroy(&nf_nat_bysource_table); | 878 | rhltable_destroy(&nf_nat_bysource_table); |
868 | nf_ct_extend_unregister(&nat_extend); | 879 | nf_ct_extend_unregister(&nat_extend); |
869 | return ret; | 880 | return ret; |
870 | } | 881 | } |
@@ -883,7 +894,7 @@ static void __exit nf_nat_cleanup(void) | |||
883 | for (i = 0; i < NFPROTO_NUMPROTO; i++) | 894 | for (i = 0; i < NFPROTO_NUMPROTO; i++) |
884 | kfree(nf_nat_l4protos[i]); | 895 | kfree(nf_nat_l4protos[i]); |
885 | 896 | ||
886 | rhashtable_destroy(&nf_nat_bysource_table); | 897 | rhltable_destroy(&nf_nat_bysource_table); |
887 | } | 898 | } |
888 | 899 | ||
889 | MODULE_LICENSE("GPL"); | 900 | MODULE_LICENSE("GPL"); |
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 026581b04ea8..e5194f6f906c 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c | |||
@@ -2570,7 +2570,8 @@ static int nf_tables_fill_set(struct sk_buff *skb, const struct nft_ctx *ctx, | |||
2570 | } | 2570 | } |
2571 | 2571 | ||
2572 | if (set->timeout && | 2572 | if (set->timeout && |
2573 | nla_put_be64(skb, NFTA_SET_TIMEOUT, cpu_to_be64(set->timeout), | 2573 | nla_put_be64(skb, NFTA_SET_TIMEOUT, |
2574 | cpu_to_be64(jiffies_to_msecs(set->timeout)), | ||
2574 | NFTA_SET_PAD)) | 2575 | NFTA_SET_PAD)) |
2575 | goto nla_put_failure; | 2576 | goto nla_put_failure; |
2576 | if (set->gc_int && | 2577 | if (set->gc_int && |
@@ -2859,7 +2860,8 @@ static int nf_tables_newset(struct net *net, struct sock *nlsk, | |||
2859 | if (nla[NFTA_SET_TIMEOUT] != NULL) { | 2860 | if (nla[NFTA_SET_TIMEOUT] != NULL) { |
2860 | if (!(flags & NFT_SET_TIMEOUT)) | 2861 | if (!(flags & NFT_SET_TIMEOUT)) |
2861 | return -EINVAL; | 2862 | return -EINVAL; |
2862 | timeout = be64_to_cpu(nla_get_be64(nla[NFTA_SET_TIMEOUT])); | 2863 | timeout = msecs_to_jiffies(be64_to_cpu(nla_get_be64( |
2864 | nla[NFTA_SET_TIMEOUT]))); | ||
2863 | } | 2865 | } |
2864 | gc_int = 0; | 2866 | gc_int = 0; |
2865 | if (nla[NFTA_SET_GC_INTERVAL] != NULL) { | 2867 | if (nla[NFTA_SET_GC_INTERVAL] != NULL) { |
@@ -3178,7 +3180,8 @@ static int nf_tables_fill_setelem(struct sk_buff *skb, | |||
3178 | 3180 | ||
3179 | if (nft_set_ext_exists(ext, NFT_SET_EXT_TIMEOUT) && | 3181 | if (nft_set_ext_exists(ext, NFT_SET_EXT_TIMEOUT) && |
3180 | nla_put_be64(skb, NFTA_SET_ELEM_TIMEOUT, | 3182 | nla_put_be64(skb, NFTA_SET_ELEM_TIMEOUT, |
3181 | cpu_to_be64(*nft_set_ext_timeout(ext)), | 3183 | cpu_to_be64(jiffies_to_msecs( |
3184 | *nft_set_ext_timeout(ext))), | ||
3182 | NFTA_SET_ELEM_PAD)) | 3185 | NFTA_SET_ELEM_PAD)) |
3183 | goto nla_put_failure; | 3186 | goto nla_put_failure; |
3184 | 3187 | ||
@@ -3447,7 +3450,7 @@ void *nft_set_elem_init(const struct nft_set *set, | |||
3447 | memcpy(nft_set_ext_data(ext), data, set->dlen); | 3450 | memcpy(nft_set_ext_data(ext), data, set->dlen); |
3448 | if (nft_set_ext_exists(ext, NFT_SET_EXT_EXPIRATION)) | 3451 | if (nft_set_ext_exists(ext, NFT_SET_EXT_EXPIRATION)) |
3449 | *nft_set_ext_expiration(ext) = | 3452 | *nft_set_ext_expiration(ext) = |
3450 | jiffies + msecs_to_jiffies(timeout); | 3453 | jiffies + timeout; |
3451 | if (nft_set_ext_exists(ext, NFT_SET_EXT_TIMEOUT)) | 3454 | if (nft_set_ext_exists(ext, NFT_SET_EXT_TIMEOUT)) |
3452 | *nft_set_ext_timeout(ext) = timeout; | 3455 | *nft_set_ext_timeout(ext) = timeout; |
3453 | 3456 | ||
@@ -3535,7 +3538,8 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set, | |||
3535 | if (nla[NFTA_SET_ELEM_TIMEOUT] != NULL) { | 3538 | if (nla[NFTA_SET_ELEM_TIMEOUT] != NULL) { |
3536 | if (!(set->flags & NFT_SET_TIMEOUT)) | 3539 | if (!(set->flags & NFT_SET_TIMEOUT)) |
3537 | return -EINVAL; | 3540 | return -EINVAL; |
3538 | timeout = be64_to_cpu(nla_get_be64(nla[NFTA_SET_ELEM_TIMEOUT])); | 3541 | timeout = msecs_to_jiffies(be64_to_cpu(nla_get_be64( |
3542 | nla[NFTA_SET_ELEM_TIMEOUT]))); | ||
3539 | } else if (set->flags & NFT_SET_TIMEOUT) { | 3543 | } else if (set->flags & NFT_SET_TIMEOUT) { |
3540 | timeout = set->timeout; | 3544 | timeout = set->timeout; |
3541 | } | 3545 | } |
diff --git a/net/netfilter/nft_hash.c b/net/netfilter/nft_hash.c index baf694de3935..d5447a22275c 100644 --- a/net/netfilter/nft_hash.c +++ b/net/netfilter/nft_hash.c | |||
@@ -53,6 +53,7 @@ static int nft_hash_init(const struct nft_ctx *ctx, | |||
53 | { | 53 | { |
54 | struct nft_hash *priv = nft_expr_priv(expr); | 54 | struct nft_hash *priv = nft_expr_priv(expr); |
55 | u32 len; | 55 | u32 len; |
56 | int err; | ||
56 | 57 | ||
57 | if (!tb[NFTA_HASH_SREG] || | 58 | if (!tb[NFTA_HASH_SREG] || |
58 | !tb[NFTA_HASH_DREG] || | 59 | !tb[NFTA_HASH_DREG] || |
@@ -67,8 +68,10 @@ static int nft_hash_init(const struct nft_ctx *ctx, | |||
67 | priv->sreg = nft_parse_register(tb[NFTA_HASH_SREG]); | 68 | priv->sreg = nft_parse_register(tb[NFTA_HASH_SREG]); |
68 | priv->dreg = nft_parse_register(tb[NFTA_HASH_DREG]); | 69 | priv->dreg = nft_parse_register(tb[NFTA_HASH_DREG]); |
69 | 70 | ||
70 | len = ntohl(nla_get_be32(tb[NFTA_HASH_LEN])); | 71 | err = nft_parse_u32_check(tb[NFTA_HASH_LEN], U8_MAX, &len); |
71 | if (len == 0 || len > U8_MAX) | 72 | if (err < 0) |
73 | return err; | ||
74 | if (len == 0) | ||
72 | return -ERANGE; | 75 | return -ERANGE; |
73 | 76 | ||
74 | priv->len = len; | 77 | priv->len = len; |
diff --git a/net/netfilter/nft_range.c b/net/netfilter/nft_range.c index fbc88009ca2e..8f0aaaea1376 100644 --- a/net/netfilter/nft_range.c +++ b/net/netfilter/nft_range.c | |||
@@ -59,6 +59,12 @@ static int nft_range_init(const struct nft_ctx *ctx, const struct nft_expr *expr | |||
59 | int err; | 59 | int err; |
60 | u32 op; | 60 | u32 op; |
61 | 61 | ||
62 | if (!tb[NFTA_RANGE_SREG] || | ||
63 | !tb[NFTA_RANGE_OP] || | ||
64 | !tb[NFTA_RANGE_FROM_DATA] || | ||
65 | !tb[NFTA_RANGE_TO_DATA]) | ||
66 | return -EINVAL; | ||
67 | |||
62 | err = nft_data_init(NULL, &priv->data_from, sizeof(priv->data_from), | 68 | err = nft_data_init(NULL, &priv->data_from, sizeof(priv->data_from), |
63 | &desc_from, tb[NFTA_RANGE_FROM_DATA]); | 69 | &desc_from, tb[NFTA_RANGE_FROM_DATA]); |
64 | if (err < 0) | 70 | if (err < 0) |
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 62bea4591054..602e5ebe9db3 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c | |||
@@ -322,14 +322,11 @@ static void netlink_skb_set_owner_r(struct sk_buff *skb, struct sock *sk) | |||
322 | sk_mem_charge(sk, skb->truesize); | 322 | sk_mem_charge(sk, skb->truesize); |
323 | } | 323 | } |
324 | 324 | ||
325 | static void netlink_sock_destruct(struct sock *sk) | 325 | static void __netlink_sock_destruct(struct sock *sk) |
326 | { | 326 | { |
327 | struct netlink_sock *nlk = nlk_sk(sk); | 327 | struct netlink_sock *nlk = nlk_sk(sk); |
328 | 328 | ||
329 | if (nlk->cb_running) { | 329 | if (nlk->cb_running) { |
330 | if (nlk->cb.done) | ||
331 | nlk->cb.done(&nlk->cb); | ||
332 | |||
333 | module_put(nlk->cb.module); | 330 | module_put(nlk->cb.module); |
334 | kfree_skb(nlk->cb.skb); | 331 | kfree_skb(nlk->cb.skb); |
335 | } | 332 | } |
@@ -346,6 +343,28 @@ static void netlink_sock_destruct(struct sock *sk) | |||
346 | WARN_ON(nlk_sk(sk)->groups); | 343 | WARN_ON(nlk_sk(sk)->groups); |
347 | } | 344 | } |
348 | 345 | ||
346 | static void netlink_sock_destruct_work(struct work_struct *work) | ||
347 | { | ||
348 | struct netlink_sock *nlk = container_of(work, struct netlink_sock, | ||
349 | work); | ||
350 | |||
351 | nlk->cb.done(&nlk->cb); | ||
352 | __netlink_sock_destruct(&nlk->sk); | ||
353 | } | ||
354 | |||
355 | static void netlink_sock_destruct(struct sock *sk) | ||
356 | { | ||
357 | struct netlink_sock *nlk = nlk_sk(sk); | ||
358 | |||
359 | if (nlk->cb_running && nlk->cb.done) { | ||
360 | INIT_WORK(&nlk->work, netlink_sock_destruct_work); | ||
361 | schedule_work(&nlk->work); | ||
362 | return; | ||
363 | } | ||
364 | |||
365 | __netlink_sock_destruct(sk); | ||
366 | } | ||
367 | |||
349 | /* This lock without WQ_FLAG_EXCLUSIVE is good on UP and it is _very_ bad on | 368 | /* This lock without WQ_FLAG_EXCLUSIVE is good on UP and it is _very_ bad on |
350 | * SMP. Look, when several writers sleep and reader wakes them up, all but one | 369 | * SMP. Look, when several writers sleep and reader wakes them up, all but one |
351 | * immediately hit write lock and grab all the cpus. Exclusive sleep solves | 370 | * immediately hit write lock and grab all the cpus. Exclusive sleep solves |
diff --git a/net/netlink/af_netlink.h b/net/netlink/af_netlink.h index 3cfd6cc60504..4fdb38318977 100644 --- a/net/netlink/af_netlink.h +++ b/net/netlink/af_netlink.h | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | #include <linux/rhashtable.h> | 4 | #include <linux/rhashtable.h> |
5 | #include <linux/atomic.h> | 5 | #include <linux/atomic.h> |
6 | #include <linux/workqueue.h> | ||
6 | #include <net/sock.h> | 7 | #include <net/sock.h> |
7 | 8 | ||
8 | #define NLGRPSZ(x) (ALIGN(x, sizeof(unsigned long) * 8) / 8) | 9 | #define NLGRPSZ(x) (ALIGN(x, sizeof(unsigned long) * 8) / 8) |
@@ -33,6 +34,7 @@ struct netlink_sock { | |||
33 | 34 | ||
34 | struct rhash_head node; | 35 | struct rhash_head node; |
35 | struct rcu_head rcu; | 36 | struct rcu_head rcu; |
37 | struct work_struct work; | ||
36 | }; | 38 | }; |
37 | 39 | ||
38 | static inline struct netlink_sock *nlk_sk(struct sock *sk) | 40 | static inline struct netlink_sock *nlk_sk(struct sock *sk) |
diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c index 31045ef44a82..fecefa2dc94e 100644 --- a/net/openvswitch/conntrack.c +++ b/net/openvswitch/conntrack.c | |||
@@ -370,8 +370,11 @@ static int handle_fragments(struct net *net, struct sw_flow_key *key, | |||
370 | skb_orphan(skb); | 370 | skb_orphan(skb); |
371 | memset(IP6CB(skb), 0, sizeof(struct inet6_skb_parm)); | 371 | memset(IP6CB(skb), 0, sizeof(struct inet6_skb_parm)); |
372 | err = nf_ct_frag6_gather(net, skb, user); | 372 | err = nf_ct_frag6_gather(net, skb, user); |
373 | if (err) | 373 | if (err) { |
374 | if (err != -EINPROGRESS) | ||
375 | kfree_skb(skb); | ||
374 | return err; | 376 | return err; |
377 | } | ||
375 | 378 | ||
376 | key->ip.proto = ipv6_hdr(skb)->nexthdr; | 379 | key->ip.proto = ipv6_hdr(skb)->nexthdr; |
377 | ovs_cb.mru = IP6CB(skb)->frag_max_size; | 380 | ovs_cb.mru = IP6CB(skb)->frag_max_size; |
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index d2238b204691..dd2332390c45 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -3648,19 +3648,25 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv | |||
3648 | 3648 | ||
3649 | if (optlen != sizeof(val)) | 3649 | if (optlen != sizeof(val)) |
3650 | return -EINVAL; | 3650 | return -EINVAL; |
3651 | if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) | ||
3652 | return -EBUSY; | ||
3653 | if (copy_from_user(&val, optval, sizeof(val))) | 3651 | if (copy_from_user(&val, optval, sizeof(val))) |
3654 | return -EFAULT; | 3652 | return -EFAULT; |
3655 | switch (val) { | 3653 | switch (val) { |
3656 | case TPACKET_V1: | 3654 | case TPACKET_V1: |
3657 | case TPACKET_V2: | 3655 | case TPACKET_V2: |
3658 | case TPACKET_V3: | 3656 | case TPACKET_V3: |
3659 | po->tp_version = val; | 3657 | break; |
3660 | return 0; | ||
3661 | default: | 3658 | default: |
3662 | return -EINVAL; | 3659 | return -EINVAL; |
3663 | } | 3660 | } |
3661 | lock_sock(sk); | ||
3662 | if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) { | ||
3663 | ret = -EBUSY; | ||
3664 | } else { | ||
3665 | po->tp_version = val; | ||
3666 | ret = 0; | ||
3667 | } | ||
3668 | release_sock(sk); | ||
3669 | return ret; | ||
3664 | } | 3670 | } |
3665 | case PACKET_RESERVE: | 3671 | case PACKET_RESERVE: |
3666 | { | 3672 | { |
@@ -4164,6 +4170,7 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, | |||
4164 | /* Added to avoid minimal code churn */ | 4170 | /* Added to avoid minimal code churn */ |
4165 | struct tpacket_req *req = &req_u->req; | 4171 | struct tpacket_req *req = &req_u->req; |
4166 | 4172 | ||
4173 | lock_sock(sk); | ||
4167 | /* Opening a Tx-ring is NOT supported in TPACKET_V3 */ | 4174 | /* Opening a Tx-ring is NOT supported in TPACKET_V3 */ |
4168 | if (!closing && tx_ring && (po->tp_version > TPACKET_V2)) { | 4175 | if (!closing && tx_ring && (po->tp_version > TPACKET_V2)) { |
4169 | net_warn_ratelimited("Tx-ring is not supported.\n"); | 4176 | net_warn_ratelimited("Tx-ring is not supported.\n"); |
@@ -4245,7 +4252,6 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, | |||
4245 | goto out; | 4252 | goto out; |
4246 | } | 4253 | } |
4247 | 4254 | ||
4248 | lock_sock(sk); | ||
4249 | 4255 | ||
4250 | /* Detach socket from network */ | 4256 | /* Detach socket from network */ |
4251 | spin_lock(&po->bind_lock); | 4257 | spin_lock(&po->bind_lock); |
@@ -4294,11 +4300,11 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, | |||
4294 | if (!tx_ring) | 4300 | if (!tx_ring) |
4295 | prb_shutdown_retire_blk_timer(po, rb_queue); | 4301 | prb_shutdown_retire_blk_timer(po, rb_queue); |
4296 | } | 4302 | } |
4297 | release_sock(sk); | ||
4298 | 4303 | ||
4299 | if (pg_vec) | 4304 | if (pg_vec) |
4300 | free_pg_vec(pg_vec, order, req->tp_block_nr); | 4305 | free_pg_vec(pg_vec, order, req->tp_block_nr); |
4301 | out: | 4306 | out: |
4307 | release_sock(sk); | ||
4302 | return err; | 4308 | return err; |
4303 | } | 4309 | } |
4304 | 4310 | ||
diff --git a/net/rds/tcp.c b/net/rds/tcp.c index fcddacc92e01..20e2923dc827 100644 --- a/net/rds/tcp.c +++ b/net/rds/tcp.c | |||
@@ -659,6 +659,8 @@ out_recv: | |||
659 | out_pernet: | 659 | out_pernet: |
660 | unregister_pernet_subsys(&rds_tcp_net_ops); | 660 | unregister_pernet_subsys(&rds_tcp_net_ops); |
661 | out_slab: | 661 | out_slab: |
662 | if (unregister_netdevice_notifier(&rds_tcp_dev_notifier)) | ||
663 | pr_warn("could not unregister rds_tcp_dev_notifier\n"); | ||
662 | kmem_cache_destroy(rds_tcp_conn_slab); | 664 | kmem_cache_destroy(rds_tcp_conn_slab); |
663 | out: | 665 | out: |
664 | return ret; | 666 | return ret; |
diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c index b54d56d4959b..cf9b2fe8eac6 100644 --- a/net/sched/act_pedit.c +++ b/net/sched/act_pedit.c | |||
@@ -108,6 +108,17 @@ static void tcf_pedit_cleanup(struct tc_action *a, int bind) | |||
108 | kfree(keys); | 108 | kfree(keys); |
109 | } | 109 | } |
110 | 110 | ||
111 | static bool offset_valid(struct sk_buff *skb, int offset) | ||
112 | { | ||
113 | if (offset > 0 && offset > skb->len) | ||
114 | return false; | ||
115 | |||
116 | if (offset < 0 && -offset > skb_headroom(skb)) | ||
117 | return false; | ||
118 | |||
119 | return true; | ||
120 | } | ||
121 | |||
111 | static int tcf_pedit(struct sk_buff *skb, const struct tc_action *a, | 122 | static int tcf_pedit(struct sk_buff *skb, const struct tc_action *a, |
112 | struct tcf_result *res) | 123 | struct tcf_result *res) |
113 | { | 124 | { |
@@ -134,6 +145,11 @@ static int tcf_pedit(struct sk_buff *skb, const struct tc_action *a, | |||
134 | if (tkey->offmask) { | 145 | if (tkey->offmask) { |
135 | char *d, _d; | 146 | char *d, _d; |
136 | 147 | ||
148 | if (!offset_valid(skb, off + tkey->at)) { | ||
149 | pr_info("tc filter pedit 'at' offset %d out of bounds\n", | ||
150 | off + tkey->at); | ||
151 | goto bad; | ||
152 | } | ||
137 | d = skb_header_pointer(skb, off + tkey->at, 1, | 153 | d = skb_header_pointer(skb, off + tkey->at, 1, |
138 | &_d); | 154 | &_d); |
139 | if (!d) | 155 | if (!d) |
@@ -146,10 +162,10 @@ static int tcf_pedit(struct sk_buff *skb, const struct tc_action *a, | |||
146 | " offset must be on 32 bit boundaries\n"); | 162 | " offset must be on 32 bit boundaries\n"); |
147 | goto bad; | 163 | goto bad; |
148 | } | 164 | } |
149 | if (offset > 0 && offset > skb->len) { | 165 | |
150 | pr_info("tc filter pedit" | 166 | if (!offset_valid(skb, off + offset)) { |
151 | " offset %d can't exceed pkt length %d\n", | 167 | pr_info("tc filter pedit offset %d out of bounds\n", |
152 | offset, skb->len); | 168 | offset); |
153 | goto bad; | 169 | goto bad; |
154 | } | 170 | } |
155 | 171 | ||
diff --git a/net/sched/cls_basic.c b/net/sched/cls_basic.c index eb219b78cd49..5877f6061b57 100644 --- a/net/sched/cls_basic.c +++ b/net/sched/cls_basic.c | |||
@@ -62,9 +62,6 @@ static unsigned long basic_get(struct tcf_proto *tp, u32 handle) | |||
62 | struct basic_head *head = rtnl_dereference(tp->root); | 62 | struct basic_head *head = rtnl_dereference(tp->root); |
63 | struct basic_filter *f; | 63 | struct basic_filter *f; |
64 | 64 | ||
65 | if (head == NULL) | ||
66 | return 0UL; | ||
67 | |||
68 | list_for_each_entry(f, &head->flist, link) { | 65 | list_for_each_entry(f, &head->flist, link) { |
69 | if (f->handle == handle) { | 66 | if (f->handle == handle) { |
70 | l = (unsigned long) f; | 67 | l = (unsigned long) f; |
@@ -109,7 +106,6 @@ static bool basic_destroy(struct tcf_proto *tp, bool force) | |||
109 | tcf_unbind_filter(tp, &f->res); | 106 | tcf_unbind_filter(tp, &f->res); |
110 | call_rcu(&f->rcu, basic_delete_filter); | 107 | call_rcu(&f->rcu, basic_delete_filter); |
111 | } | 108 | } |
112 | RCU_INIT_POINTER(tp->root, NULL); | ||
113 | kfree_rcu(head, rcu); | 109 | kfree_rcu(head, rcu); |
114 | return true; | 110 | return true; |
115 | } | 111 | } |
diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c index bb1d5a487081..0a47ba5e6109 100644 --- a/net/sched/cls_bpf.c +++ b/net/sched/cls_bpf.c | |||
@@ -292,7 +292,6 @@ static bool cls_bpf_destroy(struct tcf_proto *tp, bool force) | |||
292 | call_rcu(&prog->rcu, __cls_bpf_delete_prog); | 292 | call_rcu(&prog->rcu, __cls_bpf_delete_prog); |
293 | } | 293 | } |
294 | 294 | ||
295 | RCU_INIT_POINTER(tp->root, NULL); | ||
296 | kfree_rcu(head, rcu); | 295 | kfree_rcu(head, rcu); |
297 | return true; | 296 | return true; |
298 | } | 297 | } |
@@ -303,9 +302,6 @@ static unsigned long cls_bpf_get(struct tcf_proto *tp, u32 handle) | |||
303 | struct cls_bpf_prog *prog; | 302 | struct cls_bpf_prog *prog; |
304 | unsigned long ret = 0UL; | 303 | unsigned long ret = 0UL; |
305 | 304 | ||
306 | if (head == NULL) | ||
307 | return 0UL; | ||
308 | |||
309 | list_for_each_entry(prog, &head->plist, link) { | 305 | list_for_each_entry(prog, &head->plist, link) { |
310 | if (prog->handle == handle) { | 306 | if (prog->handle == handle) { |
311 | ret = (unsigned long) prog; | 307 | ret = (unsigned long) prog; |
diff --git a/net/sched/cls_cgroup.c b/net/sched/cls_cgroup.c index 85233c470035..c1f20077837f 100644 --- a/net/sched/cls_cgroup.c +++ b/net/sched/cls_cgroup.c | |||
@@ -137,11 +137,10 @@ static bool cls_cgroup_destroy(struct tcf_proto *tp, bool force) | |||
137 | 137 | ||
138 | if (!force) | 138 | if (!force) |
139 | return false; | 139 | return false; |
140 | 140 | /* Head can still be NULL due to cls_cgroup_init(). */ | |
141 | if (head) { | 141 | if (head) |
142 | RCU_INIT_POINTER(tp->root, NULL); | ||
143 | call_rcu(&head->rcu, cls_cgroup_destroy_rcu); | 142 | call_rcu(&head->rcu, cls_cgroup_destroy_rcu); |
144 | } | 143 | |
145 | return true; | 144 | return true; |
146 | } | 145 | } |
147 | 146 | ||
diff --git a/net/sched/cls_flow.c b/net/sched/cls_flow.c index e39672394c7b..6575aba87630 100644 --- a/net/sched/cls_flow.c +++ b/net/sched/cls_flow.c | |||
@@ -596,7 +596,6 @@ static bool flow_destroy(struct tcf_proto *tp, bool force) | |||
596 | list_del_rcu(&f->list); | 596 | list_del_rcu(&f->list); |
597 | call_rcu(&f->rcu, flow_destroy_filter); | 597 | call_rcu(&f->rcu, flow_destroy_filter); |
598 | } | 598 | } |
599 | RCU_INIT_POINTER(tp->root, NULL); | ||
600 | kfree_rcu(head, rcu); | 599 | kfree_rcu(head, rcu); |
601 | return true; | 600 | return true; |
602 | } | 601 | } |
diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index f6f40fba599b..904442421db3 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/rhashtable.h> | 15 | #include <linux/rhashtable.h> |
16 | #include <linux/workqueue.h> | ||
16 | 17 | ||
17 | #include <linux/if_ether.h> | 18 | #include <linux/if_ether.h> |
18 | #include <linux/in6.h> | 19 | #include <linux/in6.h> |
@@ -64,7 +65,10 @@ struct cls_fl_head { | |||
64 | bool mask_assigned; | 65 | bool mask_assigned; |
65 | struct list_head filters; | 66 | struct list_head filters; |
66 | struct rhashtable_params ht_params; | 67 | struct rhashtable_params ht_params; |
67 | struct rcu_head rcu; | 68 | union { |
69 | struct work_struct work; | ||
70 | struct rcu_head rcu; | ||
71 | }; | ||
68 | }; | 72 | }; |
69 | 73 | ||
70 | struct cls_fl_filter { | 74 | struct cls_fl_filter { |
@@ -269,6 +273,24 @@ static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f) | |||
269 | dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, tp->protocol, &tc); | 273 | dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, tp->protocol, &tc); |
270 | } | 274 | } |
271 | 275 | ||
276 | static void fl_destroy_sleepable(struct work_struct *work) | ||
277 | { | ||
278 | struct cls_fl_head *head = container_of(work, struct cls_fl_head, | ||
279 | work); | ||
280 | if (head->mask_assigned) | ||
281 | rhashtable_destroy(&head->ht); | ||
282 | kfree(head); | ||
283 | module_put(THIS_MODULE); | ||
284 | } | ||
285 | |||
286 | static void fl_destroy_rcu(struct rcu_head *rcu) | ||
287 | { | ||
288 | struct cls_fl_head *head = container_of(rcu, struct cls_fl_head, rcu); | ||
289 | |||
290 | INIT_WORK(&head->work, fl_destroy_sleepable); | ||
291 | schedule_work(&head->work); | ||
292 | } | ||
293 | |||
272 | static bool fl_destroy(struct tcf_proto *tp, bool force) | 294 | static bool fl_destroy(struct tcf_proto *tp, bool force) |
273 | { | 295 | { |
274 | struct cls_fl_head *head = rtnl_dereference(tp->root); | 296 | struct cls_fl_head *head = rtnl_dereference(tp->root); |
@@ -282,10 +304,9 @@ static bool fl_destroy(struct tcf_proto *tp, bool force) | |||
282 | list_del_rcu(&f->list); | 304 | list_del_rcu(&f->list); |
283 | call_rcu(&f->rcu, fl_destroy_filter); | 305 | call_rcu(&f->rcu, fl_destroy_filter); |
284 | } | 306 | } |
285 | RCU_INIT_POINTER(tp->root, NULL); | 307 | |
286 | if (head->mask_assigned) | 308 | __module_get(THIS_MODULE); |
287 | rhashtable_destroy(&head->ht); | 309 | call_rcu(&head->rcu, fl_destroy_rcu); |
288 | kfree_rcu(head, rcu); | ||
289 | return true; | 310 | return true; |
290 | } | 311 | } |
291 | 312 | ||
@@ -711,8 +732,9 @@ static int fl_change(struct net *net, struct sk_buff *in_skb, | |||
711 | goto errout; | 732 | goto errout; |
712 | 733 | ||
713 | if (fold) { | 734 | if (fold) { |
714 | rhashtable_remove_fast(&head->ht, &fold->ht_node, | 735 | if (!tc_skip_sw(fold->flags)) |
715 | head->ht_params); | 736 | rhashtable_remove_fast(&head->ht, &fold->ht_node, |
737 | head->ht_params); | ||
716 | fl_hw_destroy_filter(tp, (unsigned long)fold); | 738 | fl_hw_destroy_filter(tp, (unsigned long)fold); |
717 | } | 739 | } |
718 | 740 | ||
@@ -739,8 +761,9 @@ static int fl_delete(struct tcf_proto *tp, unsigned long arg) | |||
739 | struct cls_fl_head *head = rtnl_dereference(tp->root); | 761 | struct cls_fl_head *head = rtnl_dereference(tp->root); |
740 | struct cls_fl_filter *f = (struct cls_fl_filter *) arg; | 762 | struct cls_fl_filter *f = (struct cls_fl_filter *) arg; |
741 | 763 | ||
742 | rhashtable_remove_fast(&head->ht, &f->ht_node, | 764 | if (!tc_skip_sw(f->flags)) |
743 | head->ht_params); | 765 | rhashtable_remove_fast(&head->ht, &f->ht_node, |
766 | head->ht_params); | ||
744 | list_del_rcu(&f->list); | 767 | list_del_rcu(&f->list); |
745 | fl_hw_destroy_filter(tp, (unsigned long)f); | 768 | fl_hw_destroy_filter(tp, (unsigned long)f); |
746 | tcf_unbind_filter(tp, &f->res); | 769 | tcf_unbind_filter(tp, &f->res); |
diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c index 25927b6c4436..f935429bd5ef 100644 --- a/net/sched/cls_matchall.c +++ b/net/sched/cls_matchall.c | |||
@@ -114,7 +114,6 @@ static bool mall_destroy(struct tcf_proto *tp, bool force) | |||
114 | 114 | ||
115 | call_rcu(&f->rcu, mall_destroy_filter); | 115 | call_rcu(&f->rcu, mall_destroy_filter); |
116 | } | 116 | } |
117 | RCU_INIT_POINTER(tp->root, NULL); | ||
118 | kfree_rcu(head, rcu); | 117 | kfree_rcu(head, rcu); |
119 | return true; | 118 | return true; |
120 | } | 119 | } |
diff --git a/net/sched/cls_rsvp.h b/net/sched/cls_rsvp.h index 4f05a19fb073..322438fb3ffc 100644 --- a/net/sched/cls_rsvp.h +++ b/net/sched/cls_rsvp.h | |||
@@ -152,7 +152,8 @@ static int rsvp_classify(struct sk_buff *skb, const struct tcf_proto *tp, | |||
152 | return -1; | 152 | return -1; |
153 | nhptr = ip_hdr(skb); | 153 | nhptr = ip_hdr(skb); |
154 | #endif | 154 | #endif |
155 | 155 | if (unlikely(!head)) | |
156 | return -1; | ||
156 | restart: | 157 | restart: |
157 | 158 | ||
158 | #if RSVP_DST_LEN == 4 | 159 | #if RSVP_DST_LEN == 4 |
diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c index 96144bdf30db..0751245a6ace 100644 --- a/net/sched/cls_tcindex.c +++ b/net/sched/cls_tcindex.c | |||
@@ -543,7 +543,6 @@ static bool tcindex_destroy(struct tcf_proto *tp, bool force) | |||
543 | walker.fn = tcindex_destroy_element; | 543 | walker.fn = tcindex_destroy_element; |
544 | tcindex_walk(tp, &walker); | 544 | tcindex_walk(tp, &walker); |
545 | 545 | ||
546 | RCU_INIT_POINTER(tp->root, NULL); | ||
547 | call_rcu(&p->rcu, __tcindex_destroy); | 546 | call_rcu(&p->rcu, __tcindex_destroy); |
548 | return true; | 547 | return true; |
549 | } | 548 | } |
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 975dbeb60ab0..52d74760fb68 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c | |||
@@ -421,6 +421,10 @@ int tipc_enable_l2_media(struct net *net, struct tipc_bearer *b, | |||
421 | dev = dev_get_by_name(net, driver_name); | 421 | dev = dev_get_by_name(net, driver_name); |
422 | if (!dev) | 422 | if (!dev) |
423 | return -ENODEV; | 423 | return -ENODEV; |
424 | if (tipc_mtu_bad(dev, 0)) { | ||
425 | dev_put(dev); | ||
426 | return -EINVAL; | ||
427 | } | ||
424 | 428 | ||
425 | /* Associate TIPC bearer with L2 bearer */ | 429 | /* Associate TIPC bearer with L2 bearer */ |
426 | rcu_assign_pointer(b->media_ptr, dev); | 430 | rcu_assign_pointer(b->media_ptr, dev); |
@@ -610,8 +614,6 @@ static int tipc_l2_device_event(struct notifier_block *nb, unsigned long evt, | |||
610 | if (!b) | 614 | if (!b) |
611 | return NOTIFY_DONE; | 615 | return NOTIFY_DONE; |
612 | 616 | ||
613 | b->mtu = dev->mtu; | ||
614 | |||
615 | switch (evt) { | 617 | switch (evt) { |
616 | case NETDEV_CHANGE: | 618 | case NETDEV_CHANGE: |
617 | if (netif_carrier_ok(dev)) | 619 | if (netif_carrier_ok(dev)) |
@@ -624,6 +626,11 @@ static int tipc_l2_device_event(struct notifier_block *nb, unsigned long evt, | |||
624 | tipc_reset_bearer(net, b); | 626 | tipc_reset_bearer(net, b); |
625 | break; | 627 | break; |
626 | case NETDEV_CHANGEMTU: | 628 | case NETDEV_CHANGEMTU: |
629 | if (tipc_mtu_bad(dev, 0)) { | ||
630 | bearer_disable(net, b); | ||
631 | break; | ||
632 | } | ||
633 | b->mtu = dev->mtu; | ||
627 | tipc_reset_bearer(net, b); | 634 | tipc_reset_bearer(net, b); |
628 | break; | 635 | break; |
629 | case NETDEV_CHANGEADDR: | 636 | case NETDEV_CHANGEADDR: |
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h index 78892e2f53e3..278ff7f616f9 100644 --- a/net/tipc/bearer.h +++ b/net/tipc/bearer.h | |||
@@ -39,6 +39,7 @@ | |||
39 | 39 | ||
40 | #include "netlink.h" | 40 | #include "netlink.h" |
41 | #include "core.h" | 41 | #include "core.h" |
42 | #include "msg.h" | ||
42 | #include <net/genetlink.h> | 43 | #include <net/genetlink.h> |
43 | 44 | ||
44 | #define MAX_MEDIA 3 | 45 | #define MAX_MEDIA 3 |
@@ -59,6 +60,9 @@ | |||
59 | #define TIPC_MEDIA_TYPE_IB 2 | 60 | #define TIPC_MEDIA_TYPE_IB 2 |
60 | #define TIPC_MEDIA_TYPE_UDP 3 | 61 | #define TIPC_MEDIA_TYPE_UDP 3 |
61 | 62 | ||
63 | /* minimum bearer MTU */ | ||
64 | #define TIPC_MIN_BEARER_MTU (MAX_H_SIZE + INT_H_SIZE) | ||
65 | |||
62 | /** | 66 | /** |
63 | * struct tipc_media_addr - destination address used by TIPC bearers | 67 | * struct tipc_media_addr - destination address used by TIPC bearers |
64 | * @value: address info (format defined by media) | 68 | * @value: address info (format defined by media) |
@@ -215,4 +219,13 @@ void tipc_bearer_xmit(struct net *net, u32 bearer_id, | |||
215 | void tipc_bearer_bc_xmit(struct net *net, u32 bearer_id, | 219 | void tipc_bearer_bc_xmit(struct net *net, u32 bearer_id, |
216 | struct sk_buff_head *xmitq); | 220 | struct sk_buff_head *xmitq); |
217 | 221 | ||
222 | /* check if device MTU is too low for tipc headers */ | ||
223 | static inline bool tipc_mtu_bad(struct net_device *dev, unsigned int reserve) | ||
224 | { | ||
225 | if (dev->mtu >= TIPC_MIN_BEARER_MTU + reserve) | ||
226 | return false; | ||
227 | netdev_warn(dev, "MTU too low for tipc bearer\n"); | ||
228 | return true; | ||
229 | } | ||
230 | |||
218 | #endif /* _TIPC_BEARER_H */ | 231 | #endif /* _TIPC_BEARER_H */ |
diff --git a/net/tipc/link.c b/net/tipc/link.c index ecc12411155e..bda89bf9f4ff 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
@@ -47,8 +47,8 @@ | |||
47 | #include <linux/pkt_sched.h> | 47 | #include <linux/pkt_sched.h> |
48 | 48 | ||
49 | struct tipc_stats { | 49 | struct tipc_stats { |
50 | u32 sent_info; /* used in counting # sent packets */ | 50 | u32 sent_pkts; |
51 | u32 recv_info; /* used in counting # recv'd packets */ | 51 | u32 recv_pkts; |
52 | u32 sent_states; | 52 | u32 sent_states; |
53 | u32 recv_states; | 53 | u32 recv_states; |
54 | u32 sent_probes; | 54 | u32 sent_probes; |
@@ -857,7 +857,6 @@ void tipc_link_reset(struct tipc_link *l) | |||
857 | l->acked = 0; | 857 | l->acked = 0; |
858 | l->silent_intv_cnt = 0; | 858 | l->silent_intv_cnt = 0; |
859 | l->rst_cnt = 0; | 859 | l->rst_cnt = 0; |
860 | l->stats.recv_info = 0; | ||
861 | l->stale_count = 0; | 860 | l->stale_count = 0; |
862 | l->bc_peer_is_up = false; | 861 | l->bc_peer_is_up = false; |
863 | memset(&l->mon_state, 0, sizeof(l->mon_state)); | 862 | memset(&l->mon_state, 0, sizeof(l->mon_state)); |
@@ -888,6 +887,7 @@ int tipc_link_xmit(struct tipc_link *l, struct sk_buff_head *list, | |||
888 | struct sk_buff_head *transmq = &l->transmq; | 887 | struct sk_buff_head *transmq = &l->transmq; |
889 | struct sk_buff_head *backlogq = &l->backlogq; | 888 | struct sk_buff_head *backlogq = &l->backlogq; |
890 | struct sk_buff *skb, *_skb, *bskb; | 889 | struct sk_buff *skb, *_skb, *bskb; |
890 | int pkt_cnt = skb_queue_len(list); | ||
891 | 891 | ||
892 | /* Match msg importance against this and all higher backlog limits: */ | 892 | /* Match msg importance against this and all higher backlog limits: */ |
893 | if (!skb_queue_empty(backlogq)) { | 893 | if (!skb_queue_empty(backlogq)) { |
@@ -901,6 +901,11 @@ int tipc_link_xmit(struct tipc_link *l, struct sk_buff_head *list, | |||
901 | return -EMSGSIZE; | 901 | return -EMSGSIZE; |
902 | } | 902 | } |
903 | 903 | ||
904 | if (pkt_cnt > 1) { | ||
905 | l->stats.sent_fragmented++; | ||
906 | l->stats.sent_fragments += pkt_cnt; | ||
907 | } | ||
908 | |||
904 | /* Prepare each packet for sending, and add to relevant queue: */ | 909 | /* Prepare each packet for sending, and add to relevant queue: */ |
905 | while (skb_queue_len(list)) { | 910 | while (skb_queue_len(list)) { |
906 | skb = skb_peek(list); | 911 | skb = skb_peek(list); |
@@ -920,6 +925,7 @@ int tipc_link_xmit(struct tipc_link *l, struct sk_buff_head *list, | |||
920 | __skb_queue_tail(xmitq, _skb); | 925 | __skb_queue_tail(xmitq, _skb); |
921 | TIPC_SKB_CB(skb)->ackers = l->ackers; | 926 | TIPC_SKB_CB(skb)->ackers = l->ackers; |
922 | l->rcv_unacked = 0; | 927 | l->rcv_unacked = 0; |
928 | l->stats.sent_pkts++; | ||
923 | seqno++; | 929 | seqno++; |
924 | continue; | 930 | continue; |
925 | } | 931 | } |
@@ -968,6 +974,7 @@ void tipc_link_advance_backlog(struct tipc_link *l, struct sk_buff_head *xmitq) | |||
968 | msg_set_ack(hdr, ack); | 974 | msg_set_ack(hdr, ack); |
969 | msg_set_bcast_ack(hdr, bc_ack); | 975 | msg_set_bcast_ack(hdr, bc_ack); |
970 | l->rcv_unacked = 0; | 976 | l->rcv_unacked = 0; |
977 | l->stats.sent_pkts++; | ||
971 | seqno++; | 978 | seqno++; |
972 | } | 979 | } |
973 | l->snd_nxt = seqno; | 980 | l->snd_nxt = seqno; |
@@ -1260,7 +1267,7 @@ int tipc_link_rcv(struct tipc_link *l, struct sk_buff *skb, | |||
1260 | 1267 | ||
1261 | /* Deliver packet */ | 1268 | /* Deliver packet */ |
1262 | l->rcv_nxt++; | 1269 | l->rcv_nxt++; |
1263 | l->stats.recv_info++; | 1270 | l->stats.recv_pkts++; |
1264 | if (!tipc_data_input(l, skb, l->inputq)) | 1271 | if (!tipc_data_input(l, skb, l->inputq)) |
1265 | rc |= tipc_link_input(l, skb, l->inputq); | 1272 | rc |= tipc_link_input(l, skb, l->inputq); |
1266 | if (unlikely(++l->rcv_unacked >= TIPC_MIN_LINK_WIN)) | 1273 | if (unlikely(++l->rcv_unacked >= TIPC_MIN_LINK_WIN)) |
@@ -1800,10 +1807,6 @@ void tipc_link_set_queue_limits(struct tipc_link *l, u32 win) | |||
1800 | void tipc_link_reset_stats(struct tipc_link *l) | 1807 | void tipc_link_reset_stats(struct tipc_link *l) |
1801 | { | 1808 | { |
1802 | memset(&l->stats, 0, sizeof(l->stats)); | 1809 | memset(&l->stats, 0, sizeof(l->stats)); |
1803 | if (!link_is_bc_sndlink(l)) { | ||
1804 | l->stats.sent_info = l->snd_nxt; | ||
1805 | l->stats.recv_info = l->rcv_nxt; | ||
1806 | } | ||
1807 | } | 1810 | } |
1808 | 1811 | ||
1809 | static void link_print(struct tipc_link *l, const char *str) | 1812 | static void link_print(struct tipc_link *l, const char *str) |
@@ -1867,12 +1870,12 @@ static int __tipc_nl_add_stats(struct sk_buff *skb, struct tipc_stats *s) | |||
1867 | }; | 1870 | }; |
1868 | 1871 | ||
1869 | struct nla_map map[] = { | 1872 | struct nla_map map[] = { |
1870 | {TIPC_NLA_STATS_RX_INFO, s->recv_info}, | 1873 | {TIPC_NLA_STATS_RX_INFO, 0}, |
1871 | {TIPC_NLA_STATS_RX_FRAGMENTS, s->recv_fragments}, | 1874 | {TIPC_NLA_STATS_RX_FRAGMENTS, s->recv_fragments}, |
1872 | {TIPC_NLA_STATS_RX_FRAGMENTED, s->recv_fragmented}, | 1875 | {TIPC_NLA_STATS_RX_FRAGMENTED, s->recv_fragmented}, |
1873 | {TIPC_NLA_STATS_RX_BUNDLES, s->recv_bundles}, | 1876 | {TIPC_NLA_STATS_RX_BUNDLES, s->recv_bundles}, |
1874 | {TIPC_NLA_STATS_RX_BUNDLED, s->recv_bundled}, | 1877 | {TIPC_NLA_STATS_RX_BUNDLED, s->recv_bundled}, |
1875 | {TIPC_NLA_STATS_TX_INFO, s->sent_info}, | 1878 | {TIPC_NLA_STATS_TX_INFO, 0}, |
1876 | {TIPC_NLA_STATS_TX_FRAGMENTS, s->sent_fragments}, | 1879 | {TIPC_NLA_STATS_TX_FRAGMENTS, s->sent_fragments}, |
1877 | {TIPC_NLA_STATS_TX_FRAGMENTED, s->sent_fragmented}, | 1880 | {TIPC_NLA_STATS_TX_FRAGMENTED, s->sent_fragmented}, |
1878 | {TIPC_NLA_STATS_TX_BUNDLES, s->sent_bundles}, | 1881 | {TIPC_NLA_STATS_TX_BUNDLES, s->sent_bundles}, |
@@ -1947,9 +1950,9 @@ int __tipc_nl_add_link(struct net *net, struct tipc_nl_msg *msg, | |||
1947 | goto attr_msg_full; | 1950 | goto attr_msg_full; |
1948 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_MTU, link->mtu)) | 1951 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_MTU, link->mtu)) |
1949 | goto attr_msg_full; | 1952 | goto attr_msg_full; |
1950 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, link->rcv_nxt)) | 1953 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, link->stats.recv_pkts)) |
1951 | goto attr_msg_full; | 1954 | goto attr_msg_full; |
1952 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, link->snd_nxt)) | 1955 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, link->stats.sent_pkts)) |
1953 | goto attr_msg_full; | 1956 | goto attr_msg_full; |
1954 | 1957 | ||
1955 | if (tipc_link_is_up(link)) | 1958 | if (tipc_link_is_up(link)) |
@@ -2004,12 +2007,12 @@ static int __tipc_nl_add_bc_link_stat(struct sk_buff *skb, | |||
2004 | }; | 2007 | }; |
2005 | 2008 | ||
2006 | struct nla_map map[] = { | 2009 | struct nla_map map[] = { |
2007 | {TIPC_NLA_STATS_RX_INFO, stats->recv_info}, | 2010 | {TIPC_NLA_STATS_RX_INFO, stats->recv_pkts}, |
2008 | {TIPC_NLA_STATS_RX_FRAGMENTS, stats->recv_fragments}, | 2011 | {TIPC_NLA_STATS_RX_FRAGMENTS, stats->recv_fragments}, |
2009 | {TIPC_NLA_STATS_RX_FRAGMENTED, stats->recv_fragmented}, | 2012 | {TIPC_NLA_STATS_RX_FRAGMENTED, stats->recv_fragmented}, |
2010 | {TIPC_NLA_STATS_RX_BUNDLES, stats->recv_bundles}, | 2013 | {TIPC_NLA_STATS_RX_BUNDLES, stats->recv_bundles}, |
2011 | {TIPC_NLA_STATS_RX_BUNDLED, stats->recv_bundled}, | 2014 | {TIPC_NLA_STATS_RX_BUNDLED, stats->recv_bundled}, |
2012 | {TIPC_NLA_STATS_TX_INFO, stats->sent_info}, | 2015 | {TIPC_NLA_STATS_TX_INFO, stats->sent_pkts}, |
2013 | {TIPC_NLA_STATS_TX_FRAGMENTS, stats->sent_fragments}, | 2016 | {TIPC_NLA_STATS_TX_FRAGMENTS, stats->sent_fragments}, |
2014 | {TIPC_NLA_STATS_TX_FRAGMENTED, stats->sent_fragmented}, | 2017 | {TIPC_NLA_STATS_TX_FRAGMENTED, stats->sent_fragmented}, |
2015 | {TIPC_NLA_STATS_TX_BUNDLES, stats->sent_bundles}, | 2018 | {TIPC_NLA_STATS_TX_BUNDLES, stats->sent_bundles}, |
@@ -2076,9 +2079,9 @@ int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg) | |||
2076 | goto attr_msg_full; | 2079 | goto attr_msg_full; |
2077 | if (nla_put_string(msg->skb, TIPC_NLA_LINK_NAME, bcl->name)) | 2080 | if (nla_put_string(msg->skb, TIPC_NLA_LINK_NAME, bcl->name)) |
2078 | goto attr_msg_full; | 2081 | goto attr_msg_full; |
2079 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, bcl->rcv_nxt)) | 2082 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, 0)) |
2080 | goto attr_msg_full; | 2083 | goto attr_msg_full; |
2081 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, bcl->snd_nxt)) | 2084 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, 0)) |
2082 | goto attr_msg_full; | 2085 | goto attr_msg_full; |
2083 | 2086 | ||
2084 | prop = nla_nest_start(msg->skb, TIPC_NLA_LINK_PROP); | 2087 | prop = nla_nest_start(msg->skb, TIPC_NLA_LINK_PROP); |
diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c index 78cab9c5a445..b58dc95f3d35 100644 --- a/net/tipc/udp_media.c +++ b/net/tipc/udp_media.c | |||
@@ -697,6 +697,11 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b, | |||
697 | udp_conf.local_ip.s_addr = htonl(INADDR_ANY); | 697 | udp_conf.local_ip.s_addr = htonl(INADDR_ANY); |
698 | udp_conf.use_udp_checksums = false; | 698 | udp_conf.use_udp_checksums = false; |
699 | ub->ifindex = dev->ifindex; | 699 | ub->ifindex = dev->ifindex; |
700 | if (tipc_mtu_bad(dev, sizeof(struct iphdr) + | ||
701 | sizeof(struct udphdr))) { | ||
702 | err = -EINVAL; | ||
703 | goto err; | ||
704 | } | ||
700 | b->mtu = dev->mtu - sizeof(struct iphdr) | 705 | b->mtu = dev->mtu - sizeof(struct iphdr) |
701 | - sizeof(struct udphdr); | 706 | - sizeof(struct udphdr); |
702 | #if IS_ENABLED(CONFIG_IPV6) | 707 | #if IS_ENABLED(CONFIG_IPV6) |
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index fd6986634e6f..5bf7e1bfeac7 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c | |||
@@ -1268,12 +1268,14 @@ static struct xfrm_policy *xfrm_sk_policy_lookup(const struct sock *sk, int dir, | |||
1268 | err = security_xfrm_policy_lookup(pol->security, | 1268 | err = security_xfrm_policy_lookup(pol->security, |
1269 | fl->flowi_secid, | 1269 | fl->flowi_secid, |
1270 | policy_to_flow_dir(dir)); | 1270 | policy_to_flow_dir(dir)); |
1271 | if (!err && !xfrm_pol_hold_rcu(pol)) | 1271 | if (!err) { |
1272 | goto again; | 1272 | if (!xfrm_pol_hold_rcu(pol)) |
1273 | else if (err == -ESRCH) | 1273 | goto again; |
1274 | } else if (err == -ESRCH) { | ||
1274 | pol = NULL; | 1275 | pol = NULL; |
1275 | else | 1276 | } else { |
1276 | pol = ERR_PTR(err); | 1277 | pol = ERR_PTR(err); |
1278 | } | ||
1277 | } else | 1279 | } else |
1278 | pol = NULL; | 1280 | pol = NULL; |
1279 | } | 1281 | } |
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index 08892091cfe3..671a1d0333f0 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c | |||
@@ -2450,7 +2450,7 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
2450 | 2450 | ||
2451 | #ifdef CONFIG_COMPAT | 2451 | #ifdef CONFIG_COMPAT |
2452 | if (in_compat_syscall()) | 2452 | if (in_compat_syscall()) |
2453 | return -ENOTSUPP; | 2453 | return -EOPNOTSUPP; |
2454 | #endif | 2454 | #endif |
2455 | 2455 | ||
2456 | type = nlh->nlmsg_type; | 2456 | type = nlh->nlmsg_type; |
diff --git a/samples/bpf/bpf_helpers.h b/samples/bpf/bpf_helpers.h index 90f44bd2045e..dadd5161bd91 100644 --- a/samples/bpf/bpf_helpers.h +++ b/samples/bpf/bpf_helpers.h | |||
@@ -113,7 +113,7 @@ static int (*bpf_skb_under_cgroup)(void *ctx, void *map, int index) = | |||
113 | #define PT_REGS_FP(x) ((x)->gprs[11]) /* Works only with CONFIG_FRAME_POINTER */ | 113 | #define PT_REGS_FP(x) ((x)->gprs[11]) /* Works only with CONFIG_FRAME_POINTER */ |
114 | #define PT_REGS_RC(x) ((x)->gprs[2]) | 114 | #define PT_REGS_RC(x) ((x)->gprs[2]) |
115 | #define PT_REGS_SP(x) ((x)->gprs[15]) | 115 | #define PT_REGS_SP(x) ((x)->gprs[15]) |
116 | #define PT_REGS_IP(x) ((x)->ip) | 116 | #define PT_REGS_IP(x) ((x)->psw.addr) |
117 | 117 | ||
118 | #elif defined(__aarch64__) | 118 | #elif defined(__aarch64__) |
119 | 119 | ||
diff --git a/samples/bpf/sampleip_kern.c b/samples/bpf/sampleip_kern.c index 774a681f374a..ceabf31079cf 100644 --- a/samples/bpf/sampleip_kern.c +++ b/samples/bpf/sampleip_kern.c | |||
@@ -25,7 +25,7 @@ int do_sample(struct bpf_perf_event_data *ctx) | |||
25 | u64 ip; | 25 | u64 ip; |
26 | u32 *value, init_val = 1; | 26 | u32 *value, init_val = 1; |
27 | 27 | ||
28 | ip = ctx->regs.ip; | 28 | ip = PT_REGS_IP(&ctx->regs); |
29 | value = bpf_map_lookup_elem(&ip_map, &ip); | 29 | value = bpf_map_lookup_elem(&ip_map, &ip); |
30 | if (value) | 30 | if (value) |
31 | *value += 1; | 31 | *value += 1; |
diff --git a/samples/bpf/trace_event_kern.c b/samples/bpf/trace_event_kern.c index 71a8ed32823e..41b6115a32eb 100644 --- a/samples/bpf/trace_event_kern.c +++ b/samples/bpf/trace_event_kern.c | |||
@@ -50,7 +50,7 @@ int bpf_prog1(struct bpf_perf_event_data *ctx) | |||
50 | key.userstack = bpf_get_stackid(ctx, &stackmap, USER_STACKID_FLAGS); | 50 | key.userstack = bpf_get_stackid(ctx, &stackmap, USER_STACKID_FLAGS); |
51 | if ((int)key.kernstack < 0 && (int)key.userstack < 0) { | 51 | if ((int)key.kernstack < 0 && (int)key.userstack < 0) { |
52 | bpf_trace_printk(fmt, sizeof(fmt), cpu, ctx->sample_period, | 52 | bpf_trace_printk(fmt, sizeof(fmt), cpu, ctx->sample_period, |
53 | ctx->regs.ip); | 53 | PT_REGS_IP(&ctx->regs)); |
54 | return 0; | 54 | return 0; |
55 | } | 55 | } |
56 | 56 | ||