diff options
Diffstat (limited to 'net/packet/af_packet.c')
-rw-r--r-- | net/packet/af_packet.c | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 0f661745df0f..ceaca7c134a0 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -531,6 +531,7 @@ static int prb_calc_retire_blk_tmo(struct packet_sock *po, | |||
531 | unsigned int mbits = 0, msec = 0, div = 0, tmo = 0; | 531 | unsigned int mbits = 0, msec = 0, div = 0, tmo = 0; |
532 | struct ethtool_cmd ecmd; | 532 | struct ethtool_cmd ecmd; |
533 | int err; | 533 | int err; |
534 | u32 speed; | ||
534 | 535 | ||
535 | rtnl_lock(); | 536 | rtnl_lock(); |
536 | dev = __dev_get_by_index(sock_net(&po->sk), po->ifindex); | 537 | dev = __dev_get_by_index(sock_net(&po->sk), po->ifindex); |
@@ -539,25 +540,18 @@ static int prb_calc_retire_blk_tmo(struct packet_sock *po, | |||
539 | return DEFAULT_PRB_RETIRE_TOV; | 540 | return DEFAULT_PRB_RETIRE_TOV; |
540 | } | 541 | } |
541 | err = __ethtool_get_settings(dev, &ecmd); | 542 | err = __ethtool_get_settings(dev, &ecmd); |
543 | speed = ethtool_cmd_speed(&ecmd); | ||
542 | rtnl_unlock(); | 544 | rtnl_unlock(); |
543 | if (!err) { | 545 | if (!err) { |
544 | switch (ecmd.speed) { | ||
545 | case SPEED_10000: | ||
546 | msec = 1; | ||
547 | div = 10000/1000; | ||
548 | break; | ||
549 | case SPEED_1000: | ||
550 | msec = 1; | ||
551 | div = 1000/1000; | ||
552 | break; | ||
553 | /* | 546 | /* |
554 | * If the link speed is so slow you don't really | 547 | * If the link speed is so slow you don't really |
555 | * need to worry about perf anyways | 548 | * need to worry about perf anyways |
556 | */ | 549 | */ |
557 | case SPEED_100: | 550 | if (speed < SPEED_1000 || speed == SPEED_UNKNOWN) { |
558 | case SPEED_10: | ||
559 | default: | ||
560 | return DEFAULT_PRB_RETIRE_TOV; | 551 | return DEFAULT_PRB_RETIRE_TOV; |
552 | } else { | ||
553 | msec = 1; | ||
554 | div = speed / 1000; | ||
561 | } | 555 | } |
562 | } | 556 | } |
563 | 557 | ||
@@ -592,7 +586,7 @@ static void init_prb_bdqc(struct packet_sock *po, | |||
592 | p1->knxt_seq_num = 1; | 586 | p1->knxt_seq_num = 1; |
593 | p1->pkbdq = pg_vec; | 587 | p1->pkbdq = pg_vec; |
594 | pbd = (struct tpacket_block_desc *)pg_vec[0].buffer; | 588 | pbd = (struct tpacket_block_desc *)pg_vec[0].buffer; |
595 | p1->pkblk_start = (char *)pg_vec[0].buffer; | 589 | p1->pkblk_start = pg_vec[0].buffer; |
596 | p1->kblk_size = req_u->req3.tp_block_size; | 590 | p1->kblk_size = req_u->req3.tp_block_size; |
597 | p1->knum_blocks = req_u->req3.tp_block_nr; | 591 | p1->knum_blocks = req_u->req3.tp_block_nr; |
598 | p1->hdrlen = po->tp_hdrlen; | 592 | p1->hdrlen = po->tp_hdrlen; |
@@ -824,8 +818,7 @@ static void prb_open_block(struct tpacket_kbdq_core *pkc1, | |||
824 | h1->ts_first_pkt.ts_sec = ts.tv_sec; | 818 | h1->ts_first_pkt.ts_sec = ts.tv_sec; |
825 | h1->ts_first_pkt.ts_nsec = ts.tv_nsec; | 819 | h1->ts_first_pkt.ts_nsec = ts.tv_nsec; |
826 | pkc1->pkblk_start = (char *)pbd1; | 820 | pkc1->pkblk_start = (char *)pbd1; |
827 | pkc1->nxt_offset = (char *)(pkc1->pkblk_start + | 821 | pkc1->nxt_offset = pkc1->pkblk_start + BLK_PLUS_PRIV(pkc1->blk_sizeof_priv); |
828 | BLK_PLUS_PRIV(pkc1->blk_sizeof_priv)); | ||
829 | BLOCK_O2FP(pbd1) = (__u32)BLK_PLUS_PRIV(pkc1->blk_sizeof_priv); | 822 | BLOCK_O2FP(pbd1) = (__u32)BLK_PLUS_PRIV(pkc1->blk_sizeof_priv); |
830 | BLOCK_O2PRIV(pbd1) = BLK_HDR_LEN; | 823 | BLOCK_O2PRIV(pbd1) = BLK_HDR_LEN; |
831 | pbd1->version = pkc1->version; | 824 | pbd1->version = pkc1->version; |
@@ -1018,7 +1011,7 @@ static void *__packet_lookup_frame_in_block(struct packet_sock *po, | |||
1018 | struct tpacket_block_desc *pbd; | 1011 | struct tpacket_block_desc *pbd; |
1019 | char *curr, *end; | 1012 | char *curr, *end; |
1020 | 1013 | ||
1021 | pkc = GET_PBDQC_FROM_RB(((struct packet_ring_buffer *)&po->rx_ring)); | 1014 | pkc = GET_PBDQC_FROM_RB(&po->rx_ring); |
1022 | pbd = GET_CURR_PBLOCK_DESC_FROM_CORE(pkc); | 1015 | pbd = GET_CURR_PBLOCK_DESC_FROM_CORE(pkc); |
1023 | 1016 | ||
1024 | /* Queue is frozen when user space is lagging behind */ | 1017 | /* Queue is frozen when user space is lagging behind */ |
@@ -1044,7 +1037,7 @@ static void *__packet_lookup_frame_in_block(struct packet_sock *po, | |||
1044 | smp_mb(); | 1037 | smp_mb(); |
1045 | curr = pkc->nxt_offset; | 1038 | curr = pkc->nxt_offset; |
1046 | pkc->skb = skb; | 1039 | pkc->skb = skb; |
1047 | end = (char *) ((char *)pbd + pkc->kblk_size); | 1040 | end = (char *)pbd + pkc->kblk_size; |
1048 | 1041 | ||
1049 | /* first try the current block */ | 1042 | /* first try the current block */ |
1050 | if (curr+TOTAL_PKT_LEN_INCL_ALIGN(len) < end) { | 1043 | if (curr+TOTAL_PKT_LEN_INCL_ALIGN(len) < end) { |
@@ -1476,7 +1469,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock, | |||
1476 | * Find the device first to size check it | 1469 | * Find the device first to size check it |
1477 | */ | 1470 | */ |
1478 | 1471 | ||
1479 | saddr->spkt_device[13] = 0; | 1472 | saddr->spkt_device[sizeof(saddr->spkt_device) - 1] = 0; |
1480 | retry: | 1473 | retry: |
1481 | rcu_read_lock(); | 1474 | rcu_read_lock(); |
1482 | dev = dev_get_by_name_rcu(sock_net(sk), saddr->spkt_device); | 1475 | dev = dev_get_by_name_rcu(sock_net(sk), saddr->spkt_device); |