Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

caif: Use link layer MTU instead of fixed MTU

Previously CAIF supported maximum transfer size of ~4050.
The transfer size is now calculated dynamically based on the
link layers mtu size.

Signed-off-by: Sjur Braendeland@stericsson.com
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Sjur Braendeland and committed by
David S. Miller
2aa40aef a7da1f55

+173 -69
-1
drivers/net/caif/caif_serial.c
··· 403 403 dev->type = ARPHRD_CAIF; 404 404 dev->flags = IFF_POINTOPOINT | IFF_NOARP; 405 405 dev->mtu = CAIF_MAX_MTU; 406 - dev->hard_header_len = CAIF_NEEDED_HEADROOM; 407 406 dev->tx_queue_len = 0; 408 407 dev->destructor = free_netdev; 409 408 skb_queue_head_init(&serdev->head);
+6 -2
include/net/caif/caif_dev.h
··· 50 50 * @client_layer: User implementation of client layer. This layer 51 51 * MUST have receive and control callback functions 52 52 * implemented. 53 + * @ifindex: Link layer interface index used for this connection. 54 + * @headroom: Head room needed by CAIF protocol. 55 + * @tailroom: Tail room needed by CAIF protocol. 53 56 * 54 57 * This function connects a CAIF channel. The Client must implement 55 58 * the struct cflayer. This layer represents the Client layer and holds ··· 62 59 * E.g. CAIF Socket will call this function for each socket it connects 63 60 * and have one client_layer instance for each socket. 64 61 */ 65 - int caif_connect_client(struct caif_connect_request *config, 66 - struct cflayer *client_layer); 62 + int caif_connect_client(struct caif_connect_request *conn_req, 63 + struct cflayer *client_layer, int *ifindex, 64 + int *headroom, int *tailroom); 67 65 68 66 /** 69 67 * caif_disconnect_client - Disconnects a client from the CAIF stack.
-6
include/net/caif/caif_layer.h
··· 15 15 struct caif_payload_info; 16 16 struct caif_packet_funcs; 17 17 18 - #define CAIF_MAX_FRAMESIZE 4096 19 - #define CAIF_MAX_PAYLOAD_SIZE (4096 - 64) 20 - #define CAIF_NEEDED_HEADROOM (10) 21 - #define CAIF_NEEDED_TAILROOM (2) 22 18 23 19 #define CAIF_LAYER_NAME_SZ 16 24 - #define CAIF_SUCCESS 1 25 - #define CAIF_FAILURE 0 26 20 27 21 /** 28 22 * caif_assert() - Assert function for CAIF.
+12 -4
include/net/caif/cfcnfg.h
··· 7 7 #ifndef CFCNFG_H_ 8 8 #define CFCNFG_H_ 9 9 #include <linux/spinlock.h> 10 + #include <linux/netdevice.h> 10 11 #include <net/caif/caif_layer.h> 11 12 #include <net/caif/cfctrl.h> 12 13 ··· 74 73 75 74 void 76 75 cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type, 77 - void *dev, struct cflayer *phy_layer, u16 *phyid, 78 - enum cfcnfg_phy_preference pref, 76 + struct net_device *dev, struct cflayer *phy_layer, 77 + u16 *phyid, enum cfcnfg_phy_preference pref, 79 78 bool fcs, bool stx); 80 79 81 80 /** ··· 115 114 * @param: Link setup parameters. 116 115 * @adap_layer: Specify the adaptation layer; the receive and 117 116 * flow-control functions MUST be set in the structure. 118 - * 117 + * @ifindex: Link layer interface index used for this connection. 118 + * @proto_head: Protocol head-space needed by CAIF protocol, 119 + * excluding link layer. 120 + * @proto_tail: Protocol tail-space needed by CAIF protocol, 121 + * excluding link layer. 119 122 */ 120 123 int cfcnfg_add_adaptation_layer(struct cfcnfg *cnfg, 121 124 struct cfctrl_link_param *param, 122 - struct cflayer *adap_layer); 125 + struct cflayer *adap_layer, 126 + int *ifindex, 127 + int *proto_head, 128 + int *proto_tail); 123 129 124 130 /** 125 131 * cfcnfg_get_phyid() - Get physical ID, given type.
+8 -4
net/caif/caif_dev.c
··· 255 255 pref = CFPHYPREF_HIGH_BW; 256 256 break; 257 257 } 258 - 258 + dev_hold(dev); 259 259 cfcnfg_add_phy_layer(get_caif_conf(), 260 260 phy_type, 261 261 dev, ··· 285 285 caifd->layer.up->ctrlcmd(caifd->layer.up, 286 286 _CAIF_CTRLCMD_PHYIF_DOWN_IND, 287 287 caifd->layer.id); 288 + might_sleep(); 288 289 res = wait_event_interruptible_timeout(caifd->event, 289 290 atomic_read(&caifd->in_use) == 0, 290 291 TIMEOUT); ··· 301 300 "Unregistering an active CAIF device: %s\n", 302 301 __func__, dev->name); 303 302 cfcnfg_del_phy_layer(get_caif_conf(), &caifd->layer); 303 + dev_put(dev); 304 304 atomic_set(&caifd->state, what); 305 305 break; 306 306 ··· 328 326 EXPORT_SYMBOL(get_caif_conf); 329 327 330 328 int caif_connect_client(struct caif_connect_request *conn_req, 331 - struct cflayer *client_layer) 329 + struct cflayer *client_layer, int *ifindex, 330 + int *headroom, int *tailroom) 332 331 { 333 332 struct cfctrl_link_param param; 334 333 int ret; ··· 337 334 if (ret) 338 335 return ret; 339 336 /* Hook up the adaptation layer. */ 340 - return cfcnfg_add_adaptation_layer(get_caif_conf(), 341 - &param, client_layer); 337 + return cfcnfg_add_adaptation_layer(get_caif_conf(), &param, 338 + client_layer, ifindex, 339 + headroom, tailroom); 342 340 } 343 341 EXPORT_SYMBOL(caif_connect_client); 344 342
+36 -18
net/caif/caif_socket.c
··· 28 28 MODULE_LICENSE("GPL"); 29 29 MODULE_ALIAS_NETPROTO(AF_CAIF); 30 30 31 - #define CAIF_DEF_SNDBUF (CAIF_MAX_PAYLOAD_SIZE*10) 32 - #define CAIF_DEF_RCVBUF (CAIF_MAX_PAYLOAD_SIZE*100) 31 + #define CAIF_DEF_SNDBUF (4096*10) 32 + #define CAIF_DEF_RCVBUF (4096*100) 33 33 34 34 /* 35 35 * CAIF state is re-using the TCP socket states. ··· 76 76 struct caif_connect_request conn_req; 77 77 struct mutex readlock; 78 78 struct dentry *debugfs_socket_dir; 79 + int headroom, tailroom, maxframe; 79 80 }; 80 81 81 82 static int rx_flow_is_on(struct caifsock *cf_sk) ··· 595 594 goto err; 596 595 noblock = msg->msg_flags & MSG_DONTWAIT; 597 596 598 - buffer_size = len + CAIF_NEEDED_HEADROOM + CAIF_NEEDED_TAILROOM; 599 - 600 597 timeo = sock_sndtimeo(sk, noblock); 601 598 timeo = caif_wait_for_flow_on(container_of(sk, struct caifsock, sk), 602 599 1, timeo, &ret); 603 600 601 + if (ret) 602 + goto err; 604 603 ret = -EPIPE; 605 604 if (cf_sk->sk.sk_state != CAIF_CONNECTED || 606 605 sock_flag(sk, SOCK_DEAD) || 607 606 (sk->sk_shutdown & RCV_SHUTDOWN)) 608 607 goto err; 609 608 609 + /* Error if trying to write more than maximum frame size. */ 610 + ret = -EMSGSIZE; 611 + if (len > cf_sk->maxframe && cf_sk->sk.sk_protocol != CAIFPROTO_RFM) 612 + goto err; 613 + 614 + buffer_size = len + cf_sk->headroom + cf_sk->tailroom; 615 + 610 616 ret = -ENOMEM; 611 617 skb = sock_alloc_send_skb(sk, buffer_size, noblock, &ret); 612 - if (!skb) 618 + 619 + if (!skb || skb_tailroom(skb) < buffer_size) 613 620 goto err; 614 - skb_reserve(skb, CAIF_NEEDED_HEADROOM); 621 + 622 + skb_reserve(skb, cf_sk->headroom); 615 623 616 624 ret = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len); 617 625 ··· 651 641 long timeo; 652 642 653 643 err = -EOPNOTSUPP; 654 - 655 644 if (unlikely(msg->msg_flags&MSG_OOB)) 656 645 goto out_err; 657 646 ··· 667 658 668 659 size = len-sent; 669 660 670 - if (size > CAIF_MAX_PAYLOAD_SIZE) 671 - size = CAIF_MAX_PAYLOAD_SIZE; 661 + if (size > cf_sk->maxframe) 662 + size = cf_sk->maxframe; 672 663 673 664 /* If size is more than half of sndbuf, chop up message */ 674 665 if (size > ((sk->sk_sndbuf >> 1) - 64)) ··· 678 669 size = SKB_MAX_ALLOC; 679 670 680 671 skb = sock_alloc_send_skb(sk, 681 - size + CAIF_NEEDED_HEADROOM 682 - + CAIF_NEEDED_TAILROOM, 672 + size + cf_sk->headroom + 673 + cf_sk->tailroom, 683 674 msg->msg_flags&MSG_DONTWAIT, 684 675 &err); 685 676 if (skb == NULL) 686 677 goto out_err; 687 678 688 - skb_reserve(skb, CAIF_NEEDED_HEADROOM); 679 + skb_reserve(skb, cf_sk->headroom); 689 680 /* 690 681 * If you pass two values to the sock_alloc_send_skb 691 682 * it tries to grab the large buffer with GFP_NOFS ··· 826 817 struct caifsock *cf_sk = container_of(sk, struct caifsock, sk); 827 818 long timeo; 828 819 int err; 820 + int ifindex, headroom, tailroom; 821 + struct net_device *dev; 822 + 829 823 lock_sock(sk); 830 824 831 825 err = -EAFNOSUPPORT; 832 826 if (uaddr->sa_family != AF_CAIF) 833 827 goto out; 834 828 835 - err = -ESOCKTNOSUPPORT; 836 - if (unlikely(!(sk->sk_type == SOCK_STREAM && 837 - cf_sk->sk.sk_protocol == CAIFPROTO_AT) && 838 - sk->sk_type != SOCK_SEQPACKET)) 839 - goto out; 840 829 switch (sock->state) { 841 830 case SS_UNCONNECTED: 842 831 /* Normal case, a fresh connect */ ··· 890 883 dbfs_atomic_inc(&cnt.num_connect_req); 891 884 cf_sk->layer.receive = caif_sktrecv_cb; 892 885 err = caif_connect_client(&cf_sk->conn_req, 893 - &cf_sk->layer); 886 + &cf_sk->layer, &ifindex, &headroom, &tailroom); 894 887 if (err < 0) { 895 888 cf_sk->sk.sk_socket->state = SS_UNCONNECTED; 896 889 cf_sk->sk.sk_state = CAIF_DISCONNECTED; 890 + goto out; 891 + } 892 + dev = dev_get_by_index(sock_net(sk), ifindex); 893 + cf_sk->headroom = LL_RESERVED_SPACE_EXTRA(dev, headroom); 894 + cf_sk->tailroom = tailroom; 895 + cf_sk->maxframe = dev->mtu - (headroom + tailroom); 896 + dev_put(dev); 897 + if (cf_sk->maxframe < 1) { 898 + pr_warning("CAIF: %s(): CAIF Interface MTU too small (%d)\n", 899 + __func__, dev->mtu); 900 + err = -ENODEV; 897 901 goto out; 898 902 } 899 903
+40 -4
net/caif/cfcnfg.c
··· 6 6 #include <linux/kernel.h> 7 7 #include <linux/stddef.h> 8 8 #include <linux/slab.h> 9 + #include <linux/netdevice.h> 9 10 #include <net/caif/caif_layer.h> 10 11 #include <net/caif/cfpkt.h> 11 12 #include <net/caif/cfcnfg.h> ··· 43 42 44 43 /* Information about the physical device */ 45 44 struct dev_info dev_info; 45 + 46 + /* Interface index */ 47 + int ifindex; 48 + 49 + /* Use Start of frame extension */ 50 + bool use_stx; 51 + 52 + /* Use Start of frame checksum */ 53 + bool use_fcs; 46 54 }; 47 55 48 56 struct cfcnfg { ··· 259 249 { 260 250 } 261 251 252 + int protohead[CFCTRL_SRV_MASK] = { 253 + [CFCTRL_SRV_VEI] = 4, 254 + [CFCTRL_SRV_DATAGRAM] = 7, 255 + [CFCTRL_SRV_UTIL] = 4, 256 + [CFCTRL_SRV_RFM] = 3, 257 + [CFCTRL_SRV_DBG] = 3, 258 + }; 259 + 262 260 int cfcnfg_add_adaptation_layer(struct cfcnfg *cnfg, 263 261 struct cfctrl_link_param *param, 264 - struct cflayer *adap_layer) 262 + struct cflayer *adap_layer, 263 + int *ifindex, 264 + int *proto_head, 265 + int *proto_tail) 265 266 { 266 267 struct cflayer *frml; 267 268 if (adap_layer == NULL) { ··· 298 277 param->phyid); 299 278 caif_assert(cnfg->phy_layers[param->phyid].phy_layer->id == 300 279 param->phyid); 280 + 281 + *ifindex = cnfg->phy_layers[param->phyid].ifindex; 282 + *proto_head = 283 + protohead[param->linktype]+ 284 + (cnfg->phy_layers[param->phyid].use_stx ? 1 : 0); 285 + 286 + *proto_tail = 2; 287 + 301 288 /* FIXME: ENUMERATE INITIALLY WHEN ACTIVATING PHYSICAL INTERFACE */ 302 289 cfctrl_enum_req(cnfg->ctrl, param->phyid); 303 290 return cfctrl_linkup_request(cnfg->ctrl, param, adap_layer); ··· 327 298 struct cfcnfg *cnfg = container_obj(layer); 328 299 struct cflayer *servicel = NULL; 329 300 struct cfcnfg_phyinfo *phyinfo; 301 + struct net_device *netdev; 302 + 330 303 if (adapt_layer == NULL) { 331 304 pr_debug("CAIF: %s(): link setup response " 332 305 "but no client exist, send linkdown back\n", ··· 360 329 servicel = cfdgml_create(channel_id, &phyinfo->dev_info); 361 330 break; 362 331 case CFCTRL_SRV_RFM: 332 + netdev = phyinfo->dev_info.dev; 363 333 servicel = cfrfml_create(channel_id, &phyinfo->dev_info, 364 - RFM_FRAGMENT_SIZE); 334 + netdev->mtu); 365 335 break; 366 336 case CFCTRL_SRV_UTIL: 367 337 servicel = cfutill_create(channel_id, &phyinfo->dev_info); ··· 393 361 394 362 void 395 363 cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type, 396 - void *dev, struct cflayer *phy_layer, u16 *phyid, 397 - enum cfcnfg_phy_preference pref, 364 + struct net_device *dev, struct cflayer *phy_layer, 365 + u16 *phyid, enum cfcnfg_phy_preference pref, 398 366 bool fcs, bool stx) 399 367 { 400 368 struct cflayer *frml; ··· 448 416 cnfg->phy_layers[*phyid].dev_info.dev = dev; 449 417 cnfg->phy_layers[*phyid].phy_layer = phy_layer; 450 418 cnfg->phy_layers[*phyid].phy_ref_count = 0; 419 + cnfg->phy_layers[*phyid].ifindex = dev->ifindex; 420 + cnfg->phy_layers[*phyid].use_stx = stx; 421 + cnfg->phy_layers[*phyid].use_fcs = fcs; 422 + 451 423 phy_layer->type = phy_type; 452 424 frml = cffrml_create(*phyid, fcs); 453 425 if (!frml) {
+3 -3
net/caif/cfctrl.c
··· 19 19 #ifdef CAIF_NO_LOOP 20 20 static int handle_loop(struct cfctrl *ctrl, 21 21 int cmd, struct cfpkt *pkt){ 22 - return CAIF_FAILURE; 22 + return -1; 23 23 } 24 24 #else 25 25 static int handle_loop(struct cfctrl *ctrl, ··· 395 395 cmd = cmdrsp & CFCTRL_CMD_MASK; 396 396 if (cmd != CFCTRL_CMD_LINK_ERR 397 397 && CFCTRL_RSP_BIT != (CFCTRL_RSP_BIT & cmdrsp)) { 398 - if (handle_loop(cfctrl, cmd, pkt) == CAIF_FAILURE) 398 + if (handle_loop(cfctrl, cmd, pkt) != 0) 399 399 cmdrsp |= CFCTRL_ERR_BIT; 400 400 } 401 401 ··· 647 647 default: 648 648 break; 649 649 } 650 - return CAIF_SUCCESS; 650 + return 0; 651 651 } 652 652 #endif
+5
net/caif/cfdgml.c
··· 17 17 #define DGM_FLOW_OFF 0x81 18 18 #define DGM_FLOW_ON 0x80 19 19 #define DGM_CTRL_PKT_SIZE 1 20 + #define DGM_MTU 1500 20 21 21 22 static int cfdgml_receive(struct cflayer *layr, struct cfpkt *pkt); 22 23 static int cfdgml_transmit(struct cflayer *layr, struct cfpkt *pkt); ··· 89 88 int ret; 90 89 if (!cfsrvl_ready(service, &ret)) 91 90 return ret; 91 + 92 + /* STE Modem cannot handle more than 1500 bytes datagrams */ 93 + if (cfpkt_getlen(pkt) > DGM_MTU) 94 + return -EMSGSIZE; 92 95 93 96 cfpkt_add_head(pkt, &zero, 4); 94 97
+2 -2
net/caif/cfpkt_skbuff.c
··· 9 9 #include <linux/hardirq.h> 10 10 #include <net/caif/cfpkt.h> 11 11 12 - #define PKT_PREFIX CAIF_NEEDED_HEADROOM 13 - #define PKT_POSTFIX CAIF_NEEDED_TAILROOM 12 + #define PKT_PREFIX 16 13 + #define PKT_POSTFIX 2 14 14 #define PKT_LEN_WHEN_EXTENDING 128 15 15 #define PKT_ERROR(pkt, errmsg) do { \ 16 16 cfpkt_priv(pkt)->erronous = true; \
+4 -3
net/caif/cfserl.c
··· 14 14 #define container_obj(layr) ((struct cfserl *) layr) 15 15 16 16 #define CFSERL_STX 0x02 17 - #define CAIF_MINIUM_PACKET_SIZE 4 17 + #define SERIAL_MINIUM_PACKET_SIZE 4 18 + #define SERIAL_MAX_FRAMESIZE 4096 18 19 struct cfserl { 19 20 struct cflayer layer; 20 21 struct cfpkt *incomplete_frm; ··· 120 119 /* 121 120 * Frame error handling 122 121 */ 123 - if (expectlen < CAIF_MINIUM_PACKET_SIZE 124 - || expectlen > CAIF_MAX_FRAMESIZE) { 122 + if (expectlen < SERIAL_MINIUM_PACKET_SIZE 123 + || expectlen > SERIAL_MAX_FRAMESIZE) { 125 124 if (!layr->usestx) { 126 125 if (pkt != NULL) 127 126 cfpkt_destroy(pkt);
-1
net/caif/cfsrvl.c
··· 162 162 void cfsrvl_release(struct kref *kref) 163 163 { 164 164 struct cfsrvl *service = container_of(kref, struct cfsrvl, ref); 165 - pr_info("CAIF: %s(): enter\n", __func__); 166 165 kfree(service); 167 166 } 168 167
-6
net/caif/cfutill.c
··· 90 90 if (!cfsrvl_ready(service, &ret)) 91 91 return ret; 92 92 93 - if (cfpkt_getlen(pkt) > CAIF_MAX_PAYLOAD_SIZE) { 94 - pr_err("CAIF: %s(): packet too large size=%d\n", 95 - __func__, cfpkt_getlen(pkt)); 96 - return -EOVERFLOW; 97 - } 98 - 99 93 cfpkt_add_head(pkt, &zero, 1); 100 94 /* Add info for MUX-layer to route the packet out. */ 101 95 info = cfpkt_info(pkt);
-5
net/caif/cfveil.c
··· 84 84 return ret; 85 85 caif_assert(layr->dn != NULL); 86 86 caif_assert(layr->dn->transmit != NULL); 87 - if (cfpkt_getlen(pkt) > CAIF_MAX_PAYLOAD_SIZE) { 88 - pr_warning("CAIF: %s(): Packet too large - size=%d\n", 89 - __func__, cfpkt_getlen(pkt)); 90 - return -EOVERFLOW; 91 - } 92 87 93 88 if (cfpkt_add_head(pkt, &tmp, 1) < 0) { 94 89 pr_err("CAIF: %s(): Packet is erroneous!\n", __func__);
+57 -10
net/caif/chnl_net.c
··· 23 23 #include <net/caif/caif_dev.h> 24 24 25 25 /* GPRS PDP connection has MTU to 1500 */ 26 - #define SIZE_MTU 1500 26 + #define GPRS_PDP_MTU 1500 27 27 /* 5 sec. connect timeout */ 28 28 #define CONNECT_TIMEOUT (5 * HZ) 29 29 #define CAIF_NET_DEFAULT_QUEUE_LEN 500 ··· 232 232 { 233 233 struct chnl_net *priv = NULL; 234 234 int result = -1; 235 + int llifindex, headroom, tailroom, mtu; 236 + struct net_device *lldev; 235 237 ASSERT_RTNL(); 236 238 priv = netdev_priv(dev); 237 239 if (!priv) { ··· 243 241 244 242 if (priv->state != CAIF_CONNECTING) { 245 243 priv->state = CAIF_CONNECTING; 246 - result = caif_connect_client(&priv->conn_req, &priv->chnl); 244 + result = caif_connect_client(&priv->conn_req, &priv->chnl, 245 + &llifindex, &headroom, &tailroom); 247 246 if (result != 0) { 248 - priv->state = CAIF_DISCONNECTED; 249 247 pr_debug("CAIF: %s(): err: " 250 248 "Unable to register and open device," 251 249 " Err:%d\n", 252 250 __func__, 253 251 result); 254 - return result; 252 + goto error; 253 + } 254 + 255 + lldev = dev_get_by_index(dev_net(dev), llifindex); 256 + 257 + if (lldev == NULL) { 258 + pr_debug("CAIF: %s(): no interface?\n", __func__); 259 + result = -ENODEV; 260 + goto error; 261 + } 262 + 263 + dev->needed_tailroom = tailroom + lldev->needed_tailroom; 264 + dev->hard_header_len = headroom + lldev->hard_header_len + 265 + lldev->needed_tailroom; 266 + 267 + /* 268 + * MTU, head-room etc is not know before we have a 269 + * CAIF link layer device available. MTU calculation may 270 + * override initial RTNL configuration. 271 + * MTU is minimum of current mtu, link layer mtu pluss 272 + * CAIF head and tail, and PDP GPRS contexts max MTU. 273 + */ 274 + mtu = min_t(int, dev->mtu, lldev->mtu - (headroom + tailroom)); 275 + mtu = min_t(int, GPRS_PDP_MTU, mtu); 276 + dev_set_mtu(dev, mtu); 277 + dev_put(lldev); 278 + 279 + if (mtu < 100) { 280 + pr_warning("CAIF: %s(): " 281 + "CAIF Interface MTU too small (%d)\n", 282 + __func__, mtu); 283 + result = -ENODEV; 284 + goto error; 255 285 } 256 286 } 287 + 288 + rtnl_unlock(); /* Release RTNL lock during connect wait */ 257 289 258 290 result = wait_event_interruptible_timeout(priv->netmgmt_wq, 259 291 priv->state != CAIF_CONNECTING, 260 292 CONNECT_TIMEOUT); 261 293 294 + rtnl_lock(); 295 + 262 296 if (result == -ERESTARTSYS) { 263 297 pr_debug("CAIF: %s(): wait_event_interruptible" 264 298 " woken by a signal\n", __func__); 265 - return -ERESTARTSYS; 299 + result = -ERESTARTSYS; 300 + goto error; 266 301 } 302 + 267 303 if (result == 0) { 268 304 pr_debug("CAIF: %s(): connect timeout\n", __func__); 269 305 caif_disconnect_client(&priv->chnl); 270 306 priv->state = CAIF_DISCONNECTED; 271 307 pr_debug("CAIF: %s(): state disconnected\n", __func__); 272 - return -ETIMEDOUT; 308 + result = -ETIMEDOUT; 309 + goto error; 273 310 } 274 311 275 312 if (priv->state != CAIF_CONNECTED) { 276 313 pr_debug("CAIF: %s(): connect failed\n", __func__); 277 - return -ECONNREFUSED; 314 + result = -ECONNREFUSED; 315 + goto error; 278 316 } 279 317 pr_debug("CAIF: %s(): CAIF Netdevice connected\n", __func__); 280 318 return 0; 319 + 320 + error: 321 + caif_disconnect_client(&priv->chnl); 322 + priv->state = CAIF_DISCONNECTED; 323 + pr_debug("CAIF: %s(): state disconnected\n", __func__); 324 + return result; 325 + 281 326 } 282 327 283 328 static int chnl_net_stop(struct net_device *dev) ··· 370 321 dev->destructor = free_netdev; 371 322 dev->flags |= IFF_NOARP; 372 323 dev->flags |= IFF_POINTOPOINT; 373 - dev->needed_headroom = CAIF_NEEDED_HEADROOM; 374 - dev->needed_tailroom = CAIF_NEEDED_TAILROOM; 375 - dev->mtu = SIZE_MTU; 324 + dev->mtu = GPRS_PDP_MTU; 376 325 dev->tx_queue_len = CAIF_NET_DEFAULT_QUEUE_LEN; 377 326 378 327 priv = netdev_priv(dev);