42 VLOG_DEFINE_THIS_MODULE(dpif_solaris); |
42 VLOG_DEFINE_THIS_MODULE(dpif_solaris); |
43 |
43 |
44 static kstat2_handle_t dpif_khandle; |
44 static kstat2_handle_t dpif_khandle; |
45 static boolean_t kstat2_handle_initialized = B_FALSE; |
45 static boolean_t kstat2_handle_initialized = B_FALSE; |
46 static struct ovs_mutex kstat_mutex = OVS_MUTEX_INITIALIZER; |
46 static struct ovs_mutex kstat_mutex = OVS_MUTEX_INITIALIZER; |
|
47 |
|
48 #ifndef MAC_OVS_AUX_DATA_VERSION |
|
49 /* Auxillary data from OVS if it wants to send packet directly out on a port */ |
|
50 typedef struct mac_ovs_aux_data_s { |
|
51 uint16_t moad_ofport; |
|
52 uint16_t moad_ofaction; |
|
53 mactun_info_t moad_tuninfo; |
|
54 } mac_ovs_aux_data_t; |
|
55 |
|
56 struct ovs_tpacket_auxdata { /* tp_macoff/tp_netoff */ |
|
57 tpkt_status_t tp_status; |
|
58 uint32_t tp_len; |
|
59 uint32_t tp_snaplen; |
|
60 uint16_t tp_macoff; |
|
61 uint16_t tp_netoff; |
|
62 uint16_t tp_vlan_vci; |
|
63 mac_ovs_aux_data_t tp_ovs_info; |
|
64 }; |
|
65 |
|
66 #define tpacket_auxdata ovs_tpacket_auxdata |
|
67 #define tp_of_action tp_ovs_info.moad_ofaction |
|
68 #define tp_of_port tp_ovs_info.moad_ofport |
|
69 #define tp_tun_info tp_ovs_info.moad_tuninfo |
|
70 #define tp_tun_type tp_ovs_info.moad_tuninfo.mti_type |
|
71 #define tp_tun_id tp_ovs_info.moad_tuninfo.mti_id |
|
72 #define tp_tun_dstip tp_ovs_info.moad_tuninfo.mti_dst |
|
73 #endif |
47 |
74 |
48 /* Datapath interface for the openvswitch Solaris kernel module. */ |
75 /* Datapath interface for the openvswitch Solaris kernel module. */ |
49 struct dpif_solaris { |
76 struct dpif_solaris { |
50 struct dpif dpif; |
77 struct dpif dpif; |
51 dladm_handle_t dh; |
78 dladm_handle_t dh; |
1848 struct ofpbuf *packet, struct flow_tnl *tnl, bool may_steal) |
1875 struct ofpbuf *packet, struct flow_tnl *tnl, bool may_steal) |
1849 { |
1876 { |
1850 struct msghdr msghdr; |
1877 struct msghdr msghdr; |
1851 struct iovec iov; |
1878 struct iovec iov; |
1852 struct cmsghdr *cmsg; |
1879 struct cmsghdr *cmsg; |
1853 struct tpacket_auxdata auxdata; |
1880 struct tpacket_auxdata auxdata; |
1854 char coutmsg[sizeof (auxdata) + sizeof (*cmsg) + _CMSG_HDR_ALIGNMENT]; |
1881 char coutmsg[sizeof (auxdata) + sizeof (*cmsg) + _CMSG_HDR_ALIGNMENT]; |
1855 size_t nwritten; |
1882 size_t nwritten; |
1856 ssize_t nbytes = 0; |
1883 ssize_t nbytes = 0; |
1857 const char *buf = ofpbuf_data(packet); |
1884 const char *buf = ofpbuf_data(packet); |
1858 size_t buflen = ofpbuf_size(packet); |
1885 size_t buflen = ofpbuf_size(packet); |
1883 cmsg->cmsg_type = PACKET_AUXDATA; |
1910 cmsg->cmsg_type = PACKET_AUXDATA; |
1884 cmsg->cmsg_len = CMSG_DATA(cmsg) + sizeof (auxdata) - (uchar_t *)cmsg; |
1911 cmsg->cmsg_len = CMSG_DATA(cmsg) + sizeof (auxdata) - (uchar_t *)cmsg; |
1885 |
1912 |
1886 memcpy(&auxdata, CMSG_DATA(cmsg), sizeof (auxdata)); |
1913 memcpy(&auxdata, CMSG_DATA(cmsg), sizeof (auxdata)); |
1887 auxdata.tp_of_port = port_no; |
1914 auxdata.tp_of_port = port_no; |
1888 #ifdef MAC_OVS_AUX_DATA_VERSION |
|
1889 auxdata.tp_tun_id = 0; |
1915 auxdata.tp_tun_id = 0; |
1890 IN6_IPADDR_TO_V4MAPPED(0, &auxdata.tp_tun_dstip); |
1916 IN6_IPADDR_TO_V4MAPPED(0, &auxdata.tp_tun_dstip); |
1891 if (tnl != NULL) { |
1917 if (tnl != NULL) { |
1892 auxdata.tp_tun_type = 0; |
1918 auxdata.tp_tun_type = 0; |
1893 auxdata.tp_tun_id = htonll(tnl->tun_id); |
1919 auxdata.tp_tun_id = htonll(tnl->tun_id); |
1894 IN6_IPADDR_TO_V4MAPPED(tnl->ip_dst, &auxdata.tp_tun_dstip); |
1920 IN6_IPADDR_TO_V4MAPPED(tnl->ip_dst, &auxdata.tp_tun_dstip); |
1895 } |
1921 } |
1896 #endif |
|
1897 memcpy(CMSG_DATA(cmsg), &auxdata, sizeof (auxdata)); |
1922 memcpy(CMSG_DATA(cmsg), &auxdata, sizeof (auxdata)); |
1898 for (nwritten = 0; nwritten < buflen; nwritten += nbytes) { |
1923 for (nwritten = 0; nwritten < buflen; nwritten += nbytes) { |
1899 nbytes = sendmsg(fd, &msghdr, 0); |
1924 nbytes = sendmsg(fd, &msghdr, 0); |
1900 if (nbytes == -1) { |
1925 if (nbytes == -1) { |
1901 if (errno != EAGAIN) { |
1926 if (errno != EAGAIN) { |