svn commit: r351626 - head/sys/netgraph/bluetooth/socket

2019-08-30 Thread Maksim Yevmenkin
Author: emax
Date: Fri Aug 30 16:35:31 2019
New Revision: 351626
URL: https://svnweb.freebsd.org/changeset/base/351626

Log:
  avoid holding PCB mutex during copyin/copyout()
  
  Reported by:  imp, mms dot vanbreukelingen at gmail dot com
  Reviewed by:  imp

Modified:
  head/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c
  head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c

Modified: head/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c
==
--- head/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.cFri Aug 30 
16:30:09 2019(r351625)
+++ head/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.cFri Aug 30 
16:35:31 2019(r351626)
@@ -1156,15 +1156,15 @@ ng_btsocket_hci_raw_control(struct socket *so, u_long 
if (p->num_entries <= 0 || 
p->num_entries > NG_HCI_MAX_NEIGHBOR_NUM ||
p->entries == NULL) {
-   error = EINVAL;
-   break;
+   mtx_unlock(>pcb_mtx);
+   return (EINVAL);
}
 
NG_MKMESSAGE(msg, NGM_HCI_COOKIE,
NGM_HCI_NODE_GET_NEIGHBOR_CACHE, 0, M_NOWAIT);
if (msg == NULL) {
-   error = ENOMEM;
-   break;
+   mtx_unlock(>pcb_mtx);
+   return (ENOMEM);
}
ng_btsocket_hci_raw_get_token(>header.token);
pcb->token = msg->header.token;
@@ -1173,7 +1173,8 @@ ng_btsocket_hci_raw_control(struct socket *so, u_long 
NG_SEND_MSG_PATH(error, ng_btsocket_hci_raw_node, msg, path, 0);
if (error != 0) {
pcb->token = 0;
-   break;
+   mtx_unlock(>pcb_mtx);
+   return (error);
}
 
error = msleep(>msg, >pcb_mtx,
@@ -1181,16 +1182,21 @@ ng_btsocket_hci_raw_control(struct socket *so, u_long 
ng_btsocket_hci_raw_ioctl_timeout * hz);
pcb->token = 0;
 
-   if (error != 0)
-   break;
+   if (error != 0) {
+   mtx_unlock(>pcb_mtx);
+   return (error);
+   }
 
-   if (pcb->msg != NULL &&
-   pcb->msg->header.cmd == NGM_HCI_NODE_GET_NEIGHBOR_CACHE) {
+   msg = pcb->msg;
+   pcb->msg = NULL;
+
+   mtx_unlock(>pcb_mtx);
+   
+   if (msg != NULL &&
+   msg->header.cmd == NGM_HCI_NODE_GET_NEIGHBOR_CACHE) {
/* Return data back to user space */
-   p1 = (ng_hci_node_get_neighbor_cache_ep *)
-   (pcb->msg->data);
-   p2 = (ng_hci_node_neighbor_cache_entry_ep *)
-   (p1 + 1);
+   p1 = (ng_hci_node_get_neighbor_cache_ep *)(msg->data);
+   p2 = (ng_hci_node_neighbor_cache_entry_ep *)(p1 + 1);
 
p->num_entries = min(p->num_entries, p1->num_entries);
if (p->num_entries > 0)
@@ -1200,8 +1206,9 @@ ng_btsocket_hci_raw_control(struct socket *so, u_long 
} else
error = EINVAL;
 
-   NG_FREE_MSG(pcb->msg); /* checks for != NULL */
-   }break;
+   NG_FREE_MSG(msg); /* checks for != NULL */
+   return (error);
+   } /* NOTREACHED */
 
case SIOC_HCI_RAW_NODE_GET_CON_LIST: {
struct ng_btsocket_hci_raw_con_list *p = 
@@ -1212,15 +1219,15 @@ ng_btsocket_hci_raw_control(struct socket *so, u_long 
if (p->num_connections == 0 ||
p->num_connections > NG_HCI_MAX_CON_NUM ||
p->connections == NULL) {
-   error = EINVAL;
-   break;
+   mtx_unlock(>pcb_mtx);
+   return (EINVAL);
}
 
NG_MKMESSAGE(msg, NGM_HCI_COOKIE, NGM_HCI_NODE_GET_CON_LIST,
0, M_NOWAIT);
if (msg == NULL) {
-   error = ENOMEM;
-   break;
+   mtx_unlock(>pcb_mtx);
+   return (ENOMEM);
}
ng_btsocket_hci_raw_get_token(>header.token);
pcb->token = msg->header.token;
@@ -1229,7 +1236,8 @@ ng_btsocket_hci_raw_control(struct socket *so, u_long 
NG_SEND_MSG_PATH(error, ng_btsocket_hci_raw_node, msg, path, 0);
if (error != 0) {
pcb->token = 0;
-   break;
+   mtx_unlock(>pcb_mtx);
+   return (error);
   

svn commit: r321890 - head/usr.bin/calendar/calendars

2017-08-01 Thread Maksim Yevmenkin
Author: emax
Date: Tue Aug  1 18:48:09 2017
New Revision: 321890
URL: https://svnweb.freebsd.org/changeset/base/321890

Log:
  fix sort order

Modified:
  head/usr.bin/calendar/calendars/calendar.freebsd

Modified: head/usr.bin/calendar/calendars/calendar.freebsd
==
--- head/usr.bin/calendar/calendars/calendar.freebsdTue Aug  1 18:46:24 
2017(r321889)
+++ head/usr.bin/calendar/calendars/calendar.freebsdTue Aug  1 18:48:09 
2017(r321890)
@@ -326,9 +326,9 @@
 09/12  Benedict Christopher Reuschling <b...@freebsd.org> born in Darmstadt, 
Germany, 1981
 09/12  William C. Fumerola II <bi...@freebsd.org> born in Detroit, Michigan, 
United States, 1981
 09/14  Matthew Seaman <matt...@freebsd.org> born in Bristol, United Kingdom, 
1965
-09/16  Maksim Yevmenkin <e...@freebsd.org> born in Taganrog, USSR, 1974
 09/15  Aleksandr Rybalko <r...@freebsd.org> born in Odessa, Ukraine, 1977
 09/15  Dima Panov <flu...@freebsd.org> born in Khabarovsk, Russian Federation, 
1978
+09/16  Maksim Yevmenkin <e...@freebsd.org> born in Taganrog, USSR, 1974
 09/17  Maxim Bolotin <m...@freebsd.org> born in Rostov-on-Don, Russian 
Federation, 1976
 09/18  Matthew Fleming <m...@freebsd.org> born in Cleveland, Ohio, United 
States, 1975
 09/20  Kevin Lo <ke...@freebsd.org> born in Taipei, Taiwan, Republic of China, 
1972
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r321889 - head/usr.bin/calendar/calendars

2017-08-01 Thread Maksim Yevmenkin
Author: emax
Date: Tue Aug  1 18:46:24 2017
New Revision: 321889
URL: https://svnweb.freebsd.org/changeset/base/321889

Log:
  add myself
  
  Requested by: mckusick

Modified:
  head/usr.bin/calendar/calendars/calendar.freebsd

Modified: head/usr.bin/calendar/calendars/calendar.freebsd
==
--- head/usr.bin/calendar/calendars/calendar.freebsdTue Aug  1 18:33:27 
2017(r321888)
+++ head/usr.bin/calendar/calendars/calendar.freebsdTue Aug  1 18:46:24 
2017(r321889)
@@ -326,6 +326,7 @@
 09/12  Benedict Christopher Reuschling <b...@freebsd.org> born in Darmstadt, 
Germany, 1981
 09/12  William C. Fumerola II <bi...@freebsd.org> born in Detroit, Michigan, 
United States, 1981
 09/14  Matthew Seaman <matt...@freebsd.org> born in Bristol, United Kingdom, 
1965
+09/16  Maksim Yevmenkin <e...@freebsd.org> born in Taganrog, USSR, 1974
 09/15  Aleksandr Rybalko <r...@freebsd.org> born in Odessa, Ukraine, 1977
 09/15  Dima Panov <flu...@freebsd.org> born in Khabarovsk, Russian Federation, 
1978
 09/17  Maxim Bolotin <m...@freebsd.org> born in Rostov-on-Don, Russian 
Federation, 1976
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r297217 - head/usr.sbin/bluetooth/bthidd

2016-03-23 Thread Maksim Yevmenkin
Author: emax
Date: Wed Mar 23 22:07:13 2016
New Revision: 297217
URL: https://svnweb.freebsd.org/changeset/base/297217

Log:
  fix incorrect usage of hid_set_data() which causes crash
  in bthidd(8) on amd64 WITH_SSP builds
  
  Submitted by: rakuco
  Reviewed by:  rakuco
  Tested by:rakuco
  MFC after:1 week

Modified:
  head/usr.sbin/bluetooth/bthidd/kbd.c

Modified: head/usr.sbin/bluetooth/bthidd/kbd.c
==
--- head/usr.sbin/bluetooth/bthidd/kbd.cWed Mar 23 20:21:51 2016
(r297216)
+++ head/usr.sbin/bluetooth/bthidd/kbd.cWed Mar 23 22:07:13 2016
(r297217)
@@ -514,7 +514,7 @@ int32_t
 kbd_status_changed(bthid_session_p s, uint8_t *data, int32_t len)
 {
vkbd_status_t   st;
-   uint8_t leds, report_id;
+   uint8_t found, report_id;
hid_device_phid_device;
hid_data_t  d;
hid_item_t  h;
@@ -523,15 +523,21 @@ kbd_status_changed(bthid_session_p s, ui
assert(len == sizeof(vkbd_status_t));
 
memcpy(, data, sizeof(st));
-   leds = 0;
+   found = 0;
report_id = NO_REPORT_ID;
 
hid_device = get_hid_device(>bdaddr);
assert(hid_device != NULL);
 
+   data[0] = 0xa2; /* DATA output (HID output report) */
+   data[1] = 0x00;
+   data[2] = 0x00;
+
for (d = hid_start_parse(hid_device->desc, 1 << hid_output, -1);
 hid_get_item(d, ) > 0; ) {
if (HID_PAGE(h.usage) == HUP_LEDS) {
+   found++;
+
if (report_id == NO_REPORT_ID)
report_id = h.report_ID;
else if (h.report_ID != report_id)
@@ -544,17 +550,17 @@ kbd_status_changed(bthid_session_p s, ui
switch(HID_USAGE(h.usage)) {
case 0x01: /* Num Lock LED */
if (st.leds & LED_NUM)
-   hid_set_data(, , 1);
+   hid_set_data([1], , 1);
break;
 
case 0x02: /* Caps Lock LED */
if (st.leds & LED_CAP)
-   hid_set_data(, , 1);
+   hid_set_data([1], , 1);
break;
 
case 0x03: /* Scroll Lock LED */
if (st.leds & LED_SCR)
-   hid_set_data(, , 1);
+   hid_set_data([1], , 1);
break;
 
/* XXX add other LEDs ? */
@@ -563,18 +569,8 @@ kbd_status_changed(bthid_session_p s, ui
}
hid_end_parse(d);
 
-   data[0] = 0xa2; /* DATA output (HID output report) */
-
-   if (report_id != NO_REPORT_ID) {
-   data[1] = report_id;
-   data[2] = leds;
-   len = 3;
-   } else {
-   data[1] = leds;
-   len = 2;
-   }
-
-   write(s->intr, data, len);
+   if (found)
+   write(s->intr, data, (report_id != NO_REPORT_ID) ? 3 : 2);
 
return (0);
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r292660 - head/sys/netgraph/bluetooth/socket

2015-12-23 Thread Maksim Yevmenkin
Author: emax
Date: Wed Dec 23 16:32:04 2015
New Revision: 292660
URL: https://svnweb.freebsd.org/changeset/base/292660

Log:
  - grab ng_btsocket_l2cap_sockets_mtx lock in
ng_btsocket_l2cap_process_l2ca_enc_change()
before calling ng_btsocket_l2cap_pcb_by_cid();
  
  - handle possible NULL value returned from
ng_btsocket_l2cap_pcb_by_cid();
  
  Submitted by: Hans Petter Selasky; hps at selasky dot org
  MFC after:1 week

Modified:
  head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c

Modified: head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c
==
--- head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c  Wed Dec 23 
15:22:44 2015(r292659)
+++ head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c  Wed Dec 23 
16:32:04 2015(r292660)
@@ -708,8 +708,15 @@ static int ng_btsocket_l2cap_process_l2c
 
op = (ng_l2cap_l2ca_enc_chg_op *)(msg->data);
 
+   mtx_lock(_btsocket_l2cap_sockets_mtx);
+
pcb = ng_btsocket_l2cap_pcb_by_cid(>src, op->lcid,
   op->idtype);
+   if (pcb == NULL) {
+   mtx_unlock(_btsocket_l2cap_sockets_mtx);
+   return (ENOENT);
+   }
+
mtx_lock(>pcb_mtx);
pcb->encryption = op->result;

@@ -729,6 +736,7 @@ static int ng_btsocket_l2cap_process_l2c
}
}
mtx_unlock(>pcb_mtx);
+   mtx_unlock(_btsocket_l2cap_sockets_mtx);
 
return 0;
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r289637 - head/usr.sbin/bluetooth/sdpcontrol

2015-10-20 Thread Maksim Yevmenkin
Author: emax
Date: Tue Oct 20 18:01:08 2015
New Revision: 289637
URL: https://svnweb.freebsd.org/changeset/base/289637

Log:
  check boundaries while parsing SDP responses
  
  Reported by:  hps
  Reviewed by:  hps
  MFC after:1 week

Modified:
  head/usr.sbin/bluetooth/sdpcontrol/search.c

Modified: head/usr.sbin/bluetooth/sdpcontrol/search.c
==
--- head/usr.sbin/bluetooth/sdpcontrol/search.c Tue Oct 20 17:58:21 2015
(r289636)
+++ head/usr.sbin/bluetooth/sdpcontrol/search.c Tue Oct 20 18:01:08 2015
(r289637)
@@ -103,6 +103,12 @@ print_service_class_id_list(uint8_t cons
/* NOT REACHED */
}
 
+   if (len > (end - start)) {
+   fprintf(stderr, "Invalid Service Class ID List. " \
+   "Too long len=%d\n", len);
+   return;
+   }
+
while (start < end) {
SDP_GET8(type, start);
switch (type) {
@@ -259,28 +265,31 @@ print_protocol_descriptor(uint8_t const 
case SDP_DATA_STR8:
case SDP_DATA_URL8:
SDP_GET8(len, start);
-   fprintf(stdout, "%*.*s\n", len, len, (char *) start);
-   start += len;
+   for (; start < end && len > 0; start ++, len --)
+   fprintf(stdout, "%c", *start);
+   fprintf(stdout, "\n");
break;
 
case SDP_DATA_STR16:
case SDP_DATA_URL16:
SDP_GET16(len, start);
-   fprintf(stdout, "%*.*s\n", len, len, (char *) start);
-   start += len;
+   for (; start < end && len > 0; start ++, len --)
+   fprintf(stdout, "%c", *start);
+   fprintf(stdout, "\n");
break;
 
case SDP_DATA_STR32:
case SDP_DATA_URL32:
SDP_GET32(len, start);
-   fprintf(stdout, "%*.*s\n", len, len, (char *) start);
-   start += len;
+   for (; start < end && len > 0; start ++, len --)
+   fprintf(stdout, "%c", *start);
+   fprintf(stdout, "\n");
break;
 
case SDP_DATA_SEQ8:
case SDP_DATA_ALT8:
SDP_GET8(len, start);
-   for (; len > 0; start ++, len --)
+   for (; start < end && len > 0; start ++, len --)
fprintf(stdout, "%#2.2x ", *start);
fprintf(stdout, "\n");
break;
@@ -288,7 +297,7 @@ print_protocol_descriptor(uint8_t const 
case SDP_DATA_SEQ16:
case SDP_DATA_ALT16:
SDP_GET16(len, start);
-   for (; len > 0; start ++, len --)
+   for (; start < end && len > 0; start ++, len --)
fprintf(stdout, "%#2.2x ", *start);
fprintf(stdout, "\n");
break;
@@ -296,7 +305,7 @@ print_protocol_descriptor(uint8_t const 
case SDP_DATA_SEQ32:
case SDP_DATA_ALT32:
SDP_GET32(len, start);
-   for (; len > 0; start ++, len --)
+   for (; start < end && len > 0; start ++, len --)
fprintf(stdout, "%#2.2x ", *start);
fprintf(stdout, "\n");
break;
@@ -342,6 +351,12 @@ print_protocol_descriptor_list(uint8_t c
/* NOT REACHED */
}
 
+   if (len > (end - start)) {
+   fprintf(stderr, "Invalid Protocol Descriptor List. " \
+   "Too long, len=%d\n", len);
+   return;
+   }
+
while (start < end) {
SDP_GET8(type, start);
switch (type) {
@@ -364,6 +379,12 @@ print_protocol_descriptor_list(uint8_t c
/* NOT REACHED */
}
 
+   if (len > (end - start)) {
+   fprintf(stderr, "Invalid Protocol Descriptor List. " \
+   "Too long, len=%d\n", len);
+   return;
+   }
+
print_protocol_descriptor(start, start + len);
start += len;
}
@@ -416,6 +437,12 @@ print_bluetooth_profile_descriptor_list(
/* NOT REACHED */
}
 
+   if (len > (end - start)) {
+   fprintf(stderr, "Invalid Bluetooth Profile Descriptor List. " \
+   "Too long, len=%d\n", len);
+   return;
+   }
+
while (start < end) {

svn commit: r273548 - head/usr.bin/bluetooth/rfcomm_sppd

2014-10-23 Thread Maksim Yevmenkin
Author: emax
Date: Thu Oct 23 15:16:40 2014
New Revision: 273548
URL: https://svnweb.freebsd.org/changeset/base/273548

Log:
  Change the code to use the openpty(3) API which uses the pts(4) driver
  instead of the pty(4) driver.
  
  PR:   184597
  Submitted by: tobias.rehbein
  MFC after:2 weeks

Modified:
  head/usr.bin/bluetooth/rfcomm_sppd/Makefile
  head/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.1
  head/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.c

Modified: head/usr.bin/bluetooth/rfcomm_sppd/Makefile
==
--- head/usr.bin/bluetooth/rfcomm_sppd/Makefile Thu Oct 23 14:29:52 2014
(r273547)
+++ head/usr.bin/bluetooth/rfcomm_sppd/Makefile Thu Oct 23 15:16:40 2014
(r273548)
@@ -6,6 +6,6 @@ SRCS=   rfcomm_sppd.c rfcomm_sdp.c
 WARNS?=2
 
 DPADD= ${LIBBLUETOOTH} ${LIBSDP}
-LDADD= -lbluetooth -lsdp
+LDADD= -lbluetooth -lsdp -lutil
 
 .include bsd.prog.mk

Modified: head/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.1
==
--- head/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.1Thu Oct 23 14:29:52 
2014(r273547)
+++ head/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.1Thu Oct 23 15:16:40 
2014(r273548)
@@ -33,10 +33,9 @@
 .Nd RFCOMM Serial Port Profile daemon
 .Sh SYNOPSIS
 .Nm
-.Op Fl bhS
+.Op Fl bhtS
 .Fl a Ar address
 .Fl c Ar channel
-.Op Fl t Ar tty
 .Sh DESCRIPTION
 The
 .Nm
@@ -53,7 +52,7 @@ Once connection is established, the
 .Nm
 utility provides access to the server's remote serial port via stdin/stdout
 or via
-.Xr pty 4
+.Xr pts 4
 interface if
 .Fl t
 option was specified.
@@ -72,8 +71,7 @@ daemon.
 If
 .Fl t
 options was specified,
-the server side of the virtual serial port is attached to the pseudo-terminal
-.Ar tty .
+the server side of the virtual serial port is attached to a pseudo-terminal.
 Otherwise the virtual serial port is attached to the stdin/stdout.
 .Nm
 should be run as root in order to communicate with
@@ -146,24 +144,22 @@ Display usage message and exit.
 .It Fl S
 Server mode; see
 .Sx DESCRIPTION .
-.It Fl t Ar tty
-Slave pseudo tty name.
+.It Fl t
+Use slave pseudo tty.
 If not set stdin/stdout will be used.
 This option is required if
 .Fl b
 option was specified.
 .El
 .Sh FILES
-.Bl -tag -width .Pa /dev/tty[p-sP-S][0-9a-v] -compact
-.It Pa /dev/pty[p-sP-S][0-9a-v]
-master pseudo terminals
-.It Pa /dev/tty[p-sP-S][0-9a-v]
+.Bl -tag -width .Pa /dev/pts/[num] -compact
+.It Pa /dev/pts/[num]
 slave pseudo terminals
 .El
 .Sh EXIT STATUS
 .Ex -std
 .Sh EXAMPLES
-.Dl rfcomm_sppd -a 00:01:02:03:04:05 -c 1 -t /dev/ttyp1
+.Dl rfcomm_sppd -a 00:01:02:03:04:05 -c 1 -t
 .Pp
 Will start the
 .Nm
@@ -171,13 +167,17 @@ utility and open RFCOMM connection to th
 .Li 00:01:02:03:04:05
 and channel
 .Li 1 .
-Once the connection has been established,
-.Pa /dev/ttyp1
+Once the connection has been established, a
+.Xr pts 4
 can be used to talk to the remote serial port on the server.
+.Nm
+prints the name of the
+.Xr pts 4
+to use on stdout.
 .Sh SEE ALSO
 .Xr bluetooth 3 ,
 .Xr ng_btsocket 4 ,
-.Xr pty 4 ,
+.Xr pts 4 ,
 .Xr rfcomm_pppd 8 ,
 .Xr sdpd 8
 .Sh AUTHORS

Modified: head/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.c
==
--- head/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.cThu Oct 23 14:29:52 
2014(r273547)
+++ head/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.cThu Oct 23 15:16:40 
2014(r273548)
@@ -32,6 +32,7 @@
  */
 
 #include sys/stat.h
+#include sys/types.h
 #include bluetooth.h
 #include ctype.h
 #include err.h
@@ -49,6 +50,7 @@
 #include syslog.h
 #include termios.h
 #include unistd.h
+#include libutil.h
 
 #define SPPD_IDENT rfcomm_sppd
 #define SPPD_BUFFER_SIZE   1024
@@ -58,7 +60,7 @@ int   rfcomm_channel_lookup   (bdaddr_t con
 bdaddr_t const *remote, 
 int service, int *channel, int *error);
 
-static int sppd_ttys_open  (char const *tty, int *amaster, int *aslave);
+static int sppd_ttys_open  (char **tty, int *amaster, int *aslave);
 static int sppd_read   (int fd, char *buffer, int size);
 static int sppd_write  (int fd, char *buffer, int size);
 static voidsppd_sighandler (int s);
@@ -74,7 +76,8 @@ main(int argc, char *argv[]) 
struct sockaddr_rfcomm   ra;
bdaddr_t addr;
int  n, background, channel, service,
-s, amaster, aslave, fd, doserver;
+s, amaster, aslave, fd, doserver,
+dopty;
fd_set   rfd;
char*tty = NULL, *ep = NULL, buf[SPPD_BUFFER_SIZE];
 
@@ -82,9 +85,10 @@ main(int argc, char *argv[]) 

svn commit: r264621 - head/sys/dev/cxgbe

2014-04-17 Thread Maksim Yevmenkin
Author: emax
Date: Thu Apr 17 19:29:15 2014
New Revision: 264621
URL: http://svnweb.freebsd.org/changeset/base/264621

Log:
  use correct (integer) type for the temperature sysctl
  
  Reviewed by:  np, scottl
  Obtained from:Netflix
  MFC after:3 days

Modified:
  head/sys/dev/cxgbe/t4_main.c

Modified: head/sys/dev/cxgbe/t4_main.c
==
--- head/sys/dev/cxgbe/t4_main.cThu Apr 17 18:13:23 2014
(r264620)
+++ head/sys/dev/cxgbe/t4_main.cThu Apr 17 19:29:15 2014
(r264621)
@@ -4332,7 +4332,7 @@ t4_sysctls(struct adapter *sc)
NULL, sc-tids.nftids, number of filters);
 
SYSCTL_ADD_PROC(ctx, children, OID_AUTO, temperature, CTLTYPE_INT |
-   CTLFLAG_RD, sc, 0, sysctl_temperature, A,
+   CTLFLAG_RD, sc, 0, sysctl_temperature, I,
chip temperature (in Celsius));
 
t4_sge_sysctls(sc, ctx, children);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r263690 - head/sys/kern

2014-03-24 Thread Maksim Yevmenkin
Author: emax
Date: Mon Mar 24 18:13:41 2014
New Revision: 263690
URL: http://svnweb.freebsd.org/changeset/base/263690

Log:
  change defaule permissions on /dev/devstat. while i'm here remove
  D_NEEDGIANT flag
  
  Submitted by: jhb
  Reviewed by:  jhb, scottl, rwatson, delphij, phk
  MFC after:1 week

Modified:
  head/sys/kern/subr_devstat.c

Modified: head/sys/kern/subr_devstat.c
==
--- head/sys/kern/subr_devstat.cMon Mar 24 15:22:22 2014
(r263689)
+++ head/sys/kern/subr_devstat.cMon Mar 24 18:13:41 2014
(r263690)
@@ -460,7 +460,6 @@ static d_mmap_t devstat_mmap;
 
 static struct cdevsw devstat_cdevsw = {
.d_version =D_VERSION,
-   .d_flags =  D_NEEDGIANT,
.d_mmap =   devstat_mmap,
.d_name =   devstat,
 };
@@ -482,13 +481,16 @@ devstat_mmap(struct cdev *dev, vm_ooffse
 
if (nprot != VM_PROT_READ)
return (-1);
+   mtx_lock(devstat_mutex);
TAILQ_FOREACH(spp, pagelist, list) {
if (offset == 0) {
*paddr = vtophys(spp-stat);
+   mtx_unlock(devstat_mutex);
return (0);
}
offset -= PAGE_SIZE;
}
+   mtx_unlock(devstat_mutex);
return (-1);
 }
 
@@ -503,7 +505,7 @@ devstat_alloc(void)
mtx_assert(devstat_mutex, MA_NOTOWNED);
if (!once) {
make_dev_credf(MAKEDEV_ETERNAL | MAKEDEV_CHECKNAME,
-   devstat_cdevsw, 0, NULL, UID_ROOT, GID_WHEEL, 0400,
+   devstat_cdevsw, 0, NULL, UID_ROOT, GID_WHEEL, 0444,
DEVSTAT_DEVICE_NAME);
once = 1;
}
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r263690 - head/sys/kern

2014-03-24 Thread Maksim Yevmenkin
On Mon, Mar 24, 2014 at 11:59 AM, John-Mark Gurney j...@funkthat.com wrote:
 Maksim Yevmenkin wrote this message on Mon, Mar 24, 2014 at 18:13 +:
 Author: emax
 Date: Mon Mar 24 18:13:41 2014
 New Revision: 263690
 URL: http://svnweb.freebsd.org/changeset/base/263690

 Log:
   change defaule permissions on /dev/devstat. while i'm here remove
   D_NEEDGIANT flag

 I know that the following change is part of the remove D_NEEDGIANT, but
 I'm puzzled how this code either worked before, or continues to work..

hmm... beats me too... pagelist is only growing and never shrinking,
and new pages are added to the of the list, so may be that the reason,
i.e. window for race is very small

 It looks like pagelist was suppose to be protected by devstat_mutex,
 but previously wasn't and that this is fixing that bug, is this
 correct?

it should fix it, yes.

thanks
max
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r257472 - head/sys/kern

2013-10-31 Thread Maksim Yevmenkin
Author: emax
Date: Thu Oct 31 20:33:21 2013
New Revision: 257472
URL: http://svnweb.freebsd.org/changeset/base/257472

Log:
  Rate limit (to once per minute) Listen queue overflow message in
  sonewconn().
  
  Reviewed by:  scottl, lstewart
  Obtained from:Netflix, Inc
  MFC after:2 weeks

Modified:
  head/sys/kern/uipc_socket.c

Modified: head/sys/kern/uipc_socket.c
==
--- head/sys/kern/uipc_socket.c Thu Oct 31 20:32:11 2013(r257471)
+++ head/sys/kern/uipc_socket.c Thu Oct 31 20:33:21 2013(r257472)
@@ -486,6 +486,10 @@ SYSCTL_INT(_regression, OID_AUTO, sonewc
 struct socket *
 sonewconn(struct socket *head, int connstatus)
 {
+   static struct timeval lastover;
+   static struct timeval overinterval = { 60, 0 };
+   static int overcount;
+
struct socket *so;
int over;
 
@@ -497,9 +501,17 @@ sonewconn(struct socket *head, int conns
 #else
if (over) {
 #endif
-   log(LOG_DEBUG, %s: pcb %p: Listen queue overflow: 
-   %i already in queue awaiting acceptance\n,
-   __func__, head-so_pcb, head-so_qlen);
+   overcount++;
+
+   if (ratecheck(lastover, overinterval)) {
+   log(LOG_DEBUG, %s: pcb %p: Listen queue overflow: 
+   %i already in queue awaiting acceptance 
+   (%d occurrences)\n,
+   __func__, head-so_pcb, head-so_qlen, overcount);
+
+   overcount = 0;
+   }
+
return (NULL);
}
VNET_ASSERT(head-so_vnet != NULL, (%s:%d so_vnet is NULL, head=%p,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r256563 - head/sys/net

2013-10-15 Thread Maksim Yevmenkin
Author: emax
Date: Tue Oct 15 21:28:51 2013
New Revision: 256563
URL: http://svnweb.freebsd.org/changeset/base/256563

Log:
  In the flowtable scanner, restart the scan at the last found position,
  not at position 0.  Changes the scanner from O(N^2) to O(N).
  
  Submitted by: scottl
  Obtained from:Netflix, Inc
  MFC after:3 weeks

Modified:
  head/sys/net/flowtable.c

Modified: head/sys/net/flowtable.c
==
--- head/sys/net/flowtable.cTue Oct 15 21:08:37 2013(r256562)
+++ head/sys/net/flowtable.cTue Oct 15 21:28:51 2013(r256563)
@@ -1401,7 +1401,7 @@ fle_free(struct flentry *fle, struct flo
 static void
 flowtable_free_stale(struct flowtable *ft, struct rtentry *rt)
 {
-   int curbit = 0, count;
+   int curbit = 0, count, tmpsize;
struct flentry *fle,  **flehead, *fleprev;
struct flentry *flefreehead, *flefreetail, *fletmp;
bitstr_t *mask, *tmpmask;
@@ -1410,6 +1410,7 @@ flowtable_free_stale(struct flowtable *f
flefreehead = flefreetail = NULL;
mask = flowtable_mask(ft);
tmpmask = ft-ft_tmpmask;
+   tmpsize = ft-ft_size;
memcpy(tmpmask, mask, ft-ft_size/8);
/*
 * XXX Note to self, bit_ffs operates at the byte level
@@ -1479,7 +1480,9 @@ flowtable_free_stale(struct flowtable *f
bit_clear(mask, curbit);
FL_ENTRY_UNLOCK(ft, curbit);
bit_clear(tmpmask, curbit);
-   bit_ffs(tmpmask, ft-ft_size, curbit);
+   tmpmask += (curbit / 8);
+   tmpsize -= (curbit / 8) * 8;
+   bit_ffs(tmpmask, tmpsize, curbit);
}
count = 0;
while ((fle = flefreehead) != NULL) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r241691 - head/sys/dev/oce

2012-10-18 Thread Maksim Yevmenkin
On Thu, Oct 18, 2012 at 8:14 AM, John Baldwin j...@freebsd.org wrote:
 Author: jhb
 Date: Thu Oct 18 15:14:13 2012
 New Revision: 241691
 URL: http://svn.freebsd.org/changeset/base/241691

 Log:
   Use if_initbaudrate().

thank you for fixing this. i did not realize that there would be so
much fallout form this :( next time i would make universe first :(

sorry about this

max
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r241699 - head/usr.sbin/bluetooth/btpand

2012-10-18 Thread Maksim Yevmenkin
Author: emax
Date: Thu Oct 18 16:34:00 2012
New Revision: 241699
URL: http://svn.freebsd.org/changeset/base/241699

Log:
  make sure that socket's send and receive buffers are properly sized
  
  Submitted by: Iain Hibbert plunky at rya-online dot net
  MFC after:3 weeks

Modified:
  head/usr.sbin/bluetooth/btpand/client.c
  head/usr.sbin/bluetooth/btpand/server.c

Modified: head/usr.sbin/bluetooth/btpand/client.c
==
--- head/usr.sbin/bluetooth/btpand/client.c Thu Oct 18 15:52:00 2012
(r241698)
+++ head/usr.sbin/bluetooth/btpand/client.c Thu Oct 18 16:34:00 2012
(r241699)
@@ -47,7 +47,7 @@ client_init(void)
struct sockaddr_l2cap sa;
channel_t *chan;
socklen_t len;
-   int fd;
+   int fd, n;
uint16_t mru, mtu;
 
if (bdaddr_any(remote_bdaddr))
@@ -97,6 +97,17 @@ client_init(void)
exit(EXIT_FAILURE);
}
 
+   len = sizeof(n);
+   if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, n, len) == -1) {
+   log_err(Could not read SO_RCVBUF);
+   exit(EXIT_FAILURE);
+   }
+   if (n  (mru * 10)) {
+   n = mru * 10;
+   if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, n, sizeof(n)) == -1)
+   log_info(Could not increase SO_RCVBUF (from %d), n);
+   }
+
len = sizeof(mtu);
if (getsockopt(fd, SOL_L2CAP, SO_L2CAP_OMTU, mtu, len) == -1) {
log_err(Could not get L2CAP OMTU: %m);
@@ -107,6 +118,27 @@ client_init(void)
exit(EXIT_FAILURE);
}
 
+   len = sizeof(n);
+   if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, n, len) == -1) {
+   log_err(Could not get socket send buffer size: %m);
+   close(fd);
+   return;
+   }
+   if (n  (mtu * 2)) {
+   n = mtu * 2;
+   if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, n, sizeof(n)) == -1) 
{
+   log_err(Could not set socket send buffer size (%d): 
%m, n);
+   close(fd);
+   return;
+   }
+   }
+   n = mtu;
+   if (setsockopt(fd, SOL_SOCKET, SO_SNDLOWAT, n, sizeof(n)) == -1) {
+   log_err(Could not set socket low water mark (%d): %m, n);
+   close(fd);
+   return;
+   }
+
chan = channel_alloc();
if (chan == NULL)
exit(EXIT_FAILURE);

Modified: head/usr.sbin/bluetooth/btpand/server.c
==
--- head/usr.sbin/bluetooth/btpand/server.c Thu Oct 18 15:52:00 2012
(r241698)
+++ head/usr.sbin/bluetooth/btpand/server.c Thu Oct 18 16:34:00 2012
(r241699)
@@ -177,6 +177,18 @@ server_read(int s, short ev, void *arg)
return;
}
 
+   len = sizeof(n);
+   if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, n, len) == -1) {
+   log_err(Could not read SO_RCVBUF);
+   close(fd);
+   return;
+   }
+   if (n  (mru * 10)) {
+   n = mru * 10;
+   if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, n, sizeof(n)) == -1)
+   log_info(Could not increase SO_RCVBUF (from %d), n);
+   }
+
len = sizeof(mtu);
if (getsockopt(fd, SOL_L2CAP, SO_L2CAP_OMTU, mtu, len) == -1) {
log_err(Could not get L2CAP OMTU: %m);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r241627 - head/sys/net

2012-10-17 Thread maksim yevmenkin
Thank you for fixing it. I have accidentally committed broken version from  
work-in-progress tree :( 

Thanks,
Max


On Oct 17, 2012, at 1:19 AM, Xin LI delp...@freebsd.org wrote:

 Author: delphij
 Date: Wed Oct 17 08:19:08 2012
 New Revision: 241627
 URL: http://svn.freebsd.org/changeset/base/241627
 
 Log:
  Fix build.
 
 Modified:
  head/sys/net/if_lagg.c
 
 Modified: head/sys/net/if_lagg.c
 ==
 --- head/sys/net/if_lagg.cWed Oct 17 05:08:35 2012(r241626)
 +++ head/sys/net/if_lagg.cWed Oct 17 08:19:08 2012(r241627)
 @@ -289,7 +289,7 @@ lagg_clone_create(struct if_clone *ifc, 
use_flowid, CTLTYPE_INT|CTLFLAG_RW, sc-use_flowid, sc-use_flowid,
Use flow id for load sharing);
SYSCTL_ADD_INT(sc-ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
 -count, CTLTYPE_INT|CTLFLAG_RO, sc-sc_count, sc-sc_count,
 +count, CTLTYPE_INT|CTLFLAG_RD, sc-sc_count, sc-sc_count,
Total number of ports);
/* Hash all layers by default */
sc-sc_flags = LAGG_F_HASHL2|LAGG_F_HASHL3|LAGG_F_HASHL4;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r241616 - in head/sys: dev/ixgbe net

2012-10-17 Thread Maksim Yevmenkin
On Wed, Oct 17, 2012 at 6:51 AM, John Baldwin j...@freebsd.org wrote:

[...]

  Maybe a helper 'if_set_baudrate(ifp, IF_Gbps(10))' that would DTRT.
  (It could be a static inline or some such).  I would just like to
  keep the readability.

 well, yes, i thought about it, but decided not to do it right away. we
 could provide shortcuts/macros for popular baudrates, i.e. 1, 10, 40
 and 100 Gbps. while ixgbe(4) example is not ideal, i thought it still
 was pretty readable :)

 I don't really find it all that readable.  IF_Gbps(1) looks like a typo
 to a casual reader.  I really think you should have something like:

[...]

very well :)  would something like (please see below) work?

Index: sys/dev/ixgbe/ixgbe.c
===
--- sys/dev/ixgbe/ixgbe.c   (revision 241641)
+++ sys/dev/ixgbe/ixgbe.c   (working copy)
@@ -2597,8 +2597,7 @@
return (-1);
}
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
-   ifp-if_baudrate = IF_Gbps(1);
-   ifp-if_baudrate_pf = 1;/* 1Gbps * 10^1 = 10Gbps */
+   if_initbaudrate(ifp, IF_Gbps(10));
ifp-if_init = ixgbe_init;
ifp-if_softc = adapter;
ifp-if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
Index: sys/net/if.h
===
--- sys/net/if.h(revision 241641)
+++ sys/net/if.h(working copy)
@@ -179,7 +179,7 @@
  * Some convenience macros used for setting ifi_baudrate.
  * XXX 1000 vs. 1024? --thor...@netbsd.org
  */
-#defineIF_Kbps(x)  ((x) * 1000)/* kilobits/sec. */
+#defineIF_Kbps(x)  ((uintmax_t)(x) * 1000) /* kilobits/sec. */
 #defineIF_Mbps(x)  (IF_Kbps((x) * 1000))   /* megabits/sec. */
 #defineIF_Gbps(x)  (IF_Mbps((x) * 1000))   /* gigabits/sec. */

Index: sys/net/if_var.h
===
--- sys/net/if_var.h(revision 241641)
+++ sys/net/if_var.h(working copy)
@@ -591,6 +591,18 @@
 } while (0)

 #ifdef _KERNEL
+static __inline void
+if_initbaudrate(struct ifnet *ifp, uintmax_t baud)
+{
+
+   ifp-if_baudrate_pf = 0;
+   while (baud  (u_long)(~0UL)) {
+   baud /= 10;
+   ifp-if_baudrate_pf++;
+   }
+   ifp-if_baudrate = baud;
+}
+
 static __inline int
 drbr_enqueue(struct ifnet *ifp, struct buf_ring *br, struct mbuf *m)
 {

==

thanks,
max
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r241646 - in head/sys: dev/ixgbe net

2012-10-17 Thread Maksim Yevmenkin
Author: emax
Date: Wed Oct 17 19:24:13 2012
New Revision: 241646
URL: http://svn.freebsd.org/changeset/base/241646

Log:
  provide helper if_initbaudrate() to set if_baudrate_pf and if_baudrate_pf.
  again, use ixgbe(4) as an example of how to use new helper function.
  
  Reviewed by:  jhb
  MFC after:1 week

Modified:
  head/sys/dev/ixgbe/ixgbe.c
  head/sys/net/if.h
  head/sys/net/if_var.h

Modified: head/sys/dev/ixgbe/ixgbe.c
==
--- head/sys/dev/ixgbe/ixgbe.c  Wed Oct 17 19:21:52 2012(r241645)
+++ head/sys/dev/ixgbe/ixgbe.c  Wed Oct 17 19:24:13 2012(r241646)
@@ -2597,8 +2597,7 @@ ixgbe_setup_interface(device_t dev, stru
return (-1);
}
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
-   ifp-if_baudrate = IF_Gbps(1);
-   ifp-if_baudrate_pf = 1;/* 1Gbps * 10^1 = 10Gbps */
+   if_initbaudrate(ifp, IF_Gbps(10));
ifp-if_init = ixgbe_init;
ifp-if_softc = adapter;
ifp-if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;

Modified: head/sys/net/if.h
==
--- head/sys/net/if.h   Wed Oct 17 19:21:52 2012(r241645)
+++ head/sys/net/if.h   Wed Oct 17 19:24:13 2012(r241646)
@@ -179,7 +179,7 @@ struct if_data {
  * Some convenience macros used for setting ifi_baudrate.
  * XXX 1000 vs. 1024? --thor...@netbsd.org
  */
-#defineIF_Kbps(x)  ((x) * 1000)/* kilobits/sec. */
+#defineIF_Kbps(x)  ((uintmax_t)(x) * 1000) /* kilobits/sec. */
 #defineIF_Mbps(x)  (IF_Kbps((x) * 1000))   /* megabits/sec. */
 #defineIF_Gbps(x)  (IF_Mbps((x) * 1000))   /* gigabits/sec. */
 

Modified: head/sys/net/if_var.h
==
--- head/sys/net/if_var.h   Wed Oct 17 19:21:52 2012(r241645)
+++ head/sys/net/if_var.h   Wed Oct 17 19:24:13 2012(r241646)
@@ -591,6 +591,18 @@ do {   
\
 } while (0)
 
 #ifdef _KERNEL
+static __inline void
+if_initbaudrate(struct ifnet *ifp, uintmax_t baud)
+{
+
+   ifp-if_baudrate_pf = 0;
+   while (baud  (u_long)(~0UL)) {
+   baud /= 10;
+   ifp-if_baudrate_pf++;
+   }
+   ifp-if_baudrate = baud;
+}
+
 static __inline int
 drbr_enqueue(struct ifnet *ifp, struct buf_ring *br, struct mbuf *m)
 {  
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r241654 - head/contrib/bsnmp/snmp_mibII

2012-10-17 Thread Maksim Yevmenkin
Author: emax
Date: Wed Oct 17 21:53:38 2012
New Revision: 241654
URL: http://svn.freebsd.org/changeset/base/241654

Log:
  fix build
  
  MFC after:1 week

Modified:
  head/contrib/bsnmp/snmp_mibII/mibII.h

Modified: head/contrib/bsnmp/snmp_mibII/mibII.h
==
--- head/contrib/bsnmp/snmp_mibII/mibII.h   Wed Oct 17 21:48:45 2012
(r241653)
+++ head/contrib/bsnmp/snmp_mibII/mibII.h   Wed Oct 17 21:53:38 2012
(r241654)
@@ -36,6 +36,7 @@
 #include sys/sockio.h
 #include sys/syslog.h
 #include sys/time.h
+#include stdint.h
 #include stdio.h
 #include stdlib.h
 #include string.h
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r241656 - head/contrib/bsnmp/snmp_mibII

2012-10-17 Thread Maksim Yevmenkin
Author: emax
Date: Thu Oct 18 00:20:02 2012
New Revision: 241656
URL: http://svn.freebsd.org/changeset/base/241656

Log:
  put another bandaid on the build until i figure out bsnmp headers

Modified:
  head/contrib/bsnmp/snmp_mibII/mibII_route.c

Modified: head/contrib/bsnmp/snmp_mibII/mibII_route.c
==
--- head/contrib/bsnmp/snmp_mibII/mibII_route.c Wed Oct 17 22:14:09 2012
(r241655)
+++ head/contrib/bsnmp/snmp_mibII/mibII_route.c Thu Oct 18 00:20:02 2012
(r241656)
@@ -30,7 +30,7 @@
  *
  * Routing table
  */
-#include support.h
+/*#include support.h*/
 
 #ifdef HAVE_SYS_TREE_H
 #include sys/tree.h
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r241616 - in head/sys: dev/ixgbe net

2012-10-16 Thread Maksim Yevmenkin
Author: emax
Date: Tue Oct 16 20:18:15 2012
New Revision: 241616
URL: http://svn.freebsd.org/changeset/base/241616

Log:
  introduce concept of ifi_baudrate power factor. the idea is to work
  around the problem where high speed interfaces (such as ixgbe(4))
  are not able to report real ifi_baudrate. bascially, take a spare
  byte from struct if_data and use it to store ifi_baudrate power
  factor. in other words,
  
  real ifi_baudrate = ifi_baudrate * 10 ^ ifi_baudrate power factor
  
  this should be backwards compatible with old binaries. use ixgbe(4)
  as an example on how drivers would set ifi_baudrate power factor
  
  Discussed with:   kib, scottl, glebius
  MFC after:1 week

Modified:
  head/sys/dev/ixgbe/ixgbe.c
  head/sys/net/if.h
  head/sys/net/if_var.h

Modified: head/sys/dev/ixgbe/ixgbe.c
==
--- head/sys/dev/ixgbe/ixgbe.c  Tue Oct 16 19:59:13 2012(r241615)
+++ head/sys/dev/ixgbe/ixgbe.c  Tue Oct 16 20:18:15 2012(r241616)
@@ -2597,7 +2597,8 @@ ixgbe_setup_interface(device_t dev, stru
return (-1);
}
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
-   ifp-if_baudrate = 10;
+   ifp-if_baudrate = IF_Gbps(1);
+   ifp-if_baudrate_pf = 1;/* 1Gbps * 10^1 = 10Gbps */
ifp-if_init = ixgbe_init;
ifp-if_softc = adapter;
ifp-if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;

Modified: head/sys/net/if.h
==
--- head/sys/net/if.h   Tue Oct 16 19:59:13 2012(r241615)
+++ head/sys/net/if.h   Tue Oct 16 20:18:15 2012(r241616)
@@ -86,7 +86,7 @@ struct if_data {
u_char  ifi_hdrlen; /* media header length */
u_char  ifi_link_state; /* current link state */
u_char  ifi_vhid;   /* carp vhid */
-   u_char  ifi_spare_char2;/* spare byte */
+   u_char  ifi_baudrate_pf;/* baudrate power factor */
u_char  ifi_datalen;/* length of this data struct */
u_long  ifi_mtu;/* maximum transmission unit */
u_long  ifi_metric; /* routing metric (external only) */

Modified: head/sys/net/if_var.h
==
--- head/sys/net/if_var.h   Tue Oct 16 19:59:13 2012(r241615)
+++ head/sys/net/if_var.h   Tue Oct 16 20:18:15 2012(r241616)
@@ -228,6 +228,7 @@ typedef void if_init_f_t(void *);
 #defineif_metric   if_data.ifi_metric
 #defineif_link_state   if_data.ifi_link_state
 #defineif_baudrate if_data.ifi_baudrate
+#defineif_baudrate_pf  if_data.ifi_baudrate_pf
 #defineif_hwassist if_data.ifi_hwassist
 #defineif_ipackets if_data.ifi_ipackets
 #defineif_ierrors  if_data.ifi_ierrors
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r241616 - in head/sys: dev/ixgbe net

2012-10-16 Thread Maksim Yevmenkin
On Tue, Oct 16, 2012 at 2:02 PM, John Baldwin j...@freebsd.org wrote:
 On Tuesday, October 16, 2012 4:18:16 pm Maksim Yevmenkin wrote:
 Author: emax
 Date: Tue Oct 16 20:18:15 2012
 New Revision: 241616
 URL: http://svn.freebsd.org/changeset/base/241616

 Log:
   introduce concept of ifi_baudrate power factor. the idea is to work
   around the problem where high speed interfaces (such as ixgbe(4))
   are not able to report real ifi_baudrate. bascially, take a spare
   byte from struct if_data and use it to store ifi_baudrate power
   factor. in other words,

   real ifi_baudrate = ifi_baudrate * 10 ^ ifi_baudrate power factor

   this should be backwards compatible with old binaries. use ixgbe(4)
   as an example on how drivers would set ifi_baudrate power factor

   Discussed with: kib, scottl, glebius
   MFC after:  1 week

 It would be a lot nicer if you could still allow one to use more
 readable things like IF_Gbps(10).  Note that we do have a 40G driver
 (mlxen) as well.

 Maybe a helper 'if_set_baudrate(ifp, IF_Gbps(10))' that would DTRT.
 (It could be a static inline or some such).  I would just like to
 keep the readability.

well, yes, i thought about it, but decided not to do it right away. we
could provide shortcuts/macros for popular baudrates, i.e. 1, 10, 40
and 100 Gbps. while ixgbe(4) example is not ideal, i thought it still
was pretty readable :)

thanks,
max
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r241619 - head/sys/net

2012-10-16 Thread Maksim Yevmenkin
Author: emax
Date: Tue Oct 16 22:43:14 2012
New Revision: 241619
URL: http://svn.freebsd.org/changeset/base/241619

Log:
  report total number of ports for each lagg(4) interface
  via net.link.lagg.X.count sysctl
  
  MFC after:1  week

Modified:
  head/sys/net/if_lagg.c

Modified: head/sys/net/if_lagg.c
==
--- head/sys/net/if_lagg.c  Tue Oct 16 21:34:02 2012(r241618)
+++ head/sys/net/if_lagg.c  Tue Oct 16 22:43:14 2012(r241619)
@@ -288,6 +288,9 @@ lagg_clone_create(struct if_clone *ifc, 
SYSCTL_ADD_INT(sc-ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
use_flowid, CTLTYPE_INT|CTLFLAG_RW, sc-use_flowid, 
sc-use_flowid,
Use flow id for load sharing);
+   SYSCTL_ADD_INT(sc-ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
+   count, CTLTYPE_INT|CTLFLAG_RO, sc-sc_count, sc-sc_count,
+   Total number of ports);
/* Hash all layers by default */
sc-sc_flags = LAGG_F_HASHL2|LAGG_F_HASHL3|LAGG_F_HASHL4;
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r238622 - head/etc/rc.d

2012-08-03 Thread Maksim Yevmenkin
On Fri, Aug 3, 2012 at 1:17 AM, Andrey Zonov and...@zonov.org wrote:
 On 8/3/12 2:22 AM, Maksim Yevmenkin wrote:


 i just wanted to make sure that there is a way to absolutely make sure
 that there is no default address selection policy installed. the wide
 know rule 9 of rfc 3484 is really messing things up for dns-style load
 balancing. even when ipv6 is not used.

 Did you try an empty config file?

no, but it would not matter. please see my commit to libc, i.e.

http://svnweb.FreeBSD.org/base?view=revisionrevision=238599

before that, results were still sorted according to the rule 9. the
only hidden sorting that remains in libc is that if name resolution
contains both  and A records,  records are put before A
records, and, thus, get preferred. however, records order with in a
particular group ( or A) should be unchanged. application has
control over this by giving desired family to getaddrinfo(). it is
reasonable, imo, to return  records when application uses
AF_UNSPEC.

 Maksim, can you say more about this? Or point me to a reference that has
 the discussion?

 of course :) we have ipv4 systems in production that make use of
 getaddrinfo(3) api. when a particular dns name is resolved, and,
 multiple A records are returned, the results get sorted according to
 the default address selection policy. rfc3484 has a set of rules
 according to which results should be sorted. all of the rules do not
 apply in our case, except one - the rule #9. the idea is that ipv4
 addresses are converted to ipv6 addresses and then longest prefix
 match sorting is applied. in other words, if your system ip address
 happens to share high bits with the ip address from the A record, the
 IP address from the A record will always be preferred. of course,
 longest prefix match is performed  without any extra information such
 as netmask and/or cidr. it really is just matching high bits of the
 address.

 so, what we found out, is that some systems tend to favor a particular
 ip address (from a bunch of ip addresses returned by name resolution)
 because 4 high bits were the same. basically, round-robin dns was
 completely shot.


 RFC3484 completely breaks round-robin DNS.  It's clearly that rule #9 should
 not apply if resolved name has only A records.  That problem was discussed
 many times at ietf.org, but authors don't want to understand people.  For
 example, for us the problem will be huge when Windows users will update
 their systems.

yes, it does :) but it does not have to be :) yes, sometimes
application has to change, but it ok, imo.

 PS: It would be very useful to have a chance to turn off rule #9 in FreeBSD.

well, may be. my commits to libc and ip6addrctl rc script address our
particular problem and, hopefully, do not break things and/or
introduce unwanted/unexpected behavior

thanks
max
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r238622 - head/etc/rc.d

2012-08-02 Thread Maksim Yevmenkin
On Thu, Aug 2, 2012 at 1:55 PM, Hiroki Sato h...@freebsd.org wrote:
 Maksim Yevmenkin e...@freebsd.org wrote
   in 201207191536.q6jfabor094...@svn.freebsd.org:

 em Author: emax
 em Date: Thu Jul 19 15:36:36 2012
 em New Revision: 238622
 em URL: http://svn.freebsd.org/changeset/base/238622
 em
 em Log:
 em   Allow to specify no source-address-selection policy
 em
 em   MFC after:1 week
 em
 em Modified:
 em   head/etc/rc.d/ip6addrctl
 em
 em Modified: head/etc/rc.d/ip6addrctl
 em 
 ==
 em --- head/etc/rc.d/ip6addrctlThu Jul 19 14:43:46 2012
 (r238621)
 em +++ head/etc/rc.d/ip6addrctlThu Jul 19 15:36:36 2012
 (r238622)
 em @@ -83,6 +83,9 @@ ip6addrctl_start()
 em # Backward compatibility when ipv6_prefer=NO
 em ip6addrctl_prefer_ipv4
 em ;;
 em +   [Nn][Oo][Nn][Ee])
 em +   ip6addrctl flush /dev/null 21
 em +   ;;
 em *)
 em warn \$ip6addrctl_policy is invalid: ${ip6addrctl_policy}.  
 \
 em  \ipv4_prefer\ is used instead.

  Just curious, why ip6addrctl_enable=NO is not enough here?  I would
  like to eliminate yes/no/none keywords in $ip6addrctl_policy because
  such keywords are vague.  If we need the empty rule for some reason,
  empty would be a better name for the policy, I think.

i just wanted to make sure that there is a way to absolutely make sure
that there is no default address selection policy installed. the wide
know rule 9 of rfc 3484 is really messing things up for dns-style load
balancing. even when ipv6 is not used. personally, i don't think that
none is unreasonable word for ip6addrctl_policy, but i don't feel
particularly strongly about it. any name will do as long as original
functionality is preserved.

thanks,
max
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r238622 - head/etc/rc.d

2012-08-02 Thread Maksim Yevmenkin
On Thu, Aug 2, 2012 at 2:51 PM, Doug Barton do...@freebsd.org wrote:
 On 8/2/2012 2:25 PM, Maksim Yevmenkin wrote:
 On Thu, Aug 2, 2012 at 1:55 PM, Hiroki Sato h...@freebsd.org wrote:

  Just curious, why ip6addrctl_enable=NO is not enough here?

 Because the behavior of the script for =NO is to prefer v4.

  I would
  like to eliminate yes/no/none keywords in $ip6addrctl_policy because
  such keywords are vague.  If we need the empty rule for some reason,
  empty would be a better name for the policy, I think.

 Personally I think that the established meanings of yes and no are
 well understood, but I wouldn't object to emitting a warning for them to
 help the user make a more explicit selection.

 While we're at it, the way that the current script replicates the test
 for checkyesno in case is bogus, and should be changed. I had fixed this
 in the change set that you(hrs) backed out. To stick with the structure
 of the current script, something like this would work:

 http://people.freebsd.org/~dougb/ip6addrctl.diff

 That also brings in the warning described above.

 i just wanted to make sure that there is a way to absolutely make sure
 that there is no default address selection policy installed. the wide
 know rule 9 of rfc 3484 is really messing things up for dns-style load
 balancing. even when ipv6 is not used.

 Maksim, can you say more about this? Or point me to a reference that has
 the discussion?

of course :) we have ipv4 systems in production that make use of
getaddrinfo(3) api. when a particular dns name is resolved, and,
multiple A records are returned, the results get sorted according to
the default address selection policy. rfc3484 has a set of rules
according to which results should be sorted. all of the rules do not
apply in our case, except one - the rule #9. the idea is that ipv4
addresses are converted to ipv6 addresses and then longest prefix
match sorting is applied. in other words, if your system ip address
happens to share high bits with the ip address from the A record, the
IP address from the A record will always be preferred. of course,
longest prefix match is performed  without any extra information such
as netmask and/or cidr. it really is just matching high bits of the
address.

so, what we found out, is that some systems tend to favor a particular
ip address (from a bunch of ip addresses returned by name resolution)
because 4 high bits were the same. basically, round-robin dns was
completely shot.

 personally, i don't think that
 none is unreasonable word for ip6addrctl_policy, but i don't feel
 particularly strongly about it. any name will do as long as original
 functionality is preserved.

 I agree that none is reasonable, and is in line with other rc.d knobs.
 I would not object to empty being added as a synonym though.

 One request however, is this new knob documented in rc.conf.5? If not,
 can you do that please? :)

sure. i will try to do it later this week or early next week. thank
you for pointing it out.

thanks,
max
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r238622 - head/etc/rc.d

2012-07-19 Thread Maksim Yevmenkin
Author: emax
Date: Thu Jul 19 15:36:36 2012
New Revision: 238622
URL: http://svn.freebsd.org/changeset/base/238622

Log:
  Allow to specify no source-address-selection policy
  
  MFC after:1 week

Modified:
  head/etc/rc.d/ip6addrctl

Modified: head/etc/rc.d/ip6addrctl
==
--- head/etc/rc.d/ip6addrctlThu Jul 19 14:43:46 2012(r238621)
+++ head/etc/rc.d/ip6addrctlThu Jul 19 15:36:36 2012(r238622)
@@ -83,6 +83,9 @@ ip6addrctl_start()
# Backward compatibility when ipv6_prefer=NO
ip6addrctl_prefer_ipv4
;;
+   [Nn][Oo][Nn][Ee])
+   ip6addrctl flush /dev/null 21
+   ;;
*)
warn \$ip6addrctl_policy is invalid: ${ip6addrctl_policy}.  \
 \ipv4_prefer\ is used instead.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r238599 - head/lib/libc/net

2012-07-18 Thread Maksim Yevmenkin
Author: emax
Date: Wed Jul 18 15:52:09 2012
New Revision: 238599
URL: http://svn.freebsd.org/changeset/base/238599

Log:
  Return zero from get_addrselectpolicy() when no source-address-selection
  policy is installed.
  
  MFC after:1 week

Modified:
  head/lib/libc/net/getaddrinfo.c

Modified: head/lib/libc/net/getaddrinfo.c
==
--- head/lib/libc/net/getaddrinfo.c Wed Jul 18 15:43:47 2012
(r238598)
+++ head/lib/libc/net/getaddrinfo.c Wed Jul 18 15:52:09 2012
(r238599)
@@ -692,6 +692,8 @@ get_addrselectpolicy(struct policyhead *
 
if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, l, NULL, 0)  0)
return (0);
+   if (l == 0)
+   return (0);
if ((buf = malloc(l)) == NULL)
return (0);
if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), buf, l, NULL, 0)  0) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r236729 - head/sys/dev/ixgbe

2012-06-07 Thread Maksim Yevmenkin
Author: emax
Date: Thu Jun  7 22:57:26 2012
New Revision: 236729
URL: http://svn.freebsd.org/changeset/base/236729

Log:
  Correct typo(?) and actually set PTHRESH to 32 and not 16 as per Intel
  Linux driver 3.8.21.
  
  MFC after:1 week

Modified:
  head/sys/dev/ixgbe/ixgbe.c

Modified: head/sys/dev/ixgbe/ixgbe.c
==
--- head/sys/dev/ixgbe/ixgbe.c  Thu Jun  7 22:49:50 2012(r236728)
+++ head/sys/dev/ixgbe/ixgbe.c  Thu Jun  7 22:57:26 2012(r236729)
@@ -1152,7 +1152,7 @@ ixgbe_init_locked(struct adapter *adapte
 * from the Intel linux driver 3.8.21.
 * Prefetching enables tx line rate even with 1 queue.
 */
-   txdctl |= (16  0) | (1  8);
+   txdctl |= (32  0) | (1  8);
IXGBE_WRITE_REG(hw, IXGBE_TXDCTL(i), txdctl);
}
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r236729 - head/sys/dev/ixgbe

2012-06-07 Thread Maksim Yevmenkin
Jack,


On Thu, Jun 7, 2012 at 5:36 PM, Jack Vogel jfvo...@gmail.com wrote:
 Just because the Linux driver does something does not mean that FreeBSD
 should,
 this may be OK, but it isn't something automatic, and with a thing like this
 you should
 at least have asked me first... please next time?

oh... i'm sorry. i just went by the comment in the code that clearly
states where values were taken from and what they should be.
naturally, i assumed it was a typo. again, sorry about that. i will
double check next time.

thanks,
max
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r236693 - head/contrib/bsnmp/snmp_mibII

2012-06-06 Thread Maksim Yevmenkin
Author: emax
Date: Wed Jun  6 18:00:38 2012
New Revision: 236693
URL: http://svn.freebsd.org/changeset/base/236693

Log:
  Count both IPv4 and IPv6 TCP connections in tcpCurrEstab
  
  Timeout from: current, syrinx
  MFC after:1 week

Modified:
  head/contrib/bsnmp/snmp_mibII/mibII_tcp.c

Modified: head/contrib/bsnmp/snmp_mibII/mibII_tcp.c
==
--- head/contrib/bsnmp/snmp_mibII/mibII_tcp.c   Wed Jun  6 18:00:19 2012
(r236692)
+++ head/contrib/bsnmp/snmp_mibII/mibII_tcp.c   Wed Jun  6 18:00:38 2012
(r236693)
@@ -109,10 +109,12 @@ fetch_tcp(void)
  ptr = (struct xinpgen *)(void *)((char *)ptr + ptr-xig_len)) {
tp = (struct xtcpcb *)ptr;
if (tp-xt_inp.inp_gencnt  xinpgen-xig_gen ||
-   (tp-xt_inp.inp_vflag  INP_IPV4) == 0)
+   (tp-xt_inp.inp_vflag  (INP_IPV4|INP_IPV6)) == 0)
continue;
 
-   tcp_total++;
+   if (tp-xt_inp.inp_vflag  INP_IPV4)
+   tcp_total++;
+
if (tp-xt_tp.t_state == TCPS_ESTABLISHED ||
tp-xt_tp.t_state == TCPS_CLOSE_WAIT)
tcp_count++;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r236627 - head/sys/dev/ixgbe

2012-06-05 Thread Maksim Yevmenkin
Author: emax
Date: Tue Jun  5 18:48:02 2012
New Revision: 236627
URL: http://svn.freebsd.org/changeset/base/236627

Log:
  Before it gets lost in the noise.
  
  Put a bandaid to prevent ixgbe(4) from completely locking up the system
  under high load. Our platform has a few CPU cores and a single active
  ixgbe(4) port with 4 queues. Under high enough traffic load, at about
  7.5GBs and 700,000 packets/sec (outbound), the entire system would
  deadlock. What we found was that each CPU was in an endless loop on a
  different ix taskqueue thread. The OACTIVE flag had gotten set on each
  queue, and the ixgbe_handle_queue() function was continuously rescheduling
  itself via the taskqueue_enqueue. Since all CPUs were busy with their
  taskqueue threads, the ixgbe_local_timer() function couldn't run to clear
  the OACTIVE flag.
  
  Submitted by: scottl
  MFC after:1 week

Modified:
  head/sys/dev/ixgbe/ixgbe.c

Modified: head/sys/dev/ixgbe/ixgbe.c
==
--- head/sys/dev/ixgbe/ixgbe.c  Tue Jun  5 18:19:52 2012(r236626)
+++ head/sys/dev/ixgbe/ixgbe.c  Tue Jun  5 18:48:02 2012(r236627)
@@ -1368,7 +1368,7 @@ ixgbe_handle_que(void *context, int pend
ixgbe_start_locked(txr, ifp);
 #endif
IXGBE_TX_UNLOCK(txr);
-   if (more || (ifp-if_drv_flags  IFF_DRV_OACTIVE)) {
+   if (more) {
taskqueue_enqueue(que-tq, que-que_task);
return;
}
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r236644 - head/tools/tools/ifpifa

2012-06-05 Thread Maksim Yevmenkin
Author: emax
Date: Tue Jun  5 21:35:47 2012
New Revision: 236644
URL: http://svn.freebsd.org/changeset/base/236644

Log:
  Add a very simple debug tool that would dump list of interfaces,
  addresses on each interface, and, associated refcounter. I found
  it handy to check for address refcounter leaks.

Added:
  head/tools/tools/ifpifa/
  head/tools/tools/ifpifa/Makefile   (contents, props changed)
  head/tools/tools/ifpifa/ifpifa.c   (contents, props changed)

Added: head/tools/tools/ifpifa/Makefile
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/tools/ifpifa/MakefileTue Jun  5 21:35:47 2012
(r236644)
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+PROG=  ifpifa
+NO_MAN=
+WARNS?=6
+BINDIR?=/usr/local/bin
+DPADD=${LIBKVM}
+LDADD=-lkvm
+
+.include bsd.prog.mk

Added: head/tools/tools/ifpifa/ifpifa.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/tools/ifpifa/ifpifa.cTue Jun  5 21:35:47 2012
(r236644)
@@ -0,0 +1,190 @@
+/*-
+ * Copyright (c) 2012 maksim yevmenkin e...@freebsd.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* gcc -Wall -ggdb ifpifa.c -lkvm -o ifpifa */
+
+#include sys/types.h
+#include sys/callout.h
+#include sys/cdefs.h
+#include sys/param.h
+#include sys/protosw.h
+#include sys/queue.h
+#include sys/socket.h
+#include sys/socketvar.h
+
+#include net/if.h
+#include net/if_var.h
+#include net/if_dl.h
+#include net/if_types.h
+#include net/ethernet.h
+#include netinet/in.h
+#include netinet/in_var.h
+#include arpa/inet.h
+
+#include err.h
+#include fcntl.h
+#include kvm.h
+#include limits.h
+#include nlist.h
+#include stdio.h
+#include stdlib.h
+#include string.h
+
+__FBSDID($FreeBSD$);
+
+static struct nlistnl[] = {
+#define N_IFNET 0
+{ .n_name = _ifnet, },
+   { .n_name = NULL, },
+};
+
+static int
+kread(kvm_t *kd, u_long addr, char *buffer, int size)
+{
+   if (kd == NULL || buffer == NULL)
+   return (-1);
+ 
+   if (kvm_read(kd, addr, buffer, size) != size) {
+   warnx(kvm_read: %s, kvm_geterr(kd));
+   return (-1);
+   }
+ 
+   return (0);
+}
+
+int
+main(void)
+{
+   kvm_t *kd;
+   char errbuf[_POSIX2_LINE_MAX];
+   u_long ifnetaddr, ifnetaddr_next;
+   u_long ifaddraddr, ifaddraddr_next;
+struct ifnet ifnet;
+struct ifnethead ifnethead;
+union {
+   struct ifaddr ifa;
+   struct in_ifaddr in;
+   struct in6_ifaddr in6;
+} ifaddr;
+   union {
+   struct sockaddr *sa;
+   struct sockaddr_dl *sal;
+   struct sockaddr_in *sa4;
+   struct sockaddr_in6 *sa6;
+   } sa;
+   char addr[INET6_ADDRSTRLEN];
+
+   kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
+   if (kd == NULL) {
+   warnx(kvm_openfiles: %s, errbuf);
+   exit(0);
+   }
+
+   if (kvm_nlist(kd, nl)  0) {
+warnx(kvm_nlist: %s, kvm_geterr(kd));
+goto out;
+}
+
+   if (nl[N_IFNET].n_type == 0) {
+   warnx(kvm_nlist: no namelist);
+   goto out;
+   }
+
+   if (kread(kd, nl[N_IFNET].n_value,
+ (char *) ifnethead, sizeof(ifnethead)) != 0)
+   goto out;
+
+   for (ifnetaddr = (u_long) TAILQ_FIRST(ifnethead);
+ifnetaddr != 0;
+ifnetaddr = ifnetaddr_next) {
+   if (kread(kd, ifnetaddr, (char *) ifnet, sizeof(ifnet)) != 0

svn commit: r236645 - head/tools/tools/ifpifa

2012-06-05 Thread Maksim Yevmenkin
Author: emax
Date: Tue Jun  5 22:02:27 2012
New Revision: 236645
URL: http://svn.freebsd.org/changeset/base/236645

Log:
  Fix license
  
  Pointed by:   brueffer

Modified:
  head/tools/tools/ifpifa/ifpifa.c

Modified: head/tools/tools/ifpifa/ifpifa.c
==
--- head/tools/tools/ifpifa/ifpifa.cTue Jun  5 21:35:47 2012
(r236644)
+++ head/tools/tools/ifpifa/ifpifa.cTue Jun  5 22:02:27 2012
(r236645)
@@ -3,7 +3,7 @@
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
+ * modification, are permitted providing that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *notice, this list of conditions and the following disclaimer.
@@ -11,17 +11,17 @@
  *notice, this list of conditions and the following disclaimer in the
  *documentation and/or other materials provided with the distribution.
  *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
  */
 
 /* gcc -Wall -ggdb ifpifa.c -lkvm -o ifpifa */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r236575 - head/sys/netinet

2012-06-04 Thread Maksim Yevmenkin
Author: emax
Date: Mon Jun  4 18:43:51 2012
New Revision: 236575
URL: http://svn.freebsd.org/changeset/base/236575

Log:
  Plug more refcount leaks and possible NULL deref for interface
  address list.
  
  Submitted by: scottl@
  MFC after:3 days

Modified:
  head/sys/netinet/tcp_input.c

Modified: head/sys/netinet/tcp_input.c
==
--- head/sys/netinet/tcp_input.cMon Jun  4 18:17:09 2012
(r236574)
+++ head/sys/netinet/tcp_input.cMon Jun  4 18:43:51 2012
(r236575)
@@ -512,6 +512,8 @@ tcp6_input(struct mbuf **mp, int *offp, 
(caddr_t)ip6-ip6_dst - (caddr_t)ip6);
return IPPROTO_DONE;
}
+   if (ia6)
+   ifa_free(ia6-ia_ifa);
 
tcp_input(m, *offp);
return IPPROTO_DONE;
@@ -1240,7 +1242,8 @@ relocked:
rstreason = BANDLIM_RST_OPENPORT;
goto dropwithreset;
}
-   ifa_free(ia6-ia_ifa);
+   if (ia6)
+   ifa_free(ia6-ia_ifa);
}
 #endif /* INET6 */
/*
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r236501 - head/sys/netinet6

2012-06-03 Thread Maksim Yevmenkin
Author: emax
Date: Sun Jun  3 07:36:59 2012
New Revision: 236501
URL: http://svn.freebsd.org/changeset/base/236501

Log:
  Plug reference leak.
  
  Interface routes are refcounted as packets move through the stack,
  and there's garbage collection tied to it so that route changes can
  safely propagate while traffic is flowing. In our setup, we weren't
  changing or deleting any routes, but the refcounting logic in
  ip6_input() was wrong and caused a reference leak on every inbound
  V6 packet. This eventually caused a 32bit overflow, and the resulting
  0 value caused the garbage collection to run on the active route.
  That then snowballed into the panic.
  
  Reviewed by:  scottl
  MFC after:3 days

Modified:
  head/sys/netinet6/ip6_input.c

Modified: head/sys/netinet6/ip6_input.c
==
--- head/sys/netinet6/ip6_input.c   Sun Jun  3 06:57:47 2012
(r236500)
+++ head/sys/netinet6/ip6_input.c   Sun Jun  3 07:36:59 2012
(r236501)
@@ -879,19 +879,23 @@ passin:
 * as our interface address (e.g. multicast addresses, addresses
 * within FAITH prefixes and such).
 */
-   if (deliverifp  !ip6_getdstifaddr(m)) {
+   if (deliverifp) {
struct in6_ifaddr *ia6;
 
-   ia6 = in6_ifawithifp(deliverifp, ip6-ip6_dst);
-   if (ia6) {
-   if (!ip6_setdstifaddr(m, ia6)) {
-   /*
-* XXX maybe we should drop the packet here,
-* as we could not provide enough information
-* to the upper layers.
-*/
-   }
+   if ((ia6 = ip6_getdstifaddr(m)) != NULL) {
ifa_free(ia6-ia_ifa);
+   } else {
+   ia6 = in6_ifawithifp(deliverifp, ip6-ip6_dst);
+   if (ia6) {
+   if (!ip6_setdstifaddr(m, ia6)) {
+   /*
+* XXX maybe we should drop the packet 
here,
+* as we could not provide enough 
information
+* to the upper layers.
+*/
+   }
+   ifa_free(ia6-ia_ifa);
+   }
}
}
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r236327 - head/sys/netinet6

2012-05-30 Thread Maksim Yevmenkin
Author: emax
Date: Wed May 30 20:02:39 2012
New Revision: 236327
URL: http://svn.freebsd.org/changeset/base/236327

Log:
  When we return deprecated addresses, we need to reference them.
  
  Reviewed by:  bz, scottl
  MFC after:3 days

Modified:
  head/sys/netinet6/in6.c

Modified: head/sys/netinet6/in6.c
==
--- head/sys/netinet6/in6.c Wed May 30 19:21:54 2012(r236326)
+++ head/sys/netinet6/in6.c Wed May 30 20:02:39 2012(r236327)
@@ -2265,14 +2265,20 @@ in6_ifawithifp(struct ifnet *ifp, struct
IF_ADDR_RUNLOCK(ifp);
return (struct in6_ifaddr *)ifa;
}
-   IF_ADDR_RUNLOCK(ifp);
 
/* use the last-resort values, that are, deprecated addresses */
-   if (dep[0])
+   if (dep[0]) {
+   ifa_ref((struct ifaddr *)dep[0]);
+   IF_ADDR_RUNLOCK(ifp);
return dep[0];
-   if (dep[1])
+   }
+   if (dep[1]) {
+   ifa_ref((struct ifaddr *)dep[1]);
+   IF_ADDR_RUNLOCK(ifp);
return dep[1];
+   }
 
+   IF_ADDR_RUNLOCK(ifp);
return NULL;
 }
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r235854 - head/sys/vm

2012-05-23 Thread Maksim Yevmenkin
Author: emax
Date: Wed May 23 18:56:29 2012
New Revision: 235854
URL: http://svn.freebsd.org/changeset/base/235854

Log:
  Tweak condition for disabling allocation from per-CPU buckets in
  low memory situation. I've observed a situation where per-CPU
  allocations were disabled while there were enough free cached pages.
  Basically, cnt.v_free_count was sitting stable at a value lower
  than cnt.v_free_min and that caused massive performance drop.
  
  Reviewed by:  alc
  MFC after:1 week

Modified:
  head/sys/vm/uma_core.c

Modified: head/sys/vm/uma_core.c
==
--- head/sys/vm/uma_core.c  Wed May 23 18:41:45 2012(r235853)
+++ head/sys/vm/uma_core.c  Wed May 23 18:56:29 2012(r235854)
@@ -272,10 +272,7 @@ SYSCTL_PROC(_vm, OID_AUTO, zone_stats, C
 static void
 bucket_enable(void)
 {
-   if (cnt.v_free_count  cnt.v_free_min)
-   bucketdisable = 1;
-   else
-   bucketdisable = 0;
+   bucketdisable = vm_page_count_min();
 }
 
 /*
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r228939 - head/sys/dev/mps

2012-01-09 Thread Maksim Yevmenkin
2012/1/9 Alexander Motin m...@freebsd.org:
 On 09.01.2012 20:54, Maksim Yevmenkin wrote:

 On Wed, Dec 28, 2011 at 2:49 PM, Alexander Motinm...@freebsd.org  wrote:

 Author: mav
 Date: Wed Dec 28 22:49:28 2011
 New Revision: 228939
 URL: http://svn.freebsd.org/changeset/base/228939

 Log:
  Set maximum I/O size for mps(4) to MAXPHYS. Looking into the code, I see
  no reason why it should be limited to 64K of DFLTPHYS. DMA data tag is
 any
  way set to allow MAXPHYS, S/G lists (chain elements) are sufficient and
  overflows are also handled. On my tests even 1MB I/Os are working fine.

  Reviewed by:  ken@

 Modified:
  head/sys/dev/mps/mps_sas.c

 Modified: head/sys/dev/mps/mps_sas.c

 ==
 --- head/sys/dev/mps/mps_sas.c  Wed Dec 28 22:18:53 2011        (r228938)
 +++ head/sys/dev/mps/mps_sas.c  Wed Dec 28 22:49:28 2011        (r228939)
 @@ -937,6 +937,7 @@ mpssas_action(struct cam_sim *sim, union
                cpi-transport_version = 0;
                cpi-protocol = PROTO_SCSI;
                cpi-protocol_version = SCSI_REV_SPC;
 +               cpi-maxio = MAXPHYS;
                cpi-ccb_h.status = CAM_REQ_CMP;
                break;
        }


 sorry for the late reply, but can we make in into tunable please? i
 have in local tree

 --- mps_sas.c.orig      2011-11-17 02:05:04.0 -0800
 +++ mps_sas.c   2011-12-28 16:05:10.0 -0800
 @@ -121,6 +121,11 @@

  MALLOC_DEFINE(M_MPSSAS, MPSSAS, MPS SAS memory);

 +int mps_maxio = MAXPHYS;
 +TUNABLE_INT(hw.mps.maxio,mps_maxio);
 +SYSCTL_INT(_hw_mps, OID_AUTO, maxio, CTLFLAG_RD,mps_maxio, 0,

 +       CAM maxio override\n);
 +
  static __inline int mpssas_set_lun(uint8_t *lun, u_int ccblun);
  static struct mpssas_target * mpssas_alloc_target(struct mpssas_softc *,
      struct mpssas_target *);
 @@ -938,6 +943,7 @@
                cpi-protocol = PROTO_SCSI;
                cpi-protocol_version = SCSI_REV_SPC;
                cpi-ccb_h.status = CAM_REQ_CMP;
 +               cpi-maxio = mps_maxio;
                break;
        }
        case XPT_GET_TRAN_SETTINGS:


 We can. but could you explain why? Have you found any problems this change?

not really. i've had this patch in the local tree for a while now. we
are experimenting with various MAXPHYS/maxio settings and having this
tunable is very handy. basically, we can set MAXPHYS to some larger
value and tweak maxio (for testing purposes) without
recompiling/installing new kernel.

thanks,
max
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r228939 - head/sys/dev/mps

2012-01-09 Thread Maksim Yevmenkin
On Wed, Dec 28, 2011 at 2:49 PM, Alexander Motin m...@freebsd.org wrote:
 Author: mav
 Date: Wed Dec 28 22:49:28 2011
 New Revision: 228939
 URL: http://svn.freebsd.org/changeset/base/228939

 Log:
  Set maximum I/O size for mps(4) to MAXPHYS. Looking into the code, I see
  no reason why it should be limited to 64K of DFLTPHYS. DMA data tag is any
  way set to allow MAXPHYS, S/G lists (chain elements) are sufficient and
  overflows are also handled. On my tests even 1MB I/Os are working fine.

  Reviewed by:  ken@

 Modified:
  head/sys/dev/mps/mps_sas.c

 Modified: head/sys/dev/mps/mps_sas.c
 ==
 --- head/sys/dev/mps/mps_sas.c  Wed Dec 28 22:18:53 2011        (r228938)
 +++ head/sys/dev/mps/mps_sas.c  Wed Dec 28 22:49:28 2011        (r228939)
 @@ -937,6 +937,7 @@ mpssas_action(struct cam_sim *sim, union
                cpi-transport_version = 0;
                cpi-protocol = PROTO_SCSI;
                cpi-protocol_version = SCSI_REV_SPC;
 +               cpi-maxio = MAXPHYS;
                cpi-ccb_h.status = CAM_REQ_CMP;
                break;
        }

sorry for the late reply, but can we make in into tunable please? i
have in local tree

--- mps_sas.c.orig  2011-11-17 02:05:04.0 -0800
+++ mps_sas.c   2011-12-28 16:05:10.0 -0800
@@ -121,6 +121,11 @@

 MALLOC_DEFINE(M_MPSSAS, MPSSAS, MPS SAS memory);

+int mps_maxio = MAXPHYS;
+TUNABLE_INT(hw.mps.maxio, mps_maxio);
+SYSCTL_INT(_hw_mps, OID_AUTO, maxio, CTLFLAG_RD, mps_maxio, 0,
+   CAM maxio override\n);
+
 static __inline int mpssas_set_lun(uint8_t *lun, u_int ccblun);
 static struct mpssas_target * mpssas_alloc_target(struct mpssas_softc *,
 struct mpssas_target *);
@@ -938,6 +943,7 @@
cpi-protocol = PROTO_SCSI;
cpi-protocol_version = SCSI_REV_SPC;
cpi-ccb_h.status = CAM_REQ_CMP;
+   cpi-maxio = mps_maxio;
break;
}
case XPT_GET_TRAN_SETTINGS:

thanks,
max
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r228939 - head/sys/dev/mps

2012-01-09 Thread Maksim Yevmenkin
2012/1/9 Alexander Motin m...@freebsd.org:
 On 09.01.2012 21:01, Maksim Yevmenkin wrote:

 2012/1/9 Alexander Motinm...@freebsd.org:

 On 09.01.2012 20:54, Maksim Yevmenkin wrote:


 On Wed, Dec 28, 2011 at 2:49 PM, Alexander Motinm...@freebsd.org
  wrote:


 Author: mav
 Date: Wed Dec 28 22:49:28 2011
 New Revision: 228939
 URL: http://svn.freebsd.org/changeset/base/228939

 Log:
  Set maximum I/O size for mps(4) to MAXPHYS. Looking into the code, I
 see
  no reason why it should be limited to 64K of DFLTPHYS. DMA data tag is
 any
  way set to allow MAXPHYS, S/G lists (chain elements) are sufficient
 and
  overflows are also handled. On my tests even 1MB I/Os are working
 fine.

  Reviewed by:  ken@

 Modified:
  head/sys/dev/mps/mps_sas.c

 Modified: head/sys/dev/mps/mps_sas.c


 ==
 --- head/sys/dev/mps/mps_sas.c  Wed Dec 28 22:18:53 2011
  (r228938)
 +++ head/sys/dev/mps/mps_sas.c  Wed Dec 28 22:49:28 2011
  (r228939)
 @@ -937,6 +937,7 @@ mpssas_action(struct cam_sim *sim, union
                cpi-transport_version = 0;
                cpi-protocol = PROTO_SCSI;
                cpi-protocol_version = SCSI_REV_SPC;
 +               cpi-maxio = MAXPHYS;
                cpi-ccb_h.status = CAM_REQ_CMP;
                break;
        }



 sorry for the late reply, but can we make in into tunable please? i
 have in local tree

 --- mps_sas.c.orig      2011-11-17 02:05:04.0 -0800
 +++ mps_sas.c   2011-12-28 16:05:10.0 -0800
 @@ -121,6 +121,11 @@

  MALLOC_DEFINE(M_MPSSAS, MPSSAS, MPS SAS memory);

 +int mps_maxio = MAXPHYS;
 +TUNABLE_INT(hw.mps.maxio,mps_maxio);
 +SYSCTL_INT(_hw_mps, OID_AUTO, maxio, CTLFLAG_RD,mps_maxio, 0,

 +       CAM maxio override\n);
 +
  static __inline int mpssas_set_lun(uint8_t *lun, u_int ccblun);
  static struct mpssas_target * mpssas_alloc_target(struct mpssas_softc
 *,
      struct mpssas_target *);
 @@ -938,6 +943,7 @@
                cpi-protocol = PROTO_SCSI;
                cpi-protocol_version = SCSI_REV_SPC;
                cpi-ccb_h.status = CAM_REQ_CMP;
 +               cpi-maxio = mps_maxio;
                break;
        }
        case XPT_GET_TRAN_SETTINGS:



 We can. but could you explain why? Have you found any problems this
 change?


 not really. i've had this patch in the local tree for a while now. we
 are experimenting with various MAXPHYS/maxio settings and having this
 tunable is very handy. basically, we can set MAXPHYS to some larger
 value and tweak maxio (for testing purposes) without
 recompiling/installing new kernel.


 I don't really think that it is perfect place for such tunable. It is a bit
 strange IMHO to have different maxio for different types of HBAs except
 physical limitations. I would prefer it to be configurable on above layers,
 for example, file systems, if needed. But if you need it here for something,
 I won't object against adding it.

i'm not sure i understand your point. there certainly drivers that set
maxio to value smaller then MAXPHYS. sometimes comments in the code
clearly state that this is because of hardware limitation. in case of
mps(4) it was not clear at all which values are acceptable for maxio.
hence the tunable.

 Have you found any benefits of having maxio below MAXPHYS while
 experimenting? May be those results could be used to improve FS behavior
 somehow to make tuning not needed?

we believe so. fs tuning is under investigation as well.

thanks
max
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r221448 - head/usr.sbin/bluetooth/bthidd

2011-05-04 Thread Maksim Yevmenkin
Author: emax
Date: Wed May  4 17:58:15 2011
New Revision: 221448
URL: http://svn.freebsd.org/changeset/base/221448

Log:
  Encode horizontal scroll events (AC Pan) as button presses (bit 5 and 6)
  
  Submitted by: David Demelier demelier dot david at gmail dot com
  MFC after:1 week

Modified:
  head/usr.sbin/bluetooth/bthidd/hid.c

Modified: head/usr.sbin/bluetooth/bthidd/hid.c
==
--- head/usr.sbin/bluetooth/bthidd/hid.cWed May  4 17:56:53 2011
(r221447)
+++ head/usr.sbin/bluetooth/bthidd/hid.cWed May  4 17:58:15 2011
(r221448)
@@ -229,6 +229,17 @@ hid_interrupt(bthid_session_p s, uint8_t
break;
 
switch (usage) {
+   case HUC_AC_PAN:
+   /* Horizontal scroll */
+   if (val  0)
+   mouse_butt |= (1  5);
+   else
+   mouse_butt |= (1  6);
+
+   mevents ++;
+   val = 0;
+   break;
+
case 0xb5: /* Scan Next Track */
val = 0x19;
break;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r220840 - head/usr.sbin/bluetooth/l2control

2011-04-19 Thread Maksim Yevmenkin
Author: emax
Date: Tue Apr 19 16:21:57 2011
New Revision: 220840
URL: http://svn.freebsd.org/changeset/base/220840

Log:
  Improve the man page and l2control's usage() a bit.
  
  Submitted by: arundel
  MFC after:1 week

Modified:
  head/usr.sbin/bluetooth/l2control/l2control.8
  head/usr.sbin/bluetooth/l2control/l2control.c

Modified: head/usr.sbin/bluetooth/l2control/l2control.8
==
--- head/usr.sbin/bluetooth/l2control/l2control.8   Tue Apr 19 16:20:55 
2011(r220839)
+++ head/usr.sbin/bluetooth/l2control/l2control.8   Tue Apr 19 16:21:57 
2011(r220840)
@@ -25,7 +25,7 @@
 .\ $Id: l2control.8,v 1.5 2003/05/21 00:53:00 max Exp $
 .\ $FreeBSD$
 .\
-.Dd June 14, 2002
+.Dd April 9, 2011
 .Dt L2CONTROL 8
 .Os
 .Sh NAME
@@ -34,25 +34,27 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl hn
-.Fl a Ar BD_ADDR
+.Fl a Ar local
 .Ar command
 .Op Ar parameters ...
 .Sh DESCRIPTION
 The
 .Nm
-utility connects to the local device with the specified BD_ADDR and attempts
-to send the specified command.
+utility connects to the local device with the specified BD_ADDR or name
+and attempts to send the specified command.
 The
 .Nm
 utility will print results to the standard output and error messages to
-the standard error.
+the standard error output.
 .Pp
 The options are as follows:
 .Bl -tag -width indent
-.It Fl a Ar BD_ADDR
-Connect to the local device with the specified BD_ADDR.
+.It Fl a Ar local
+Connect to the local device with the specified BD_ADDR or name.
 Example:
-.Fl a Li 00:01:02:03:04:05 .
+.Fl a Li 00:01:02:03:04:05
+or
+.Fl a Li bt_device .
 .It Fl h
 Display usage message and exit.
 .It Fl n
@@ -62,10 +64,10 @@ Normally
 attempts to resolve Bluetooth addresses, and display them symbolically.
 .It Ar command
 One of the supported commands (see below).
-Special command
+The special command
 .Cm help
-can be used to obtain the list of all supported commands.
-To get more information about specific command use
+can be used to obtain a list of all supported commands.
+To get more information about a specific command use
 .Cm help Ar command .
 .It Ar parameters
 One or more optional space separated command parameters.
@@ -92,4 +94,4 @@ are:
 .Xr ng_l2cap 4 ,
 .Xr l2ping 8
 .Sh AUTHORS
-.An Maksim Yevmenkin Aq m_evmen...@yahoo.com
+.An Maksim Yevmenkin Aq e...@freebsd.org

Modified: head/usr.sbin/bluetooth/l2control/l2control.c
==
--- head/usr.sbin/bluetooth/l2control/l2control.c   Tue Apr 19 16:20:55 
2011(r220839)
+++ head/usr.sbin/bluetooth/l2control/l2control.c   Tue Apr 19 16:21:57 
2011(r220840)
@@ -207,7 +207,14 @@ print_l2cap_command(struct l2cap_command
 static void
 usage(void)
 {
-   fprintf(stdout, Usage: l2control -a BD_ADDR [-n] [-h] cmd [p1] 
[..]]\n);
+   fprintf(stderr, Usage: l2control [-hn] -a local cmd [params ..]\n);
+   fprintf(stderr, Where:\n);
+   fprintf(stderr,   -a local   Specify local device to connect to\n);
+   fprintf(stderr,   -h Display this message\n);
+   fprintf(stderr,   -n Show addresses as numbers\n);
+   fprintf(stderr,   cmdSupported command  \
+   (see l2control help)\n);
+   fprintf(stderr,   params Optional command parameters\n);
exit(255);
 } /* usage */
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r220116 - head/usr.sbin/bluetooth/l2ping

2011-03-28 Thread Maksim Yevmenkin
Author: emax
Date: Mon Mar 28 23:08:18 2011
New Revision: 220116
URL: http://svn.freebsd.org/changeset/base/220116

Log:
  Do not use word 'flood' as it not entirely correct. Use better 'no delay'
  description. While here, replace atoi(3) with strtol(3).
  
  Submitted by: arundel
  MFC after:1 week

Modified:
  head/usr.sbin/bluetooth/l2ping/l2ping.8
  head/usr.sbin/bluetooth/l2ping/l2ping.c

Modified: head/usr.sbin/bluetooth/l2ping/l2ping.8
==
--- head/usr.sbin/bluetooth/l2ping/l2ping.8 Mon Mar 28 22:50:02 2011
(r220115)
+++ head/usr.sbin/bluetooth/l2ping/l2ping.8 Mon Mar 28 23:08:18 2011
(r220116)
@@ -25,7 +25,7 @@
 .\ $Id: l2ping.8,v 1.3 2003/05/21 01:00:19 max Exp $
 .\ $FreeBSD$
 .\
-.Dd June 14, 2002
+.Dd March 29, 2011
 .Dt L2PING 8
 .Os
 .Sh NAME
@@ -36,7 +36,7 @@
 .Op Fl fhn
 .Fl a Ar remote
 .Op Fl c Ar count
-.Op Fl i Ar delay
+.Op Fl i Ar wait
 .Op Fl S Ar source
 .Op Fl s Ar size
 .Sh DESCRIPTION
@@ -63,8 +63,7 @@ If this option is not specified,
 .Nm
 will operate until interrupted.
 .It Fl f
-.Dq Flood
-ping, i.e., no delay between packets.
+Don't wait between sending each packet.
 .It Fl h
 Display usage message and exit.
 .It Fl i Ar wait
@@ -109,7 +108,7 @@ Some implementations may not like large 
 .Xr ng_l2cap 4 ,
 .Xr l2control 8
 .Sh AUTHORS
-.An Maksim Yevmenkin Aq m_evmen...@yahoo.com
+.An Maksim Yevmenkin Aq e...@freebsd.org
 .Sh BUGS
 Could collect more statistic.
 Could check for duplicated, corrupted and lost packets.

Modified: head/usr.sbin/bluetooth/l2ping/l2ping.c
==
--- head/usr.sbin/bluetooth/l2ping/l2ping.c Mon Mar 28 22:50:02 2011
(r220115)
+++ head/usr.sbin/bluetooth/l2ping/l2ping.c Mon Mar 28 23:08:18 2011
(r220116)
@@ -37,6 +37,7 @@
 #include bluetooth.h
 #include err.h
 #include errno.h
+#include limits.h
 #include stdio.h
 #include stdlib.h
 #include string.h
@@ -60,11 +61,11 @@ int
 main(int argc, char *argv[])
 {
bdaddr_t src, dst;
-   struct hostent  *he = NULL;
-   uint8_t *echo_data = NULL;
+   struct hostent  *he;
+   uint8_t *echo_data;
struct sockaddr_l2capsa;
int32_t  n, s, count, wait, flood, echo_size, numeric;
-   char*rname = NULL;
+   char*endp, *rname;
 
/* Set defaults */
memcpy(src, NG_HCI_BDADDR_ANY, sizeof(src));
@@ -100,8 +101,8 @@ main(int argc, char *argv[])
break;
 
case 'c':
-   count = atoi(optarg);
-   if (count = 0)
+   count = strtol(optarg, endp, 10);
+   if (count = 0 || *endp != '\0')
usage();
break;
 
@@ -110,8 +111,8 @@ main(int argc, char *argv[])
break;
 
case 'i':
-   wait = atoi(optarg);
-   if (wait = 0)
+   wait = strtol(optarg, endp, 10);
+   if (wait = 0 || *endp != '\0')
usage();
break;
 
@@ -129,9 +130,10 @@ main(int argc, char *argv[])
break;
 
case 's':
-   echo_size = atoi(optarg);
-   if (echo_size  sizeof(int32_t) ||
-   echo_size  NG_L2CAP_MAX_ECHO_SIZE)
+echo_size = strtol(optarg, endp, 10);
+if (echo_size  sizeof(int32_t) ||
+   echo_size  NG_L2CAP_MAX_ECHO_SIZE ||
+   *endp != '\0')
usage();
break;
 
@@ -272,12 +274,12 @@ tv2msec(struct timeval const *tvp)
 static void
 usage(void)
 {
-   fprintf(stderr, Usage: l2ping -a bd_addr  \
-   [-S bd_addr -c count -i wait -n -s size -h]\n);
+   fprintf(stderr, Usage: l2ping [-fhn] -a remote  \
+   [-c count] [-i wait] [-S source] [-s size]\n);
fprintf(stderr, Where:\n);
fprintf(stderr,   -a remote  Specify remote device to ping\n);
fprintf(stderr,   -c count   Number of packets to send\n);
-   fprintf(stderr,   -f No delay (sort of flood)\n);
+   fprintf(stderr,   -f No delay between packets\n);
fprintf(stderr,   -h Display this message\n);
fprintf(stderr,   -i waitDelay between packets (sec)\n);
fprintf(stderr,   -n Numeric output only\n);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r215195 - in head: etc usr.sbin/bluetooth usr.sbin/bluetooth/ath3kfw

2010-11-12 Thread Maksim Yevmenkin
Author: emax
Date: Fri Nov 12 19:43:12 2010
New Revision: 215195
URL: http://svn.freebsd.org/changeset/base/215195

Log:
  Add firmware downloader for Atheros AR3011 based USB Bluetooth devices.
  
  Hardware donated by:  Rusty Nejdl rnejdl at ringofsaturn dot com
  Tested by:Rusty Nejdl rnejdl at ringofsaturn dot com
  Tested by:Andrzej Tobola ato at iem dot pw dot edu dot pl
  MFC after:3 weeks

Added:
  head/usr.sbin/bluetooth/ath3kfw/
  head/usr.sbin/bluetooth/ath3kfw/Makefile   (contents, props changed)
  head/usr.sbin/bluetooth/ath3kfw/ath3kfw.8   (contents, props changed)
  head/usr.sbin/bluetooth/ath3kfw/ath3kfw.c   (contents, props changed)
Modified:
  head/etc/devd.conf
  head/usr.sbin/bluetooth/Makefile

Modified: head/etc/devd.conf
==
--- head/etc/devd.conf  Fri Nov 12 19:33:13 2010(r215194)
+++ head/etc/devd.conf  Fri Nov 12 19:43:12 2010(r215195)
@@ -97,6 +97,13 @@ detach 100 {
action /etc/rc.d/bluetooth quietstop $device-name;
 };
 
+# Firmware downloader for Atheros AR3011 based USB Bluetooth devices
+#attach 100 {
+#  match vendor 0x0cf3;
+#  match product 0x3000;
+#  action sleep 2  /usr/sbin/ath3kfw -d $device-name -f 
/usr/local/etc/ath3k-1.fw;
+#};
+
 # When a USB keyboard arrives, attach it as the console keyboard.
 attach 100 {
device-name ukbd0;

Modified: head/usr.sbin/bluetooth/Makefile
==
--- head/usr.sbin/bluetooth/MakefileFri Nov 12 19:33:13 2010
(r215194)
+++ head/usr.sbin/bluetooth/MakefileFri Nov 12 19:43:12 2010
(r215195)
@@ -2,6 +2,7 @@
 # $FreeBSD$
 
 SUBDIR= \
+   ath3kfw \
bcmfw \
bt3cfw \
bthidcontrol \

Added: head/usr.sbin/bluetooth/ath3kfw/Makefile
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.sbin/bluetooth/ath3kfw/MakefileFri Nov 12 19:43:12 2010
(r215195)
@@ -0,0 +1,9 @@
+# $FreeBSD$
+
+PROG=  ath3kfw
+MAN=   ath3kfw.8
+WARNS?=6
+DPADD+=${LIBUSB}
+LDADD+=-lusb
+
+.include bsd.prog.mk

Added: head/usr.sbin/bluetooth/ath3kfw/ath3kfw.8
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.sbin/bluetooth/ath3kfw/ath3kfw.8   Fri Nov 12 19:43:12 2010
(r215195)
@@ -0,0 +1,78 @@
+.\ Copyright (c) 2010 Maksim Yevmenkin m_evmen...@yahoo.com
+.\ All rights reserved.
+.\
+.\ Redistribution and use in source and binary forms, with or without
+.\ modification, are permitted provided that the following conditions
+.\ are met:
+.\ 1. Redistributions of source code must retain the above copyright
+.\notice, this list of conditions and the following disclaimer.
+.\ 2. Redistributions in binary form must reproduce the above copyright
+.\notice, this list of conditions and the following disclaimer in the
+.\documentation and/or other materials provided with the distribution.
+.\
+.\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\ SUCH DAMAGE.
+.\
+.\ $FreeBSD$
+.\
+.Dd Novermber 9, 2010
+.Dt ATH3KFW 8
+.Os
+.Sh NAME
+.Nm ath3kfw
+.Nd firmware download utility for Atheros AR3011 chip based Bluetooth USB 
devices
+.Sh SYNOPSIS
+.Nm
+.Fl d Ar device_name
+.Fl f Ar firmware_file_name
+.Nm
+.Fl h
+.Sh DESCRIPTION
+The
+.Nm
+utility downloads the specified firmware file to the specified
+.Xr ugen 4
+device.
+.Pp
+This utility will
+.Em only
+work with Atheros AR3011 chip based Bluetooth USB devices.
+The identification is currently based on USB vendor ID/product ID pair.
+The vendor ID should be 0x0cf3
+.Pq Dv USB_VENDOR_ATHEROS2
+and the product ID should be 0x3000.
+.Pp
+Firmware files ath3k-1.fw and ath3k-2.fw can be obtained from the
+linux-firmware RPM.
+.Pp
+The options are as follows:
+.Bl -tag -width indent
+.It Fl d Ar device_name
+Specify
+.Xr ugen 4 
+device name.
+.It Fl f Ar firmware_file_name
+Specify firmware file name for download.
+.It Fl h
+Display usage message and exit.
+.El

svn commit: r212335 - head/usr.sbin/bluetooth/bthidd

2010-09-08 Thread Maksim Yevmenkin
Author: emax
Date: Wed Sep  8 20:00:27 2010
New Revision: 212335
URL: http://svn.freebsd.org/changeset/base/212335

Log:
  Make sure to only pickup hid_input items when parsing input reports.
  As it turns out, libusbhid(3) also picks up hic_collection items even
  though we explicitly requested hid_input items only.
  
  Tested by:Buganini  buganini at gmail dot com 
  MFC after:1 week

Modified:
  head/usr.sbin/bluetooth/bthidd/hid.c

Modified: head/usr.sbin/bluetooth/bthidd/hid.c
==
--- head/usr.sbin/bluetooth/bthidd/hid.cWed Sep  8 20:00:15 2010
(r212334)
+++ head/usr.sbin/bluetooth/bthidd/hid.cWed Sep  8 20:00:27 2010
(r212335)
@@ -160,7 +160,8 @@ hid_interrupt(bthid_session_p s, uint8_t
 
for (d = hid_start_parse(hid_device-desc, 1  hid_input, -1);
 hid_get_item(d, h)  0; ) {
-   if ((h.flags  HIO_CONST) || (h.report_ID != report_id))
+   if ((h.flags  HIO_CONST) || (h.report_ID != report_id) ||
+   (h.kind != hid_input))
continue;
 
page = HID_PAGE(h.usage);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r212296 - head/usr.sbin/bluetooth/bthidcontrol

2010-09-07 Thread Maksim Yevmenkin
Author: emax
Date: Tue Sep  7 16:36:03 2010
New Revision: 212296
URL: http://svn.freebsd.org/changeset/base/212296

Log:
  Do not request SDP attributes using ranges.
  Apparently some devices do not like it.
  
  MFC after:1 week
  Tested by:Buganini  buganini at gmail dot com 

Modified:
  head/usr.sbin/bluetooth/bthidcontrol/sdp.c

Modified: head/usr.sbin/bluetooth/bthidcontrol/sdp.c
==
--- head/usr.sbin/bluetooth/bthidcontrol/sdp.c  Tue Sep  7 15:23:00 2010
(r212295)
+++ head/usr.sbin/bluetooth/bthidcontrol/sdp.c  Tue Sep  7 16:36:03 2010
(r212296)
@@ -54,7 +54,9 @@ SDP_ATTR_RANGE(   SDP_ATTR_PROTOCOL_DESCRI
 SDP_ATTR_RANGE (SDP_ATTR_ADDITIONAL_PROTOCOL_DESCRIPTOR_LISTS,
SDP_ATTR_ADDITIONAL_PROTOCOL_DESCRIPTOR_LISTS),
 SDP_ATTR_RANGE(0x0205, /* HIDReconnectInitiate */
-   0x0206),/* HIDDescriptorList */
+   0x0205),
+SDP_ATTR_RANGE(0x0206, /* HIDDescriptorList */
+   0x0206),
 SDP_ATTR_RANGE(0x0209, /* HIDBatteryPower */
0x0209),
 SDP_ATTR_RANGE(0x020d, /* HIDNormallyConnectable */
@@ -149,7 +151,7 @@ hid_sdp_query(bdaddr_t const *local, str
}
 
if (control_psm == -1 || interrupt_psm == -1 ||
-   reconnect_initiate == -1 || normally_connectable == -1 ||
+   reconnect_initiate == -1 ||
hid_descriptor == NULL || hid_descriptor_length == -1)
hid_sdp_query_exit(ENOATTR);
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r210783 - head/sys/netgraph/bluetooth/l2cap

2010-08-02 Thread Maksim Yevmenkin
Author: emax
Date: Mon Aug  2 22:26:08 2010
New Revision: 210783
URL: http://svn.freebsd.org/changeset/base/210783

Log:
  Fix typo
  
  PR:   kern/140590
  MFC after:3 days

Modified:
  head/sys/netgraph/bluetooth/l2cap/ng_l2cap_cmds.h

Modified: head/sys/netgraph/bluetooth/l2cap/ng_l2cap_cmds.h
==
--- head/sys/netgraph/bluetooth/l2cap/ng_l2cap_cmds.h   Mon Aug  2 21:33:36 
2010(r210782)
+++ head/sys/netgraph/bluetooth/l2cap/ng_l2cap_cmds.h   Mon Aug  2 22:26:08 
2010(r210783)
@@ -379,7 +379,7 @@ do {
\
break;  \
\
c = mtod((_m), struct _info_rsp *); \
-   c-hdr.code = NG_L2CAP_INFO_REQ;\
+   c-hdr.code = NG_L2CAP_INFO_RSP;\
c-hdr.ident = (_ident);\
c-hdr.length = sizeof(c-param);   \
\
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org