* [PATCH net-next 06/21] staging: Convert is_<foo>_ether_addr uses to eth_addr_<foo>
From: Joe Perches @ 2012-10-19 4:14 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel
In-Reply-To: <cover.1350618006.git.joe@perches.com>
Convert the old ether_addr tests to eth_addr_<foo>.
Adds api consistency.
Signed-off-by: Joe Perches <joe@perches.com>
---
drivers/staging/ccg/u_ether.c | 6 +++---
drivers/staging/csr/sme_wext.c | 2 +-
drivers/staging/et131x/et131x.c | 4 ++--
drivers/staging/gdm72xx/gdm_wimax.c | 2 +-
drivers/staging/octeon/ethernet.c | 2 +-
drivers/staging/ozwpan/ozcdev.c | 2 +-
.../rtl8187se/ieee80211/ieee80211_softmac.c | 2 +-
.../rtl8187se/ieee80211/ieee80211_softmac_wx.c | 2 +-
drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c | 2 +-
drivers/staging/rtl8187se/r8180_core.c | 2 +-
drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 6 +++---
drivers/staging/rtl8192e/rtl819x_TSProc.c | 2 +-
drivers/staging/rtl8192e/rtllib_rx.c | 8 ++++----
drivers/staging/rtl8192e/rtllib_softmac.c | 4 ++--
drivers/staging/rtl8192e/rtllib_softmac_wx.c | 4 ++--
drivers/staging/rtl8192e/rtllib_tx.c | 12 ++++++------
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 4 ++--
.../staging/rtl8192u/ieee80211/ieee80211_softmac.c | 2 +-
.../rtl8192u/ieee80211/ieee80211_softmac_wx.c | 2 +-
drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c | 12 ++++++------
.../staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 2 +-
drivers/staging/rtl8192u/r8192U_core.c | 8 ++++----
drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 2 +-
drivers/staging/rtl8712/rtl871x_ioctl_set.c | 2 +-
drivers/staging/rtl8712/rtl871x_mlme.c | 2 +-
drivers/staging/rtl8712/rtl871x_recv.c | 8 ++++----
drivers/staging/slicoss/slicoss.c | 2 +-
drivers/staging/vt6655/bssdb.c | 2 +-
drivers/staging/vt6655/card.c | 2 +-
drivers/staging/vt6655/device_main.c | 2 +-
drivers/staging/vt6655/dpc.c | 4 ++--
drivers/staging/vt6655/hostap.c | 4 ++--
drivers/staging/vt6655/iwctl.c | 2 +-
drivers/staging/vt6655/key.c | 2 +-
drivers/staging/vt6655/mib.c | 8 ++++----
drivers/staging/vt6655/rxtx.c | 10 +++++-----
drivers/staging/vt6655/wpactl.c | 4 ++--
drivers/staging/vt6656/bssdb.c | 2 +-
drivers/staging/vt6656/dpc.c | 4 ++--
drivers/staging/vt6656/hostap.c | 4 ++--
drivers/staging/vt6656/iwctl.c | 2 +-
drivers/staging/vt6656/key.c | 2 +-
drivers/staging/vt6656/rxtx.c | 14 +++++++-------
drivers/staging/vt6656/wpactl.c | 2 +-
drivers/staging/wlags49_h2/wl_wext.c | 2 +-
45 files changed, 90 insertions(+), 90 deletions(-)
diff --git a/drivers/staging/ccg/u_ether.c b/drivers/staging/ccg/u_ether.c
index d0dabcf..0f1a1b7 100644
--- a/drivers/staging/ccg/u_ether.c
+++ b/drivers/staging/ccg/u_ether.c
@@ -509,13 +509,13 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb,
if (!is_promisc(cdc_filter)) {
u8 *dest = skb->data;
- if (is_multicast_ether_addr(dest)) {
+ if (eth_addr_multicast(dest)) {
u16 type;
/* ignores USB_CDC_PACKET_TYPE_MULTICAST and host
* SET_ETHERNET_MULTICAST_FILTERS requests
*/
- if (is_broadcast_ether_addr(dest))
+ if (eth_addr_broadcast(dest))
type = USB_CDC_PACKET_TYPE_BROADCAST;
else
type = USB_CDC_PACKET_TYPE_ALL_MULTICAST;
@@ -714,7 +714,7 @@ static int get_ether_addr(const char *str, u8 *dev_addr)
num |= hex_to_bin(*str++);
dev_addr [i] = num;
}
- if (is_valid_ether_addr(dev_addr))
+ if (eth_addr_valid(dev_addr))
return 0;
}
eth_random_addr(dev_addr);
diff --git a/drivers/staging/csr/sme_wext.c b/drivers/staging/csr/sme_wext.c
index b58c0c6..0aea381 100644
--- a/drivers/staging/csr/sme_wext.c
+++ b/drivers/staging/csr/sme_wext.c
@@ -1211,7 +1211,7 @@ unifi_siwap(struct net_device *dev, struct iw_request_info *info,
unifi_trace(priv, UDBG1, "unifi_siwap: asked for %pM\n",
wrqu->ap_addr.sa_data);
- if (is_zero_ether_addr(wrqu->ap_addr.sa_data)) {
+ if (eth_addr_zero(wrqu->ap_addr.sa_data)) {
priv->ignore_bssid_join = FALSE;
err = sme_mgt_disconnect(priv);
if (err) {
diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c
index 413da0d..90c8e86 100644
--- a/drivers/staging/et131x/et131x.c
+++ b/drivers/staging/et131x/et131x.c
@@ -3955,7 +3955,7 @@ static void et131x_hwaddr_init(struct et131x_adapter *adapter)
* EEPROM then we need to generate the last octet and set it on the
* device
*/
- if (is_zero_ether_addr(adapter->rom_addr)) {
+ if (eth_addr_zero(adapter->rom_addr)) {
/*
* We need to randomly generate the last octet so we
* decrease our chances of setting the mac address to
@@ -5156,7 +5156,7 @@ static int et131x_set_mac_addr(struct net_device *netdev, void *new_mac)
return -ENODEV;
/* Make sure the requested MAC is valid */
- if (!is_valid_ether_addr(address->sa_data))
+ if (!eth_addr_valid(address->sa_data))
return -EADDRNOTAVAIL;
et131x_disable_txrx(netdev);
diff --git a/drivers/staging/gdm72xx/gdm_wimax.c b/drivers/staging/gdm72xx/gdm_wimax.c
index 6cb8107..5a00ff6 100644
--- a/drivers/staging/gdm72xx/gdm_wimax.c
+++ b/drivers/staging/gdm72xx/gdm_wimax.c
@@ -489,7 +489,7 @@ static int gdm_wimax_set_mac_addr(struct net_device *dev, void *p)
if (netif_running(dev))
return -EBUSY;
- if (!is_valid_ether_addr(addr->sa_data))
+ if (!eth_addr_valid(addr->sa_data))
return -EADDRNOTAVAIL;
__gdm_wimax_set_mac_addr(dev, addr->sa_data);
diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
index 683bedc..496351f 100644
--- a/drivers/staging/octeon/ethernet.c
+++ b/drivers/staging/octeon/ethernet.c
@@ -453,7 +453,7 @@ int cvm_oct_common_init(struct net_device *dev)
if (priv->of_node)
mac = of_get_mac_address(priv->of_node);
- if (mac && is_valid_ether_addr(mac)) {
+ if (mac && eth_addr_valid(mac)) {
memcpy(dev->dev_addr, mac, ETH_ALEN);
dev->addr_assign_type &= ~NET_ADDR_RANDOM;
} else {
diff --git a/drivers/staging/ozwpan/ozcdev.c b/drivers/staging/ozwpan/ozcdev.c
index 64913ae..b2cf3b4 100644
--- a/drivers/staging/ozwpan/ozcdev.c
+++ b/drivers/staging/ozwpan/ozcdev.c
@@ -214,7 +214,7 @@ static int oz_set_active_pd(u8 *addr)
if (old_pd)
oz_pd_put(old_pd);
} else {
- if (is_zero_ether_addr(addr)) {
+ if (eth_addr_zero(addr)) {
spin_lock_bh(&g_cdev.lock);
pd = g_cdev.active_pd;
g_cdev.active_pd = 0;
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
index 00f9af0..15fd4f4 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
@@ -2803,7 +2803,7 @@ static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee,
param->u.crypt.key_len);
return -EINVAL;
}
- if (is_broadcast_ether_addr(param->sta_addr)) {
+ if (eth_addr_broadcast(param->sta_addr)) {
if (param->u.crypt.idx >= WEP_KEYS)
return -EINVAL;
crypt = &ieee->crypt[param->u.crypt.idx];
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c
index 1ef8fd6..ad23eb5 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c
@@ -162,7 +162,7 @@ int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
spin_lock_irqsave(&ieee->lock, flags);
memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN);
- ieee->wap_set = !is_zero_ether_addr(temp->sa_data);
+ ieee->wap_set = !eth_addr_zero(temp->sa_data);
//printk(" %x:%x:%x:%x:%x:%x\n", ieee->current_network.bssid[0],ieee->current_network.bssid[1],ieee->current_network.bssid[2],ieee->current_network.bssid[3],ieee->current_network.bssid[4],ieee->current_network.bssid[5]);
spin_unlock_irqrestore(&ieee->lock, flags);
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c
index 89ed86e..b281c8d 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c
@@ -413,7 +413,7 @@ int ieee80211_rtl_xmit(struct sk_buff *skb,
/* Determine fragmentation size based on destination (multicast
* and broadcast are not fragmented) */
- if (is_multicast_ether_addr(header.addr1)) {
+ if (eth_addr_multicast(header.addr1)) {
frag_size = MAX_FRAG_THRESHOLD;
qos_ctl = QOS_CTL_NOTCONTAIN_ACK;
}
diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c
index 20e5fb5..b439dd5 100644
--- a/drivers/staging/rtl8187se/r8180_core.c
+++ b/drivers/staging/rtl8187se/r8180_core.c
@@ -2003,7 +2003,7 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority,
}
memcpy(&dest, frag_hdr->addr1, ETH_ALEN);
- if (is_multicast_ether_addr(dest)) {
+ if (eth_addr_multicast(dest)) {
Duration = 0;
RtsDur = 0;
bRTSEnable = 0;
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
index 81134d3..8da56f4 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -2023,9 +2023,9 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
stype = WLAN_FC_GET_STYPE(fc);
pda_addr = header->addr1;
- if (is_broadcast_ether_addr(pda_addr))
+ if (eth_addr_broadcast(pda_addr))
broad_addr = true;
- else if (is_multicast_ether_addr(pda_addr))
+ else if (eth_addr_multicast(pda_addr))
multi_addr = true;
else
uni_addr = true;
@@ -2357,7 +2357,7 @@ static void rtl8192_rx_normal(struct net_device *dev)
stats.RxBufShift);
skb_trim(skb, skb->len - 4/*sCrcLng*/);
rtllib_hdr = (struct rtllib_hdr_1addr *)skb->data;
- if (!is_multicast_ether_addr(rtllib_hdr->addr1)) {
+ if (!eth_addr_multicast(rtllib_hdr->addr1)) {
/* unicast packet */
unicast_packet = true;
}
diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c
index 658e875..ebd3349 100644
--- a/drivers/staging/rtl8192e/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c
@@ -310,7 +310,7 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS,
u8 *Addr, u8 TID, enum tr_select TxRxSelect, bool bAddNewTs)
{
u8 UP = 0;
- if (is_multicast_ether_addr(Addr)) {
+ if (eth_addr_multicast(Addr)) {
RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR! get TS for Broadcast or "
"Multicast\n");
return false;
diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c
index 8b8a5c6..8d13ace 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -1000,7 +1000,7 @@ static int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc,
return -1;
/* {broad,multi}cast packets to our BSS go through */
- if (is_multicast_ether_addr(dst)) {
+ if (eth_addr_multicast(dst)) {
if (memcmp(bssid, ieee->current_network.bssid, ETH_ALEN))
return -1;
}
@@ -1230,7 +1230,7 @@ static void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee,
ieee->stats.rx_packets++;
ieee->stats.rx_bytes += sub_skb->len;
- if (is_multicast_ether_addr(dst))
+ if (eth_addr_multicast(dst))
ieee->stats.multicast++;
/* Indicate the packets to upper layer */
@@ -1269,7 +1269,7 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,
sc = le16_to_cpu(hdr->seq_ctl);
/*Filter pkt not to me*/
- multicast = is_multicast_ether_addr(hdr->addr1);
+ multicast = eth_addr_multicast(hdr->addr1);
unicast = !multicast;
if (unicast && (compare_ether_addr(dev->dev_addr, hdr->addr1) != 0)) {
if (ieee->bNetPromiscuousMode)
@@ -1350,7 +1350,7 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,
/* Get TS for Rx Reorder */
hdr = (struct rtllib_hdr_4addr *) skb->data;
if (ieee->current_network.qos_data.active && IsQoSDataFrame(skb->data)
- && !is_multicast_ether_addr(hdr->addr1)
+ && !eth_addr_multicast(hdr->addr1)
&& (!bToOtherSTA)) {
TID = Frame_QoSTID(skb->data);
SeqNum = WLAN_GET_SEQ_SEQ(sc);
diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c
index 4feecec..a8d0931 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac.c
@@ -1844,7 +1844,7 @@ static short probe_rq_parse(struct rtllib_device *ieee, struct sk_buff *skb,
bssid_match =
(memcmp(header->addr3, ieee->current_network.bssid, ETH_ALEN) != 0) &&
- (!is_broadcast_ether_addr(header->addr3));
+ (!eth_addr_broadcast(header->addr3));
if (bssid_match)
return -1;
@@ -3356,7 +3356,7 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee,
param->u.crypt.key_len);
return -EINVAL;
}
- if (is_broadcast_ether_addr(param->sta_addr)) {
+ if (eth_addr_broadcast(param->sta_addr)) {
if (param->u.crypt.idx >= NUM_WEP_KEYS)
return -EINVAL;
crypt = &ieee->crypt_info.crypt[param->u.crypt.idx];
diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
index 740cf85..b870df5 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
@@ -158,7 +158,7 @@ int rtllib_wx_set_wap(struct rtllib_device *ieee,
goto out;
}
- if (is_zero_ether_addr(temp->sa_data)) {
+ if (eth_addr_zero(temp->sa_data)) {
spin_lock_irqsave(&ieee->lock, flags);
memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN);
ieee->wap_set = 0;
@@ -178,7 +178,7 @@ int rtllib_wx_set_wap(struct rtllib_device *ieee,
ieee->cannot_notify = false;
memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN);
- ieee->wap_set = !is_zero_ether_addr(temp->sa_data);
+ ieee->wap_set = !eth_addr_zero(temp->sa_data);
spin_unlock_irqrestore(&ieee->lock, flags);
diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c
index 42900ee..a843560 100644
--- a/drivers/staging/rtl8192e/rtllib_tx.c
+++ b/drivers/staging/rtl8192e/rtllib_tx.c
@@ -296,7 +296,7 @@ static void rtllib_tx_query_agg_cap(struct rtllib_device *ieee,
return;
if (!IsQoSDataFrame(skb->data))
return;
- if (is_multicast_ether_addr(hdr->addr1))
+ if (eth_addr_multicast(hdr->addr1))
return;
if (tcb_desc->bdhcp || ieee->CntAfterLink < 2)
@@ -423,7 +423,7 @@ static void rtllib_query_protectionmode(struct rtllib_device *ieee,
if (tcb_desc->bBroadcast || tcb_desc->bMulticast)
return;
- if (is_broadcast_ether_addr(skb->data+16))
+ if (eth_addr_broadcast(skb->data+16))
return;
if (ieee->mode < IEEE_N_24G) {
@@ -514,7 +514,7 @@ u16 rtllib_query_seqnum(struct rtllib_device *ieee, struct sk_buff *skb,
{
u16 seqnum = 0;
- if (is_multicast_ether_addr(dst))
+ if (eth_addr_multicast(dst))
return 0;
if (IsQoSDataFrame(skb->data)) {
struct tx_ts_record *pTS = NULL;
@@ -697,7 +697,7 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
ETH_ALEN);
}
- bIsMulticast = is_multicast_ether_addr(header.addr1);
+ bIsMulticast = eth_addr_multicast(header.addr1);
header.frame_ctl = cpu_to_le16(fc);
@@ -897,9 +897,9 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
tcb_desc->RATRIndex = 7;
tcb_desc->bTxUseDriverAssingedRate = 1;
} else {
- if (is_multicast_ether_addr(header.addr1))
+ if (eth_addr_multicast(header.addr1))
tcb_desc->bMulticast = 1;
- if (is_broadcast_ether_addr(header.addr1))
+ if (eth_addr_broadcast(header.addr1))
tcb_desc->bBroadcast = 1;
rtllib_txrate_selectmode(ieee, tcb_desc);
if (tcb_desc->bMulticast || tcb_desc->bBroadcast)
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
index e3cf7a4..5b89789 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
@@ -1285,7 +1285,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
*/
//added by amy for reorder
if(ieee->current_network.qos_data.active && IsQoSDataFrame(skb->data)
- && !is_multicast_ether_addr(hdr->addr1))
+ && !eth_addr_multicast(hdr->addr1))
{
TID = Frame_QoSTID(skb->data);
SeqNum = WLAN_GET_SEQ_SEQ(sc);
@@ -1346,7 +1346,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
stats->rx_packets++;
stats->rx_bytes += sub_skb->len;
- if(is_multicast_ether_addr(dst)) {
+ if(eth_addr_multicast(dst)) {
stats->multicast++;
}
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
index 7a07078..7c74ce39 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
@@ -2965,7 +2965,7 @@ static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee,
param->u.crypt.key_len);
return -EINVAL;
}
- if (is_broadcast_ether_addr(param->sta_addr)) {
+ if (eth_addr_broadcast(param->sta_addr)) {
if (param->u.crypt.idx >= WEP_KEYS)
return -EINVAL;
crypt = &ieee->crypt[param->u.crypt.idx];
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c
index 421da8a..c1f92b8 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c
@@ -166,7 +166,7 @@ int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
spin_lock_irqsave(&ieee->lock, flags);
memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN);
- ieee->wap_set = !is_zero_ether_addr(temp->sa_data);
+ ieee->wap_set = !eth_addr_zero(temp->sa_data);
spin_unlock_irqrestore(&ieee->lock, flags);
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
index 3f5ceeb..0c11c99 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
@@ -314,7 +314,7 @@ void ieee80211_tx_query_agg_cap(struct ieee80211_device* ieee, struct sk_buff* s
if (!IsQoSDataFrame(skb->data))
return;
- if (is_multicast_ether_addr(hdr->addr1))
+ if (eth_addr_multicast(hdr->addr1))
return;
//check packet and mode later
#ifdef TO_DO_LIST
@@ -444,7 +444,7 @@ void ieee80211_query_protectionmode(struct ieee80211_device* ieee, cb_desc* tcb_
if(tcb_desc->bBroadcast || tcb_desc->bMulticast)//only unicast frame will use rts/cts
return;
- if (is_broadcast_ether_addr(skb->data+16)) //check addr3 as infrastructure add3 is DA.
+ if (eth_addr_broadcast(skb->data+16)) //check addr3 as infrastructure add3 is DA.
return;
if (ieee->mode < IEEE_N_24G) //b, g mode
@@ -575,7 +575,7 @@ void ieee80211_txrate_selectmode(struct ieee80211_device* ieee, cb_desc* tcb_des
void ieee80211_query_seqnum(struct ieee80211_device*ieee, struct sk_buff* skb, u8* dst)
{
- if (is_multicast_ether_addr(dst))
+ if (eth_addr_multicast(dst))
return;
if (IsQoSDataFrame(skb->data)) //we deal qos data only
{
@@ -693,7 +693,7 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
/* Determine fragmentation size based on destination (multicast
* and broadcast are not fragmented) */
- if (is_multicast_ether_addr(header.addr1)) {
+ if (eth_addr_multicast(header.addr1)) {
frag_size = MAX_FRAG_THRESHOLD;
qos_ctl |= QOS_CTL_NOTCONTAIN_ACK;
}
@@ -863,9 +863,9 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
{
cb_desc *tcb_desc = (cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE);
tcb_desc->bTxEnableFwCalcDur = 1;
- if (is_multicast_ether_addr(header.addr1))
+ if (eth_addr_multicast(header.addr1))
tcb_desc->bMulticast = 1;
- if (is_broadcast_ether_addr(header.addr1))
+ if (eth_addr_broadcast(header.addr1))
tcb_desc->bBroadcast = 1;
ieee80211_txrate_selectmode(ieee, tcb_desc);
if ( tcb_desc->bMulticast || tcb_desc->bBroadcast)
diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
index 06a9824..cde11e9 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
@@ -350,7 +350,7 @@ bool GetTs(
// We do not build any TS for Broadcast or Multicast stream.
// So reject these kinds of search here.
//
- if (is_multicast_ether_addr(Addr))
+ if (eth_addr_multicast(Addr))
{
IEEE80211_DEBUG(IEEE80211_DL_ERR, "get TS for Broadcast or Multicast\n");
return false;
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 5a2fab9..74797dc 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -5475,9 +5475,9 @@ void rtl8192_rx_nomal(struct sk_buff* skb)
rx_pkt_len = skb->len;
ieee80211_hdr = (struct ieee80211_hdr_1addr *)skb->data;
unicast_packet = false;
- if(is_broadcast_ether_addr(ieee80211_hdr->addr1)) {
+ if(eth_addr_broadcast(ieee80211_hdr->addr1)) {
//TODO
- }else if(is_multicast_ether_addr(ieee80211_hdr->addr1)){
+ }else if(eth_addr_multicast(ieee80211_hdr->addr1)){
//TODO
}else {
/* unicast packet */
@@ -5535,9 +5535,9 @@ void rtl8192_rx_nomal(struct sk_buff* skb)
rx_pkt_len = skb->len;
ieee80211_hdr = (struct ieee80211_hdr_1addr *)skb->data;
unicast_packet = false;
- if(is_broadcast_ether_addr(ieee80211_hdr->addr1)) {
+ if(eth_addr_broadcast(ieee80211_hdr->addr1)) {
//TODO
- }else if(is_multicast_ether_addr(ieee80211_hdr->addr1)){
+ }else if(eth_addr_multicast(ieee80211_hdr->addr1)){
//TODO
}else {
/* unicast packet */
diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
index c9a6a7f..703e545 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -407,7 +407,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
if (param_len != (u32)((u8 *) param->u.crypt.key - (u8 *)param) +
param->u.crypt.key_len)
return -EINVAL;
- if (is_broadcast_ether_addr(param->sta_addr)) {
+ if (eth_addr_broadcast(param->sta_addr)) {
if (param->u.crypt.idx >= WEP_KEYS) {
/* for large key indices, set the default (0) */
param->u.crypt.idx = 0;
diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_set.c b/drivers/staging/rtl8712/rtl871x_ioctl_set.c
index d3ab24e..6a9aab6 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_set.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_set.c
@@ -131,7 +131,7 @@ u8 r8712_set_802_11_bssid(struct _adapter *padapter, u8 *bssid)
u8 status = true;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
- if (is_zero_ether_addr(bssid) || is_broadcast_ether_addr(bssid)) {
+ if (eth_addr_zero(bssid) || eth_addr_broadcast(bssid)) {
status = false;
return status;
}
diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c
index c51ad9e..5c4d550 100644
--- a/drivers/staging/rtl8712/rtl871x_mlme.c
+++ b/drivers/staging/rtl8712/rtl871x_mlme.c
@@ -149,7 +149,7 @@ static struct wlan_network *_r8712_find_network(struct __queue *scanned_queue,
struct list_head *phead, *plist;
struct wlan_network *pnetwork = NULL;
- if (is_zero_ether_addr(addr))
+ if (eth_addr_zero(addr))
return NULL;
spin_lock_irqsave(&scanned_queue->lock, irqL);
phead = get_list_head(scanned_queue);
diff --git a/drivers/staging/rtl8712/rtl871x_recv.c b/drivers/staging/rtl8712/rtl871x_recv.c
index 23ec684..37702e3 100644
--- a/drivers/staging/rtl8712/rtl871x_recv.c
+++ b/drivers/staging/rtl8712/rtl871x_recv.c
@@ -332,8 +332,8 @@ static sint sta2sta_data_frame(struct _adapter *adapter,
return _FAIL;
if ((memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast))
return _FAIL;
- if (is_zero_ether_addr(pattrib->bssid) ||
- is_zero_ether_addr(mybssid) ||
+ if (eth_addr_zero(pattrib->bssid) ||
+ eth_addr_zero(mybssid) ||
(memcmp(pattrib->bssid, mybssid, ETH_ALEN)))
return _FAIL;
sta_addr = pattrib->src;
@@ -410,8 +410,8 @@ static sint ap2sta_data_frame(struct _adapter *adapter,
if ((memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast))
return _FAIL;
/* check BSSID */
- if (is_zero_ether_addr(pattrib->bssid) ||
- is_zero_ether_addr(mybssid) ||
+ if (eth_addr_zero(pattrib->bssid) ||
+ eth_addr_zero(mybssid) ||
(memcmp(pattrib->bssid, mybssid, ETH_ALEN)))
return _FAIL;
if (bmcast)
diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c
index cd920da..4cc972d 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -918,7 +918,7 @@ static int slic_mac_set_address(struct net_device *dev, void *ptr)
if (!adapter)
return -EBUSY;
- if (!is_valid_ether_addr(addr->sa_data))
+ if (!eth_addr_valid(addr->sa_data))
return -EINVAL;
memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
diff --git a/drivers/staging/vt6655/bssdb.c b/drivers/staging/vt6655/bssdb.c
index fe57fb8..4e44851 100644
--- a/drivers/staging/vt6655/bssdb.c
+++ b/drivers/staging/vt6655/bssdb.c
@@ -143,7 +143,7 @@ BSSpSearchBSSList(
if (pbyDesireBSSID != NULL) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
"BSSpSearchBSSList BSSID[%pM]\n", pbyDesireBSSID);
- if ((!is_broadcast_ether_addr(pbyDesireBSSID)) &&
+ if ((!eth_addr_broadcast(pbyDesireBSSID)) &&
(memcmp(pbyDesireBSSID, ZeroBSSID, 6)!= 0)){
pbyBSSID = pbyDesireBSSID;
}
diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c
index 319ca48..12b31ce 100644
--- a/drivers/staging/vt6655/card.c
+++ b/drivers/staging/vt6655/card.c
@@ -835,7 +835,7 @@ bool CARDbSetBSSID(void *pDeviceHandler, unsigned char *pbyBSSID, CARD_OP_MODE e
pDevice->byRxMode &= ~RCR_BSSID;
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wcmd: rx_mode = %x\n", pDevice->byRxMode );
} else {
- if (is_zero_ether_addr(pDevice->abyBSSID) == false) {
+ if (eth_addr_zero(pDevice->abyBSSID) == false) {
MACvRegBitsOn(pDevice->PortOffset, MAC_REG_RCR, RCR_BSSID);
pDevice->bBSSIDFilter = true;
pDevice->byRxMode |= RCR_BSSID;
diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index 9e3b3f2b..b47d31a 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -2275,7 +2275,7 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) {
spin_unlock_irq(&pDevice->lock);
return 0;
}
- if (is_multicast_ether_addr((unsigned char *)(skb->data))) {
+ if (eth_addr_multicast((unsigned char *)(skb->data))) {
uNodeIndex = 0;
bNodeExist = true;
if (pMgmt->sNodeDBTable[0].bPSEnable) {
diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c
index 373e9e4..de96dfa 100644
--- a/drivers/staging/vt6655/dpc.c
+++ b/drivers/staging/vt6655/dpc.c
@@ -442,7 +442,7 @@ device_receive_frame (
return false;
}
- if (!is_multicast_ether_addr(pbyFrame)) {
+ if (!eth_addr_multicast(pbyFrame)) {
if (WCTLbIsDuplicate(&(pDevice->sDupRxCache), (PS802_11Header) (skb->data + 4))) {
pDevice->s802_11Counter.FrameDuplicateCount++;
return false;
@@ -1421,7 +1421,7 @@ static bool s_bAPModeRxData (
if (FrameSize > CB_MAX_BUF_SIZE)
return false;
// check DA
- if(is_multicast_ether_addr((unsigned char *)(skb->data+cbHeaderOffset))) {
+ if(eth_addr_multicast((unsigned char *)(skb->data+cbHeaderOffset))) {
if (pMgmt->sNodeDBTable[0].bPSEnable) {
skbcpy = dev_alloc_skb((int)pDevice->rx_buf_sz);
diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
index 67b1b88..5076547 100644
--- a/drivers/staging/vt6655/hostap.c
+++ b/drivers/staging/vt6655/hostap.c
@@ -495,7 +495,7 @@ static int hostap_set_encryption(PSDevice pDevice,
return -EINVAL;
}
- if (is_broadcast_ether_addr(param->sta_addr)) {
+ if (eth_addr_broadcast(param->sta_addr)) {
if (param->u.crypt.idx >= MAX_GROUP_KEY)
return -EINVAL;
iNodeIndex = 0;
@@ -714,7 +714,7 @@ static int hostap_get_encryption(PSDevice pDevice,
param->u.crypt.err = 0;
- if (is_broadcast_ether_addr(param->sta_addr)) {
+ if (eth_addr_broadcast(param->sta_addr)) {
iNodeIndex = 0;
} else {
if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &iNodeIndex) == false) {
diff --git a/drivers/staging/vt6655/iwctl.c b/drivers/staging/vt6655/iwctl.c
index 5cdda8d..94d96bd 100644
--- a/drivers/staging/vt6655/iwctl.c
+++ b/drivers/staging/vt6655/iwctl.c
@@ -676,7 +676,7 @@ if (pMgmt->eScanState == WMAC_IS_SCANNING) {
return rc;
}
//mike :add
- if ((is_broadcast_ether_addr(pMgmt->abyDesireBSSID)) ||
+ if ((eth_addr_broadcast(pMgmt->abyDesireBSSID)) ||
(memcmp(pMgmt->abyDesireBSSID, ZeroBSSID, 6) == 0)){
PRINT_K("SIOCSIWAP:invalid desired BSSID return!\n");
return rc;
diff --git a/drivers/staging/vt6655/key.c b/drivers/staging/vt6655/key.c
index 194fedc..03affe48 100644
--- a/drivers/staging/vt6655/key.c
+++ b/drivers/staging/vt6655/key.c
@@ -371,7 +371,7 @@ bool KeybRemoveKey (
{
int i;
- if (is_broadcast_ether_addr(pbyBSSID)) {
+ if (eth_addr_broadcast(pbyBSSID)) {
// delete all keys
if ((dwKeyIndex & PAIRWISE_KEY) != 0) {
for (i=0;i<MAX_KEY_TABLE;i++) {
diff --git a/drivers/staging/vt6655/mib.c b/drivers/staging/vt6655/mib.c
index 63ae4ad..28157f6 100644
--- a/drivers/staging/vt6655/mib.c
+++ b/drivers/staging/vt6655/mib.c
@@ -471,11 +471,11 @@ STAvUpdateTDStatCounter (
pStatistic->CustomStat.ullTsrAllOK =
(pStatistic->ullTsrOK[TYPE_AC0DMA] + pStatistic->ullTsrOK[TYPE_TXDMA0]);
// update counters in case that successful transmit
- if (is_broadcast_ether_addr(pbyDestAddr)) {
+ if (eth_addr_broadcast(pbyDestAddr)) {
pStatistic->ullTxBroadcastFrames[uIdx]++;
pStatistic->ullTxBroadcastBytes[uIdx] += (unsigned long long) cbFrameLength;
}
- else if (is_multicast_ether_addr(pbyDestAddr)) {
+ else if (eth_addr_multicast(pbyDestAddr)) {
pStatistic->ullTxMulticastFrames[uIdx]++;
pStatistic->ullTxMulticastBytes[uIdx] += (unsigned long long) cbFrameLength;
}
@@ -495,9 +495,9 @@ STAvUpdateTDStatCounter (
pStatistic->dwTsrACKData[uIdx]++;
}
- if (is_broadcast_ether_addr(pbyDestAddr))
+ if (eth_addr_broadcast(pbyDestAddr))
pStatistic->dwTsrBroadcast[uIdx]++;
- else if (is_multicast_ether_addr(pbyDestAddr))
+ else if (eth_addr_multicast(pbyDestAddr))
pStatistic->dwTsrMulticast[uIdx]++;
else
pStatistic->dwTsrDirected[uIdx]++;
diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c
index 4972e57..5189415 100644
--- a/drivers/staging/vt6655/rxtx.c
+++ b/drivers/staging/vt6655/rxtx.c
@@ -1372,7 +1372,7 @@ s_cbFillTxBufHead(PSDevice pDevice, unsigned char byPktType, unsigned char *pbyT
if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
(pDevice->eOPMode == OP_MODE_AP)) {
- if (is_multicast_ether_addr(&(psEthHeader->abyDstAddr[0])))
+ if (eth_addr_multicast(&(psEthHeader->abyDstAddr[0])))
bNeedACK = false;
else
bNeedACK = true;
@@ -2088,7 +2088,7 @@ vGenerateFIFOHeader(PSDevice pDevice, unsigned char byPktType, unsigned char *pb
if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
(pDevice->eOPMode == OP_MODE_AP)) {
- if (is_multicast_ether_addr(&(psEthHeader->abyDstAddr[0]))) {
+ if (eth_addr_multicast(&(psEthHeader->abyDstAddr[0]))) {
bNeedACK = false;
pTxBufHead->wFIFOCtl = pTxBufHead->wFIFOCtl & (~FIFOCTL_NEEDACK);
}
@@ -2388,7 +2388,7 @@ CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) {
pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us);
- if (is_multicast_ether_addr(&(pPacket->p80211Header->sA3.abyAddr1[0])))
+ if (eth_addr_multicast(&(pPacket->p80211Header->sA3.abyAddr1[0])))
bNeedACK = false;
else {
bNeedACK = true;
@@ -2722,7 +2722,7 @@ cbGetFragCount (
if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
(pDevice->eOPMode == OP_MODE_AP)) {
- if (is_multicast_ether_addr(&(psEthHeader->abyDstAddr[0])))
+ if (eth_addr_multicast(&(psEthHeader->abyDstAddr[0])))
bNeedACK = false;
else
bNeedACK = true;
@@ -2897,7 +2897,7 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, unsigned char *pbMPDU, un
pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us);
- if (is_multicast_ether_addr(&(p80211Header->sA3.abyAddr1[0]))) {
+ if (eth_addr_multicast(&(p80211Header->sA3.abyAddr1[0]))) {
bNeedACK = false;
if (pDevice->bEnableHostWEP) {
uNodeIndex = 0;
diff --git a/drivers/staging/vt6655/wpactl.c b/drivers/staging/vt6655/wpactl.c
index 2b6ae1e..e7a00f2 100644
--- a/drivers/staging/vt6655/wpactl.c
+++ b/drivers/staging/vt6655/wpactl.c
@@ -353,8 +353,8 @@ spin_lock_irq(&pDevice->lock);
}
// spin_lock_irq(&pDevice->lock);
- if (is_broadcast_ether_addr(¶m->addr[0]) || (param->addr == NULL)) {
- // If is_broadcast_ether_addr, set the key as every key entry's group key.
+ if (eth_addr_broadcast(¶m->addr[0]) || (param->addr == NULL)) {
+ // If eth_addr_broadcast, set the key as every key entry's group key.
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Groupe Key Assign.\n");
if ((KeybSetAllGroupKey(&(pDevice->sKey),
diff --git a/drivers/staging/vt6656/bssdb.c b/drivers/staging/vt6656/bssdb.c
index 2ac066d..db8d7ed 100644
--- a/drivers/staging/vt6656/bssdb.c
+++ b/drivers/staging/vt6656/bssdb.c
@@ -131,7 +131,7 @@ PKnownBSS BSSpSearchBSSList(void *hDeviceContext,
if (pbyDesireBSSID != NULL) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
"BSSpSearchBSSList BSSID[%pM]\n", pbyDesireBSSID);
- if ((!is_broadcast_ether_addr(pbyDesireBSSID)) &&
+ if ((!eth_addr_broadcast(pbyDesireBSSID)) &&
(memcmp(pbyDesireBSSID, ZeroBSSID, 6)!= 0)){
pbyBSSID = pbyDesireBSSID;
}
diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c
index 28edf9e..cea9fbf 100644
--- a/drivers/staging/vt6656/dpc.c
+++ b/drivers/staging/vt6656/dpc.c
@@ -452,7 +452,7 @@ RXbBulkInProcessData (
}
}
- if (!is_multicast_ether_addr(pMACHeader->abyAddr1)) {
+ if (!eth_addr_multicast(pMACHeader->abyAddr1)) {
if ( WCTLbIsDuplicate(&(pDevice->sDupRxCache), (PS802_11Header) pbyFrame) ) {
pDevice->s802_11Counter.FrameDuplicateCount++;
return FALSE;
@@ -1424,7 +1424,7 @@ static BOOL s_bAPModeRxData (
if (FrameSize > CB_MAX_BUF_SIZE)
return FALSE;
// check DA
- if (is_multicast_ether_addr((PBYTE)(skb->data+cbHeaderOffset))) {
+ if (eth_addr_multicast((PBYTE)(skb->data+cbHeaderOffset))) {
if (pMgmt->sNodeDBTable[0].bPSEnable) {
skbcpy = dev_alloc_skb((int)pDevice->rx_buf_sz);
diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
index 0a73d40..f5fa4ba 100644
--- a/drivers/staging/vt6656/hostap.c
+++ b/drivers/staging/vt6656/hostap.c
@@ -439,7 +439,7 @@ static int hostap_set_encryption(PSDevice pDevice,
return -EINVAL;
}
- if (is_broadcast_ether_addr(param->sta_addr)) {
+ if (eth_addr_broadcast(param->sta_addr)) {
if (param->u.crypt.idx >= MAX_GROUP_KEY)
return -EINVAL;
iNodeIndex = 0;
@@ -661,7 +661,7 @@ static int hostap_get_encryption(PSDevice pDevice,
param->u.crypt.err = 0;
- if (is_broadcast_ether_addr(param->sta_addr)) {
+ if (eth_addr_broadcast(param->sta_addr)) {
iNodeIndex = 0;
} else {
if (BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &iNodeIndex) == FALSE) {
diff --git a/drivers/staging/vt6656/iwctl.c b/drivers/staging/vt6656/iwctl.c
index 8f19874..43c03e2 100644
--- a/drivers/staging/vt6656/iwctl.c
+++ b/drivers/staging/vt6656/iwctl.c
@@ -582,7 +582,7 @@ int iwctl_siwap(struct net_device *dev, struct iw_request_info *info,
} else {
memcpy(pMgmt->abyDesireBSSID, wrq->sa_data, 6);
// mike: add
- if ((is_broadcast_ether_addr(pMgmt->abyDesireBSSID)) ||
+ if ((eth_addr_broadcast(pMgmt->abyDesireBSSID)) ||
(memcmp(pMgmt->abyDesireBSSID, ZeroBSSID, 6) == 0)) {
PRINT_K("SIOCSIWAP:invalid desired BSSID return!\n");
return rc;
diff --git a/drivers/staging/vt6656/key.c b/drivers/staging/vt6656/key.c
index a61fcb9..4d2a170 100644
--- a/drivers/staging/vt6656/key.c
+++ b/drivers/staging/vt6656/key.c
@@ -402,7 +402,7 @@ BOOL KeybRemoveKey(
int i;
BOOL bReturnValue = FALSE;
- if (is_broadcast_ether_addr(pbyBSSID)) {
+ if (eth_addr_broadcast(pbyBSSID)) {
// delete all keys
if ((dwKeyIndex & PAIRWISE_KEY) != 0) {
for (i=0;i<MAX_KEY_TABLE;i++) {
diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 3390838..ed2edd2 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -298,9 +298,9 @@ s_vSaveTxPktInfo(PSDevice pDevice, BYTE byPktNum, PBYTE pbyDestAddr, WORD wPktLe
{
PSStatCounter pStatistic=&(pDevice->scStatistic);
- if (is_broadcast_ether_addr(pbyDestAddr))
+ if (eth_addr_broadcast(pbyDestAddr))
pStatistic->abyTxPktInfo[byPktNum].byBroadMultiUni = TX_PKT_BROAD;
- else if (is_multicast_ether_addr(pbyDestAddr))
+ else if (eth_addr_multicast(pbyDestAddr))
pStatistic->abyTxPktInfo[byPktNum].byBroadMultiUni = TX_PKT_MULTI;
else
pStatistic->abyTxPktInfo[byPktNum].byBroadMultiUni = TX_PKT_UNI;
@@ -1484,7 +1484,7 @@ s_bPacketToWirelessUsb(
} else { //if (pDevice->dwDiagRefCount != 0) {
if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
(pDevice->eOPMode == OP_MODE_AP)) {
- if (is_multicast_ether_addr(psEthHeader->abyDstAddr)) {
+ if (eth_addr_multicast(psEthHeader->abyDstAddr)) {
bNeedACK = FALSE;
pTxBufHead->wFIFOCtl =
pTxBufHead->wFIFOCtl & (~FIFOCTL_NEEDACK);
@@ -2027,7 +2027,7 @@ CMD_STATUS csMgmt_xmit(
pTxBufHead->wFIFOCtl |= FIFOCTL_TMOEN;
pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us);
- if (is_multicast_ether_addr(pPacket->p80211Header->sA3.abyAddr1)) {
+ if (eth_addr_multicast(pPacket->p80211Header->sA3.abyAddr1)) {
bNeedACK = FALSE;
}
else {
@@ -2434,7 +2434,7 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb) {
pTxBufHead->wFIFOCtl |= FIFOCTL_TMOEN;
pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us);
- if (is_multicast_ether_addr(p80211Header->sA3.abyAddr1)) {
+ if (eth_addr_multicast(p80211Header->sA3.abyAddr1)) {
bNeedACK = FALSE;
if (pDevice->bEnableHostWEP) {
uNodeIndex = 0;
@@ -2759,7 +2759,7 @@ int nsDMA_tx_packet(PSDevice pDevice, unsigned int uDMAIdx, struct sk_buff *skb)
return 0;
}
- if (is_multicast_ether_addr((PBYTE)(skb->data))) {
+ if (eth_addr_multicast((PBYTE)(skb->data))) {
uNodeIndex = 0;
bNodeExist = TRUE;
if (pMgmt->sNodeDBTable[0].bPSEnable) {
@@ -2952,7 +2952,7 @@ int nsDMA_tx_packet(PSDevice pDevice, unsigned int uDMAIdx, struct sk_buff *skb)
else {
if (pDevice->eOPMode == OP_MODE_ADHOC) {
// Adhoc Tx rate decided from node DB
- if (is_multicast_ether_addr(pDevice->sTxEthHeader.abyDstAddr)) {
+ if (eth_addr_multicast(pDevice->sTxEthHeader.abyDstAddr)) {
// Multicast use highest data rate
pDevice->wCurrentRate = pMgmt->sNodeDBTable[0].wTxDataRate;
// preamble type
diff --git a/drivers/staging/vt6656/wpactl.c b/drivers/staging/vt6656/wpactl.c
index 3e65aa1..534a7c8 100644
--- a/drivers/staging/vt6656/wpactl.c
+++ b/drivers/staging/vt6656/wpactl.c
@@ -337,7 +337,7 @@ int wpa_set_wpadev(PSDevice pDevice, int val)
return -EINVAL;
}
- if (is_broadcast_ether_addr(¶m->addr[0]) || (param->addr == NULL)) {
+ if (eth_addr_broadcast(¶m->addr[0]) || (param->addr == NULL)) {
/* if broadcast, set the key as every key entry's group key */
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Groupe Key Assign.\n");
diff --git a/drivers/staging/wlags49_h2/wl_wext.c b/drivers/staging/wlags49_h2/wl_wext.c
index f553366..8263409 100644
--- a/drivers/staging/wlags49_h2/wl_wext.c
+++ b/drivers/staging/wlags49_h2/wl_wext.c
@@ -174,7 +174,7 @@ static int hermes_clear_tkip_keys(ltv_t *ltv, u16 key_idx, u8 *addr)
switch (key_idx) {
case 0:
- if (!is_broadcast_ether_addr(addr)) {
+ if (!eth_addr_broadcast(addr)) {
ltv->len = 7;
ltv->typ = CFG_REMOVE_TKIP_MAPPED_KEY;
memcpy(<v->u.u8[0], addr, ETH_ALEN);
--
1.7.8.111.gad25c.dirty
^ permalink raw reply related
* [PATCH net-next 07/21] infiniband: Convert is_<foo>_ether_addr uses to eth_addr_<foo>
From: Joe Perches @ 2012-10-19 4:14 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel
In-Reply-To: <cover.1350618006.git.joe@perches.com>
Convert the old ether_addr tests to eth_addr_<foo>.
Adds api consistency.
Signed-off-by: Joe Perches <joe@perches.com>
---
drivers/infiniband/hw/amso1100/c2.c | 2 +-
drivers/infiniband/hw/nes/nes_nic.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/hw/amso1100/c2.c b/drivers/infiniband/hw/amso1100/c2.c
index 5ce7b9e..3bb307c 100644
--- a/drivers/infiniband/hw/amso1100/c2.c
+++ b/drivers/infiniband/hw/amso1100/c2.c
@@ -908,7 +908,7 @@ static struct net_device *c2_devinit(struct c2_dev *c2dev,
memcpy_fromio(netdev->dev_addr, mmio_addr + C2_REGS_ENADDR, 6);
/* Validate the MAC address */
- if (!is_valid_ether_addr(netdev->dev_addr)) {
+ if (!eth_addr_valid(netdev->dev_addr)) {
pr_debug("Invalid MAC Address\n");
c2_print_macaddr(netdev);
free_netdev(netdev);
diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
index 0564be7..3cd7d38 100644
--- a/drivers/infiniband/hw/nes/nes_nic.c
+++ b/drivers/infiniband/hw/nes/nes_nic.c
@@ -809,7 +809,7 @@ static int nes_netdev_set_mac_address(struct net_device *netdev, void *p)
u32 macaddr_low;
u16 macaddr_high;
- if (!is_valid_ether_addr(mac_addr->sa_data))
+ if (!eth_addr_valid(mac_addr->sa_data))
return -EADDRNOTAVAIL;
memcpy(netdev->dev_addr, mac_addr->sa_data, netdev->addr_len);
--
1.7.8.111.gad25c.dirty
^ permalink raw reply related
* [PATCH net-next 08/21] scsi: Convert is_<foo>_ether_addr uses to eth_addr_<foo>
From: Joe Perches @ 2012-10-19 4:14 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel
In-Reply-To: <cover.1350618006.git.joe@perches.com>
Convert the old ether_addr tests to eth_addr_<foo>.
Adds api consistency.
Signed-off-by: Joe Perches <joe@perches.com>
---
drivers/scsi/bnx2fc/bnx2fc_els.c | 4 ++--
drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 2 +-
drivers/scsi/fcoe/fcoe.c | 12 ++++++------
drivers/scsi/fcoe/fcoe_ctlr.c | 8 ++++----
drivers/scsi/fnic/fnic_fcs.c | 6 +++---
5 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/drivers/scsi/bnx2fc/bnx2fc_els.c b/drivers/scsi/bnx2fc/bnx2fc_els.c
index bdbbb13..e611fe5 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_els.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_els.c
@@ -860,7 +860,7 @@ static void bnx2fc_flogi_resp(struct fc_seq *seq, struct fc_frame *fp,
goto done;
mac = fr_cb(fp)->granted_mac;
- if (is_zero_ether_addr(mac)) {
+ if (eth_addr_zero(mac)) {
op = fc_frame_payload_op(fp);
if (lport->vport) {
if (op == ELS_LS_RJT) {
@@ -872,7 +872,7 @@ static void bnx2fc_flogi_resp(struct fc_seq *seq, struct fc_frame *fp,
}
fcoe_ctlr_recv_flogi(fip, lport, fp);
}
- if (!is_zero_ether_addr(mac))
+ if (!eth_addr_zero(mac))
fip->update_mac(lport, mac);
done:
fc_lport_flogi_resp(seq, fp, lport);
diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index e055865..e888418 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -1216,7 +1216,7 @@ static int bnx2fc_interface_setup(struct bnx2fc_interface *interface)
ha->addr[4], ha->addr[5]);
if ((ha->type == NETDEV_HW_ADDR_T_SAN) &&
- (is_valid_ether_addr(ha->addr))) {
+ (eth_addr_valid(ha->addr))) {
memcpy(ctlr->ctl_src_addr, ha->addr,
ETH_ALEN);
sel_san_mac = 1;
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index 666b7ac..876b99c 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -328,7 +328,7 @@ static int fcoe_interface_setup(struct fcoe_interface *fcoe,
rcu_read_lock();
for_each_dev_addr(real_dev, ha) {
if ((ha->type == NETDEV_HW_ADDR_T_SAN) &&
- (is_valid_ether_addr(ha->addr))) {
+ (eth_addr_valid(ha->addr))) {
memcpy(fip->ctl_src_addr, ha->addr, ETH_ALEN);
fip->spma = 1;
break;
@@ -563,9 +563,9 @@ static void fcoe_update_src_mac(struct fc_lport *lport, u8 *addr)
struct fcoe_port *port = lport_priv(lport);
struct fcoe_interface *fcoe = port->priv;
- if (!is_zero_ether_addr(port->data_src_addr))
+ if (!eth_addr_zero(port->data_src_addr))
dev_uc_del(fcoe->netdev, port->data_src_addr);
- if (!is_zero_ether_addr(addr))
+ if (!eth_addr_zero(addr))
dev_uc_add(fcoe->netdev, addr);
memcpy(port->data_src_addr, addr, ETH_ALEN);
}
@@ -980,7 +980,7 @@ static void fcoe_if_destroy(struct fc_lport *lport)
fcoe_clean_pending_queue(lport);
rtnl_lock();
- if (!is_zero_ether_addr(port->data_src_addr))
+ if (!eth_addr_zero(port->data_src_addr))
dev_uc_del(netdev, port->data_src_addr);
if (lport->vport)
synchronize_net();
@@ -2587,9 +2587,9 @@ static void fcoe_flogi_resp(struct fc_seq *seq, struct fc_frame *fp, void *arg)
mac = fr_cb(fp)->granted_mac;
/* pre-FIP */
- if (is_zero_ether_addr(mac))
+ if (eth_addr_zero(mac))
fcoe_ctlr_recv_flogi(fip, lport, fp);
- if (!is_zero_ether_addr(mac))
+ if (!eth_addr_zero(mac))
fcoe_update_src_mac(lport, mac);
done:
fc_lport_flogi_resp(seq, fp, lport);
diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
index 2ebe03a..5f230a0 100644
--- a/drivers/scsi/fcoe/fcoe_ctlr.c
+++ b/drivers/scsi/fcoe/fcoe_ctlr.c
@@ -302,7 +302,7 @@ static void fcoe_ctlr_announce(struct fcoe_ctlr *fip)
if (sel && !compare_ether_addr(sel->fcf_mac, fip->dest_addr))
goto unlock;
- if (!is_zero_ether_addr(fip->dest_addr)) {
+ if (!eth_addr_zero(fip->dest_addr)) {
printk(KERN_NOTICE "libfcoe: host%d: "
"FIP Fibre-Channel Forwarder MAC %pM deselected\n",
fip->lp->host->host_no, fip->dest_addr);
@@ -907,7 +907,7 @@ static int fcoe_ctlr_parse_adv(struct fcoe_ctlr *fip,
((struct fip_mac_desc *)desc)->fd_mac,
ETH_ALEN);
memcpy(fcf->fcoe_mac, fcf->fcf_mac, ETH_ALEN);
- if (!is_valid_ether_addr(fcf->fcf_mac)) {
+ if (!eth_addr_valid(fcf->fcf_mac)) {
LIBFCOE_FIP_DBG(fip,
"Invalid MAC addr %pM in FIP adv\n",
fcf->fcf_mac);
@@ -1212,7 +1212,7 @@ static void fcoe_ctlr_recv_els(struct fcoe_ctlr *fip, struct sk_buff *skb)
if ((els_dtype == FIP_DT_FLOGI || els_dtype == FIP_DT_FDISC) &&
sub == FIP_SC_REP && fip->mode != FIP_MODE_VN2VN) {
if (els_op == ELS_LS_ACC) {
- if (!is_valid_ether_addr(granted_mac)) {
+ if (!eth_addr_valid(granted_mac)) {
LIBFCOE_FIP_DBG(fip,
"Invalid MAC address %pM in FIP ELS\n",
granted_mac);
@@ -2252,7 +2252,7 @@ static int fcoe_ctlr_vn_parse(struct fcoe_ctlr *fip,
if (dlen != sizeof(struct fip_mac_desc))
goto len_err;
macd = (struct fip_mac_desc *)desc;
- if (!is_valid_ether_addr(macd->fd_mac)) {
+ if (!eth_addr_valid(macd->fd_mac)) {
LIBFCOE_FIP_DBG(fip,
"Invalid MAC addr %pM in FIP VN2VN\n",
macd->fd_mac);
diff --git a/drivers/scsi/fnic/fnic_fcs.c b/drivers/scsi/fnic/fnic_fcs.c
index 3c53c34..792df19 100644
--- a/drivers/scsi/fnic/fnic_fcs.c
+++ b/drivers/scsi/fnic/fnic_fcs.c
@@ -190,12 +190,12 @@ void fnic_update_mac_locked(struct fnic *fnic, u8 *new)
u8 *ctl = fnic->ctlr.ctl_src_addr;
u8 *data = fnic->data_src_addr;
- if (is_zero_ether_addr(new))
+ if (eth_addr_zero(new))
new = ctl;
if (!compare_ether_addr(data, new))
return;
FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, "update_mac %pM\n", new);
- if (!is_zero_ether_addr(data) && compare_ether_addr(data, ctl))
+ if (!eth_addr_zero(data) && compare_ether_addr(data, ctl))
vnic_dev_del_addr(fnic->vdev, data);
memcpy(data, new, ETH_ALEN);
if (compare_ether_addr(new, ctl))
@@ -251,7 +251,7 @@ void fnic_set_port_id(struct fc_lport *lport, u32 port_id, struct fc_frame *fp)
if (fp) {
mac = fr_cb(fp)->granted_mac;
- if (is_zero_ether_addr(mac)) {
+ if (eth_addr_zero(mac)) {
/* non-FIP - FLOGI already accepted - ignore return */
fcoe_ctlr_recv_flogi(&fnic->ctlr, lport, fp);
}
--
1.7.8.111.gad25c.dirty
^ permalink raw reply related
* [PATCH net-next 09/21] of: Convert is_<foo>_ether_addr uses to eth_addr_<foo>
From: Joe Perches @ 2012-10-19 4:14 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel
In-Reply-To: <cover.1350618006.git.joe@perches.com>
Convert the old ether_addr tests to eth_addr_<foo>.
Adds api consistency.
Signed-off-by: Joe Perches <joe@perches.com>
---
drivers/of/of_net.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/of/of_net.c b/drivers/of/of_net.c
index ffab033..452dcf6 100644
--- a/drivers/of/of_net.c
+++ b/drivers/of/of_net.c
@@ -78,15 +78,15 @@ const void *of_get_mac_address(struct device_node *np)
struct property *pp;
pp = of_find_property(np, "mac-address", NULL);
- if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
+ if (pp && (pp->length == 6) && eth_addr_valid(pp->value))
return pp->value;
pp = of_find_property(np, "local-mac-address", NULL);
- if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
+ if (pp && (pp->length == 6) && eth_addr_valid(pp->value))
return pp->value;
pp = of_find_property(np, "address", NULL);
- if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
+ if (pp && (pp->length == 6) && eth_addr_valid(pp->value))
return pp->value;
return NULL;
--
1.7.8.111.gad25c.dirty
^ permalink raw reply related
* [PATCH net-next 10/21] s390: Convert is_<foo>_ether_addr uses to eth_addr_<foo>
From: Joe Perches @ 2012-10-19 4:14 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel
In-Reply-To: <cover.1350618006.git.joe@perches.com>
Convert the old ether_addr tests to eth_addr_<foo>.
Adds api consistency.
Signed-off-by: Joe Perches <joe@perches.com>
---
drivers/s390/net/qeth_l2_main.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index e67e025..58324dc 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -227,9 +227,9 @@ static inline int qeth_l2_get_cast_type(struct qeth_card *card,
{
if (card->info.type == QETH_CARD_TYPE_OSN)
return RTN_UNSPEC;
- if (is_broadcast_ether_addr(skb->data))
+ if (eth_addr_broadcast(skb->data))
return RTN_BROADCAST;
- if (is_multicast_ether_addr(skb->data))
+ if (eth_addr_multicast(skb->data))
return RTN_MULTICAST;
return RTN_UNSPEC;
}
--
1.7.8.111.gad25c.dirty
^ permalink raw reply related
* [PATCH net-next 11/21] usb: Convert is_<foo>_ether_addr uses to eth_addr_<foo>
From: Joe Perches @ 2012-10-19 4:14 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel
In-Reply-To: <cover.1350618006.git.joe@perches.com>
Convert the old ether_addr tests to eth_addr_<foo>.
Adds api consistency.
Signed-off-by: Joe Perches <joe@perches.com>
---
drivers/usb/gadget/u_ether.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c
index 6458764..d6a5577 100644
--- a/drivers/usb/gadget/u_ether.c
+++ b/drivers/usb/gadget/u_ether.c
@@ -510,13 +510,13 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb,
if (!is_promisc(cdc_filter)) {
u8 *dest = skb->data;
- if (is_multicast_ether_addr(dest)) {
+ if (eth_addr_multicast(dest)) {
u16 type;
/* ignores USB_CDC_PACKET_TYPE_MULTICAST and host
* SET_ETHERNET_MULTICAST_FILTERS requests
*/
- if (is_broadcast_ether_addr(dest))
+ if (eth_addr_broadcast(dest))
type = USB_CDC_PACKET_TYPE_BROADCAST;
else
type = USB_CDC_PACKET_TYPE_ALL_MULTICAST;
@@ -721,7 +721,7 @@ static int get_ether_addr(const char *str, u8 *dev_addr)
num |= hex_to_bin(*str++);
dev_addr [i] = num;
}
- if (is_valid_ether_addr(dev_addr))
+ if (eth_addr_valid(dev_addr))
return 0;
}
eth_random_addr(dev_addr);
--
1.7.8.111.gad25c.dirty
^ permalink raw reply related
* [PATCH net-next 12/21] uwb: Convert is_<foo>_ether_addr uses to eth_addr_<foo>
From: Joe Perches @ 2012-10-19 4:14 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel
In-Reply-To: <cover.1350618006.git.joe@perches.com>
Convert the old ether_addr tests to eth_addr_<foo>.
Adds api consistency.
Signed-off-by: Joe Perches <joe@perches.com>
---
drivers/uwb/address.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/uwb/address.c b/drivers/uwb/address.c
index 8739c4f..ba4e4cf 100644
--- a/drivers/uwb/address.c
+++ b/drivers/uwb/address.c
@@ -343,7 +343,7 @@ static ssize_t uwb_rc_mac_addr_store(struct device *dev,
result = -EINVAL;
goto out;
}
- if (is_multicast_ether_addr(addr.data)) {
+ if (eth_addr_multicast(addr.data)) {
dev_err(&rc->uwb_dev.dev, "refusing to set multicast "
"MAC address %s\n", buf);
result = -EINVAL;
--
1.7.8.111.gad25c.dirty
^ permalink raw reply related
* [PATCH net-next 13/21] Documentation: networking: Convert is_<foo>_ether_addr uses to eth_addr_<foo>
From: Joe Perches @ 2012-10-19 4:14 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel
In-Reply-To: <cover.1350618006.git.joe@perches.com>
Convert the old ether_addr tests to eth_addr_<foo>.
Adds api consistency.
Signed-off-by: Joe Perches <joe@perches.com>
---
Documentation/networking/driver.txt | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Documentation/networking/driver.txt b/Documentation/networking/driver.txt
index da59e28..4db39f4 100644
--- a/Documentation/networking/driver.txt
+++ b/Documentation/networking/driver.txt
@@ -80,7 +80,7 @@ Probing guidelines:
1) Any hardware layer address you obtain for your device should
be verified. For example, for ethernet check it with
- linux/etherdevice.h:is_valid_ether_addr()
+ linux/etherdevice.h:eth_addr_valid()
Close/stop guidelines:
--
1.7.8.111.gad25c.dirty
^ permalink raw reply related
* [PATCH net-next 14/21] llc_if.h: Convert is_<foo>_ether_addr uses to eth_addr_<foo>
From: Joe Perches @ 2012-10-19 4:14 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel
In-Reply-To: <cover.1350618006.git.joe@perches.com>
Convert the old ether_addr tests to eth_addr_<foo>.
Adds api consistency.
Signed-off-by: Joe Perches <joe@perches.com>
---
include/net/llc_if.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/net/llc_if.h b/include/net/llc_if.h
index b595a00..cce2942 100644
--- a/include/net/llc_if.h
+++ b/include/net/llc_if.h
@@ -71,12 +71,12 @@
*/
static inline int llc_mac_null(const u8 *mac)
{
- return is_zero_ether_addr(mac);
+ return eth_addr_zero(mac);
}
static inline int llc_mac_multicast(const u8 *mac)
{
- return is_multicast_ether_addr(mac);
+ return eth_addr_multicast(mac);
}
/**
* llc_mac_match - determines if two mac addresses are the same
--
1.7.8.111.gad25c.dirty
^ permalink raw reply related
* [PATCH net-next 15/21] in.h: Rename ipv4_is_<foo> functions to ipv4_addr_<foo>
From: Joe Perches @ 2012-10-19 4:14 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel
In-Reply-To: <cover.1350618006.git.joe@perches.com>
Make the ipv4_is_<foo> tests use a similar style to ipv6_<foo> tests.
Add backward compatibility #defines to keep current ipv4_is_<foo>
code working until completely converted.
Signed-off-by: Joe Perches <joe@perches.com>
---
include/linux/in.h | 40 ++++++++++++++++++++++++++++------------
1 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/include/linux/in.h b/include/linux/in.h
index 31b4937..2116ce8 100644
--- a/include/linux/in.h
+++ b/include/linux/in.h
@@ -39,66 +39,82 @@ static inline int proto_ports_offset(int proto)
}
}
-static inline bool ipv4_is_loopback(__be32 addr)
+static inline bool ipv4_addr_loopback(__be32 addr)
{
return (addr & htonl(0xff000000)) == htonl(0x7f000000);
}
-static inline bool ipv4_is_multicast(__be32 addr)
+static inline bool ipv4_addr_multicast(__be32 addr)
{
return (addr & htonl(0xf0000000)) == htonl(0xe0000000);
}
-static inline bool ipv4_is_local_multicast(__be32 addr)
+static inline bool ipv4_addr_local_multicast(__be32 addr)
{
return (addr & htonl(0xffffff00)) == htonl(0xe0000000);
}
-static inline bool ipv4_is_lbcast(__be32 addr)
+static inline bool ipv4_addr_lbcast(__be32 addr)
{
/* limited broadcast */
return addr == htonl(INADDR_BROADCAST);
}
-static inline bool ipv4_is_zeronet(__be32 addr)
+static inline bool ipv4_addr_zeronet(__be32 addr)
{
return (addr & htonl(0xff000000)) == htonl(0x00000000);
}
/* Special-Use IPv4 Addresses (RFC3330) */
-static inline bool ipv4_is_private_10(__be32 addr)
+static inline bool ipv4_addr_private_10(__be32 addr)
{
return (addr & htonl(0xff000000)) == htonl(0x0a000000);
}
-static inline bool ipv4_is_private_172(__be32 addr)
+static inline bool ipv4_addr_private_172(__be32 addr)
{
return (addr & htonl(0xfff00000)) == htonl(0xac100000);
}
-static inline bool ipv4_is_private_192(__be32 addr)
+static inline bool ipv4_addr_private_192(__be32 addr)
{
return (addr & htonl(0xffff0000)) == htonl(0xc0a80000);
}
-static inline bool ipv4_is_linklocal_169(__be32 addr)
+static inline bool ipv4_addr_linklocal_169(__be32 addr)
{
return (addr & htonl(0xffff0000)) == htonl(0xa9fe0000);
}
-static inline bool ipv4_is_anycast_6to4(__be32 addr)
+static inline bool ipv4_addr_anycast_6to4(__be32 addr)
{
return (addr & htonl(0xffffff00)) == htonl(0xc0586300);
}
-static inline bool ipv4_is_test_192(__be32 addr)
+static inline bool ipv4_addr_test_192(__be32 addr)
{
return (addr & htonl(0xffffff00)) == htonl(0xc0000200);
}
-static inline bool ipv4_is_test_198(__be32 addr)
+static inline bool ipv4_addr_test_198(__be32 addr)
{
return (addr & htonl(0xfffe0000)) == htonl(0xc6120000);
}
+
+/* Some #defines to make old ipv4_is_<foo> tests work for awhile */
+
+#define ipv4_is_loopback(addr) ipv4_addr_loopback(addr)
+#define ipv4_is_multicast(addr) ipv4_addr_multicast(addr)
+#define ipv4_is_local_multicast(addr) ipv4_addr_local_multicast(addr)
+#define ipv4_is_lbcast(addr) ipv4_addr_lbcast(addr)
+#define ipv4_is_zeronet(addr) ipv4_addr_zeronet(addr)
+#define ipv4_is_private_10(addr) ipv4_addr_private_10(addr)
+#define ipv4_is_private_172(addr) ipv4_addr_private_172(addr)
+#define ipv4_is_private_192(addr) ipv4_addr_private_192(addr)
+#define ipv4_is_linklocal_169(addr) ipv4_addr_linklocal_169(addr)
+#define ipv4_is_anycast_6to4(addr) ipv4_addr_anycast_6to4(addr)
+#define ipv4_is_test_192(addr) ipv4_addr_test_192(addr)
+#define ipv4_is_test_198(addr) ipv4_addr_test_198(addr)
+
#endif /* _LINUX_IN_H */
--
1.7.8.111.gad25c.dirty
^ permalink raw reply related
* [PATCH net-next 16/21] net: Convert ipv4_is_<foo> uses to ipv4_addr_<foo>
From: Joe Perches @ 2012-10-19 4:15 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel
In-Reply-To: <cover.1350618006.git.joe@perches.com>
Use the new ipv4_addr_<foo> functions to be consistent with
the ipv6_addr_<foo> and eth_addr_<foo> style.
Signed-off-by: Joe Perches <joe@perches.com>
---
net/bridge/br_multicast.c | 4 +-
net/core/netpoll.c | 2 +-
net/core/pktgen.c | 10 +++---
net/ipv4/arp.c | 4 +-
net/ipv4/datagram.c | 2 +-
net/ipv4/devinet.c | 4 +-
net/ipv4/fib_frontend.c | 12 ++++----
net/ipv4/igmp.c | 12 ++++----
net/ipv4/ip_gre.c | 20 ++++++------
net/ipv4/ipmr.c | 4 +-
net/ipv4/netfilter/ipt_rpfilter.c | 10 +++---
net/ipv4/ping.c | 2 +-
net/ipv4/raw.c | 2 +-
net/ipv4/route.c | 58 ++++++++++++++++++------------------
net/ipv4/udp.c | 2 +-
net/ipv6/addrconf.c | 12 ++++----
net/l2tp/l2tp_ip.c | 2 +-
net/l2tp/l2tp_ip6.c | 2 +-
net/netfilter/ipvs/ip_vs_xmit.c | 6 ++--
net/netfilter/xt_cluster.c | 2 +-
net/netfilter/xt_pkttype.c | 2 +-
net/sctp/protocol.c | 10 +++---
22 files changed, 92 insertions(+), 92 deletions(-)
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index 2417434..1a58375 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -696,7 +696,7 @@ static int br_ip4_multicast_add_group(struct net_bridge *br,
{
struct br_ip br_group;
- if (ipv4_is_local_multicast(group))
+ if (ipv4_addr_local_multicast(group))
return 0;
br_group.u.ip4 = group;
@@ -1266,7 +1266,7 @@ static void br_ip4_multicast_leave_group(struct net_bridge *br,
{
struct br_ip br_group;
- if (ipv4_is_local_multicast(group))
+ if (ipv4_addr_local_multicast(group))
return;
br_group.u.ip4 = group;
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 77a0388..7a84b2a 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -495,7 +495,7 @@ static void netpoll_arp_reply(struct sk_buff *skb, struct netpoll_info *npinfo)
memcpy(&tip, arp_ptr, 4);
/* Should we ignore arp? */
- if (ipv4_is_loopback(tip) || ipv4_is_multicast(tip))
+ if (ipv4_addr_loopback(tip) || ipv4_addr_multicast(tip))
return;
size = arp_hdr_len(skb->dev);
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 3422af7..8327f05 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -2396,11 +2396,11 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
t = random32() % (imx - imn) + imn;
s = htonl(t);
- while (ipv4_is_loopback(s) ||
- ipv4_is_multicast(s) ||
- ipv4_is_lbcast(s) ||
- ipv4_is_zeronet(s) ||
- ipv4_is_local_multicast(s)) {
+ while (ipv4_addr_loopback(s) ||
+ ipv4_addr_multicast(s) ||
+ ipv4_addr_lbcast(s) ||
+ ipv4_addr_zeronet(s) ||
+ ipv4_addr_local_multicast(s)) {
t = random32() % (imx - imn) + imn;
s = htonl(t);
}
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index 4780045..b03e5e4 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -789,8 +789,8 @@ static int arp_process(struct sk_buff *skb)
* Check for bad requests for 127.x.x.x and requests for multicast
* addresses. If this is one such, delete it.
*/
- if (ipv4_is_multicast(tip) ||
- (!IN_DEV_ROUTE_LOCALNET(in_dev) && ipv4_is_loopback(tip)))
+ if (ipv4_addr_multicast(tip) ||
+ (!IN_DEV_ROUTE_LOCALNET(in_dev) && ipv4_addr_loopback(tip)))
goto out;
/*
diff --git a/net/ipv4/datagram.c b/net/ipv4/datagram.c
index 424fafb..83b51ad 100644
--- a/net/ipv4/datagram.c
+++ b/net/ipv4/datagram.c
@@ -43,7 +43,7 @@ int ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
oif = sk->sk_bound_dev_if;
saddr = inet->inet_saddr;
- if (ipv4_is_multicast(usin->sin_addr.s_addr)) {
+ if (ipv4_addr_multicast(usin->sin_addr.s_addr)) {
if (!oif)
oif = inet->mc_index;
if (!saddr)
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 2a6abc1..f217d83 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -491,7 +491,7 @@ static int inet_set_ifa(struct net_device *dev, struct in_ifaddr *ifa)
in_dev_hold(in_dev);
ifa->ifa_dev = in_dev;
}
- if (ipv4_is_loopback(ifa->ifa_local))
+ if (ipv4_addr_loopback(ifa->ifa_local))
ifa->ifa_scope = RT_SCOPE_HOST;
return inet_insert_ifa(ifa);
}
@@ -660,7 +660,7 @@ static int inet_abc_len(__be32 addr)
{
int rc = -1; /* Something else, probably a multicast. */
- if (ipv4_is_zeronet(addr))
+ if (ipv4_addr_zeronet(addr))
rc = 0;
else {
__u32 haddr = ntohl(addr);
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 825c608..9883d33 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -164,9 +164,9 @@ static inline unsigned int __inet_dev_addr_type(struct net *net,
unsigned int ret = RTN_BROADCAST;
struct fib_table *local_table;
- if (ipv4_is_zeronet(addr) || ipv4_is_lbcast(addr))
+ if (ipv4_addr_zeronet(addr) || ipv4_addr_lbcast(addr))
return RTN_BROADCAST;
- if (ipv4_is_multicast(addr))
+ if (ipv4_addr_multicast(addr))
return RTN_MULTICAST;
local_table = fib_get_table(net, RT_TABLE_LOCAL);
@@ -216,7 +216,7 @@ __be32 fib_compute_spec_dst(struct sk_buff *skb)
net = dev_net(dev);
scope = RT_SCOPE_UNIVERSE;
- if (!ipv4_is_zeronet(ip_hdr(skb)->saddr)) {
+ if (!ipv4_addr_zeronet(ip_hdr(skb)->saddr)) {
fl4.flowi4_oif = 0;
fl4.flowi4_iif = LOOPBACK_IFINDEX;
fl4.daddr = ip_hdr(skb)->saddr;
@@ -760,7 +760,7 @@ void fib_add_ifaddr(struct in_ifaddr *ifa)
if (ifa->ifa_broadcast && ifa->ifa_broadcast != htonl(0xFFFFFFFF))
fib_magic(RTM_NEWROUTE, RTN_BROADCAST, ifa->ifa_broadcast, 32, prim);
- if (!ipv4_is_zeronet(prefix) && !(ifa->ifa_flags & IFA_F_SECONDARY) &&
+ if (!ipv4_addr_zeronet(prefix) && !(ifa->ifa_flags & IFA_F_SECONDARY) &&
(prefix != addr || ifa->ifa_prefixlen < 32)) {
fib_magic(RTM_NEWROUTE,
dev->flags & IFF_LOOPBACK ? RTN_LOCAL : RTN_UNICAST,
@@ -807,7 +807,7 @@ void fib_del_ifaddr(struct in_ifaddr *ifa, struct in_ifaddr *iprim)
pr_warn("%s: bug: iprim != prim\n", __func__);
return;
}
- } else if (!ipv4_is_zeronet(any) &&
+ } else if (!ipv4_addr_zeronet(any) &&
(any != ifa->ifa_local || ifa->ifa_prefixlen < 32)) {
fib_magic(RTM_DELROUTE,
dev->flags & IFF_LOOPBACK ? RTN_LOCAL : RTN_UNICAST,
@@ -878,7 +878,7 @@ void fib_del_ifaddr(struct in_ifaddr *ifa, struct in_ifaddr *iprim)
__be32 brd1 = ifa1->ifa_address | ~ifa1->ifa_mask;
__be32 any1 = ifa1->ifa_address & ifa1->ifa_mask;
- if (!ipv4_is_zeronet(any1)) {
+ if (!ipv4_addr_zeronet(any1)) {
if (ifa->ifa_broadcast == brd1 ||
ifa->ifa_broadcast == any1)
ok |= BRD_OK;
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 736ab70..dc9a9b3 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -1796,7 +1796,7 @@ int ip_mc_join_group(struct sock *sk , struct ip_mreqn *imr)
int ifindex;
int count = 0;
- if (!ipv4_is_multicast(addr))
+ if (!ipv4_addr_multicast(addr))
return -EINVAL;
rtnl_lock();
@@ -1920,7 +1920,7 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
int leavegroup = 0;
int i, j, rv;
- if (!ipv4_is_multicast(addr))
+ if (!ipv4_addr_multicast(addr))
return -EINVAL;
rtnl_lock();
@@ -2055,7 +2055,7 @@ int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf, int ifindex)
struct net *net = sock_net(sk);
int leavegroup = 0;
- if (!ipv4_is_multicast(addr))
+ if (!ipv4_addr_multicast(addr))
return -EINVAL;
if (msf->imsf_fmode != MCAST_INCLUDE &&
msf->imsf_fmode != MCAST_EXCLUDE)
@@ -2141,7 +2141,7 @@ int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf,
struct ip_sf_socklist *psl;
struct net *net = sock_net(sk);
- if (!ipv4_is_multicast(addr))
+ if (!ipv4_addr_multicast(addr))
return -EINVAL;
rtnl_lock();
@@ -2203,7 +2203,7 @@ int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf,
if (psin->sin_family != AF_INET)
return -EINVAL;
addr = psin->sin_addr.s_addr;
- if (!ipv4_is_multicast(addr))
+ if (!ipv4_addr_multicast(addr))
return -EINVAL;
rtnl_lock();
@@ -2255,7 +2255,7 @@ int ip_mc_sf_allow(struct sock *sk, __be32 loc_addr, __be32 rmt_addr, int dif)
int ret;
ret = 1;
- if (!ipv4_is_multicast(loc_addr))
+ if (!ipv4_addr_multicast(loc_addr))
goto out;
rcu_read_lock();
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index dd94879..4c9ef98 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -306,7 +306,7 @@ static struct ip_tunnel *ipgre_tunnel_lookup(struct net_device *dev,
for_each_ip_tunnel_rcu(ign->tunnels_l[h1]) {
if ((local != t->parms.iph.saddr &&
(local != t->parms.iph.daddr ||
- !ipv4_is_multicast(local))) ||
+ !ipv4_addr_multicast(local))) ||
!(t->dev->flags & IFF_UP))
continue;
@@ -375,7 +375,7 @@ static struct ip_tunnel __rcu **__ipgre_bucket(struct ipgre_net *ign,
if (local)
prio |= 1;
- if (remote && !ipv4_is_multicast(remote)) {
+ if (remote && !ipv4_addr_multicast(remote)) {
prio |= 2;
h ^= HASH(remote);
}
@@ -580,7 +580,7 @@ static void ipgre_err(struct sk_buff *skb, u32 info)
return;
}
if (t->parms.iph.daddr == 0 ||
- ipv4_is_multicast(t->parms.iph.daddr))
+ ipv4_addr_multicast(t->parms.iph.daddr))
return;
if (t->parms.iph.ttl == 0 && type == ICMP_TIME_EXCEEDED)
@@ -681,7 +681,7 @@ static int ipgre_rcv(struct sk_buff *skb)
skb_postpull_rcsum(skb, skb_transport_header(skb), offset);
skb->pkt_type = PACKET_HOST;
#ifdef CONFIG_NET_IPGRE_BROADCAST
- if (ipv4_is_multicast(iph->daddr)) {
+ if (ipv4_addr_multicast(iph->daddr)) {
/* Looped back packet, drop it! */
if (rt_is_output_route(skb_rtable(skb)))
goto drop;
@@ -877,7 +877,7 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
if (rt6 && mtu < dst_mtu(skb_dst(skb)) && mtu >= IPV6_MIN_MTU) {
if ((tunnel->parms.iph.daddr &&
- !ipv4_is_multicast(tunnel->parms.iph.daddr)) ||
+ !ipv4_addr_multicast(tunnel->parms.iph.daddr)) ||
rt6->rt6i_dst.plen == 128) {
rt6->rt6i_flags |= RTF_MODIFIED;
dst_metric_set(skb_dst(skb), RTAX_MTU, mtu);
@@ -1115,7 +1115,7 @@ ipgre_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd)
t = netdev_priv(dev);
- if (ipv4_is_multicast(p.iph.daddr))
+ if (ipv4_addr_multicast(p.iph.daddr))
nflags = IFF_BROADCAST;
else if (p.iph.daddr)
nflags = IFF_POINTOPOINT;
@@ -1266,7 +1266,7 @@ static int ipgre_open(struct net_device *dev)
{
struct ip_tunnel *t = netdev_priv(dev);
- if (ipv4_is_multicast(t->parms.iph.daddr)) {
+ if (ipv4_addr_multicast(t->parms.iph.daddr)) {
struct flowi4 fl4;
struct rtable *rt;
@@ -1292,7 +1292,7 @@ static int ipgre_close(struct net_device *dev)
{
struct ip_tunnel *t = netdev_priv(dev);
- if (ipv4_is_multicast(t->parms.iph.daddr) && t->mlink) {
+ if (ipv4_addr_multicast(t->parms.iph.daddr) && t->mlink) {
struct in_device *in_dev;
in_dev = inetdev_by_index(dev_net(dev), t->mlink);
if (in_dev)
@@ -1365,7 +1365,7 @@ static int ipgre_tunnel_init(struct net_device *dev)
if (iph->daddr) {
#ifdef CONFIG_NET_IPGRE_BROADCAST
- if (ipv4_is_multicast(iph->daddr)) {
+ if (ipv4_addr_multicast(iph->daddr)) {
if (!iph->saddr)
return -EINVAL;
dev->flags = IFF_BROADCAST;
@@ -1663,7 +1663,7 @@ static int ipgre_changelink(struct net_device *dev, struct nlattr *tb[],
if (dev->type != ARPHRD_ETHER) {
unsigned int nflags = 0;
- if (ipv4_is_multicast(p.iph.daddr))
+ if (ipv4_addr_multicast(p.iph.daddr))
nflags = IFF_BROADCAST;
else if (p.iph.daddr)
nflags = IFF_POINTOPOINT;
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 6168c4d..99d7ed2 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1092,7 +1092,7 @@ static int ipmr_mfc_add(struct net *net, struct mr_table *mrt,
return 0;
}
- if (!ipv4_is_multicast(mfc->mfcc_mcastgrp.s_addr))
+ if (!ipv4_addr_multicast(mfc->mfcc_mcastgrp.s_addr))
return -EINVAL;
c = ipmr_cache_alloc();
@@ -1927,7 +1927,7 @@ static int __pim_rcv(struct mr_table *mrt, struct sk_buff *skb,
* b. packet is not a NULL-REGISTER
* c. packet is not truncated
*/
- if (!ipv4_is_multicast(encap->daddr) ||
+ if (!ipv4_addr_multicast(encap->daddr) ||
encap->tot_len == 0 ||
ntohs(encap->tot_len) + pimlen > skb->len)
return 1;
diff --git a/net/ipv4/netfilter/ipt_rpfilter.c b/net/ipv4/netfilter/ipt_rpfilter.c
index c301300..86ae272 100644
--- a/net/ipv4/netfilter/ipt_rpfilter.c
+++ b/net/ipv4/netfilter/ipt_rpfilter.c
@@ -26,8 +26,8 @@ MODULE_DESCRIPTION("iptables: ipv4 reverse path filter match");
/* don't try to find route from mcast/bcast/zeronet */
static __be32 rpfilter_get_saddr(__be32 addr)
{
- if (ipv4_is_multicast(addr) || ipv4_is_lbcast(addr) ||
- ipv4_is_zeronet(addr))
+ if (ipv4_addr_multicast(addr) || ipv4_addr_lbcast(addr) ||
+ ipv4_addr_zeronet(addr))
return 0;
return addr;
}
@@ -80,9 +80,9 @@ static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par)
return true ^ invert;
iph = ip_hdr(skb);
- if (ipv4_is_multicast(iph->daddr)) {
- if (ipv4_is_zeronet(iph->saddr))
- return ipv4_is_local_multicast(iph->daddr) ^ invert;
+ if (ipv4_addr_multicast(iph->daddr)) {
+ if (ipv4_addr_zeronet(iph->saddr))
+ return ipv4_addr_local_multicast(iph->daddr) ^ invert;
flow.flowi4_iif = 0;
} else {
flow.flowi4_iif = LOOPBACK_IFINDEX;
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index 8f3d054..68adc89 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -553,7 +553,7 @@ static int ping_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
tos |= RTO_ONLINK;
}
- if (ipv4_is_multicast(daddr)) {
+ if (ipv4_addr_multicast(daddr)) {
if (!ipc.oif)
ipc.oif = inet->mc_index;
if (!saddr)
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 73d1e4d..4116bf3 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -562,7 +562,7 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
if (msg->msg_flags & MSG_DONTROUTE)
tos |= RTO_ONLINK;
- if (ipv4_is_multicast(daddr)) {
+ if (ipv4_addr_multicast(daddr)) {
if (!ipc.oif)
ipc.oif = inet->mc_index;
if (!saddr)
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index a8c6512..263dfd8 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -688,8 +688,8 @@ static void __ip_do_redirect(struct rtable *rt, struct sk_buff *skb, struct flow
net = dev_net(dev);
if (new_gw == old_gw || !IN_DEV_RX_REDIRECTS(in_dev) ||
- ipv4_is_multicast(new_gw) || ipv4_is_lbcast(new_gw) ||
- ipv4_is_zeronet(new_gw))
+ ipv4_addr_multicast(new_gw) || ipv4_addr_lbcast(new_gw) ||
+ ipv4_addr_zeronet(new_gw))
goto reject_redirect;
if (!IN_DEV_SHARED_MEDIA(in_dev)) {
@@ -1332,16 +1332,16 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
if (in_dev == NULL)
return -EINVAL;
- if (ipv4_is_multicast(saddr) || ipv4_is_lbcast(saddr) ||
+ if (ipv4_addr_multicast(saddr) || ipv4_addr_lbcast(saddr) ||
skb->protocol != htons(ETH_P_IP))
goto e_inval;
if (likely(!IN_DEV_ROUTE_LOCALNET(in_dev)))
- if (ipv4_is_loopback(saddr))
+ if (ipv4_addr_loopback(saddr))
goto e_inval;
- if (ipv4_is_zeronet(saddr)) {
- if (!ipv4_is_local_multicast(daddr))
+ if (ipv4_addr_zeronet(saddr)) {
+ if (!ipv4_addr_local_multicast(daddr))
goto e_inval;
} else {
err = fib_validate_source(skb, saddr, 0, tos, 0, dev,
@@ -1374,7 +1374,7 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
}
#ifdef CONFIG_IP_MROUTE
- if (!ipv4_is_local_multicast(daddr) && IN_DEV_MFORWARD(in_dev))
+ if (!ipv4_addr_local_multicast(daddr) && IN_DEV_MFORWARD(in_dev))
rth->dst.input = ip_mr_input;
#endif
RT_CACHE_STAT_INC(in_slow_mc);
@@ -1553,29 +1553,29 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
by fib_lookup.
*/
- if (ipv4_is_multicast(saddr) || ipv4_is_lbcast(saddr))
+ if (ipv4_addr_multicast(saddr) || ipv4_addr_lbcast(saddr))
goto martian_source;
res.fi = NULL;
- if (ipv4_is_lbcast(daddr) || (saddr == 0 && daddr == 0))
+ if (ipv4_addr_lbcast(daddr) || (saddr == 0 && daddr == 0))
goto brd_input;
/* Accept zero addresses only to limited broadcast;
* I even do not know to fix it or not. Waiting for complains :-)
*/
- if (ipv4_is_zeronet(saddr))
+ if (ipv4_addr_zeronet(saddr))
goto martian_source;
- if (ipv4_is_zeronet(daddr))
+ if (ipv4_addr_zeronet(daddr))
goto martian_destination;
/* Following code try to avoid calling IN_DEV_NET_ROUTE_LOCALNET(),
* and call it once if daddr or/and saddr are loopback addresses
*/
- if (ipv4_is_loopback(daddr)) {
+ if (ipv4_addr_loopback(daddr)) {
if (!IN_DEV_NET_ROUTE_LOCALNET(in_dev, net))
goto martian_destination;
- } else if (ipv4_is_loopback(saddr)) {
+ } else if (ipv4_addr_loopback(saddr)) {
if (!IN_DEV_NET_ROUTE_LOCALNET(in_dev, net))
goto martian_source;
}
@@ -1620,7 +1620,7 @@ brd_input:
if (skb->protocol != htons(ETH_P_IP))
goto e_inval;
- if (!ipv4_is_zeronet(saddr)) {
+ if (!ipv4_addr_zeronet(saddr)) {
err = fib_validate_source(skb, saddr, 0, tos, 0, dev,
in_dev, &itag);
if (err < 0)
@@ -1726,7 +1726,7 @@ int ip_route_input_noref(struct sk_buff *skb, __be32 daddr, __be32 saddr,
Note, that multicast routers are not affected, because
route cache entry is created eventually.
*/
- if (ipv4_is_multicast(daddr)) {
+ if (ipv4_addr_multicast(daddr)) {
struct in_device *in_dev = __in_dev_get_rcu(dev);
if (in_dev) {
@@ -1735,7 +1735,7 @@ int ip_route_input_noref(struct sk_buff *skb, __be32 daddr, __be32 saddr,
if (our
#ifdef CONFIG_IP_MROUTE
||
- (!ipv4_is_local_multicast(daddr) &&
+ (!ipv4_addr_local_multicast(daddr) &&
IN_DEV_MFORWARD(in_dev))
#endif
) {
@@ -1772,14 +1772,14 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
return ERR_PTR(-EINVAL);
if (likely(!IN_DEV_ROUTE_LOCALNET(in_dev)))
- if (ipv4_is_loopback(fl4->saddr) && !(dev_out->flags & IFF_LOOPBACK))
+ if (ipv4_addr_loopback(fl4->saddr) && !(dev_out->flags & IFF_LOOPBACK))
return ERR_PTR(-EINVAL);
- if (ipv4_is_lbcast(fl4->daddr))
+ if (ipv4_addr_lbcast(fl4->daddr))
type = RTN_BROADCAST;
- else if (ipv4_is_multicast(fl4->daddr))
+ else if (ipv4_addr_multicast(fl4->daddr))
type = RTN_MULTICAST;
- else if (ipv4_is_zeronet(fl4->daddr))
+ else if (ipv4_addr_zeronet(fl4->daddr))
return ERR_PTR(-EINVAL);
if (dev_out->flags & IFF_LOOPBACK)
@@ -1860,7 +1860,7 @@ add:
#ifdef CONFIG_IP_MROUTE
if (type == RTN_MULTICAST) {
if (IN_DEV_MFORWARD(in_dev) &&
- !ipv4_is_local_multicast(fl4->daddr)) {
+ !ipv4_addr_local_multicast(fl4->daddr)) {
rth->dst.input = ip_mr_input;
rth->dst.output = ip_mc_output;
}
@@ -1900,9 +1900,9 @@ struct rtable *__ip_route_output_key(struct net *net, struct flowi4 *fl4)
rcu_read_lock();
if (fl4->saddr) {
rth = ERR_PTR(-EINVAL);
- if (ipv4_is_multicast(fl4->saddr) ||
- ipv4_is_lbcast(fl4->saddr) ||
- ipv4_is_zeronet(fl4->saddr))
+ if (ipv4_addr_multicast(fl4->saddr) ||
+ ipv4_addr_lbcast(fl4->saddr) ||
+ ipv4_addr_zeronet(fl4->saddr))
goto out;
/* I removed check for oif == dev_out->oif here.
@@ -1914,8 +1914,8 @@ struct rtable *__ip_route_output_key(struct net *net, struct flowi4 *fl4)
*/
if (fl4->flowi4_oif == 0 &&
- (ipv4_is_multicast(fl4->daddr) ||
- ipv4_is_lbcast(fl4->daddr))) {
+ (ipv4_addr_multicast(fl4->daddr) ||
+ ipv4_addr_lbcast(fl4->daddr))) {
/* It is equivalent to inet_addr_type(saddr) == RTN_LOCAL */
dev_out = __ip_dev_find(net, fl4->saddr, false);
if (dev_out == NULL)
@@ -1959,15 +1959,15 @@ struct rtable *__ip_route_output_key(struct net *net, struct flowi4 *fl4)
rth = ERR_PTR(-ENETUNREACH);
goto out;
}
- if (ipv4_is_local_multicast(fl4->daddr) ||
- ipv4_is_lbcast(fl4->daddr)) {
+ if (ipv4_addr_local_multicast(fl4->daddr) ||
+ ipv4_addr_lbcast(fl4->daddr)) {
if (!fl4->saddr)
fl4->saddr = inet_select_addr(dev_out, 0,
RT_SCOPE_LINK);
goto make_route;
}
if (fl4->saddr) {
- if (ipv4_is_multicast(fl4->daddr))
+ if (ipv4_addr_multicast(fl4->daddr))
fl4->saddr = inet_select_addr(dev_out, 0,
fl4->flowi4_scope);
else if (!fl4->daddr)
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 79c8dbe..3d0f229 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -918,7 +918,7 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
connected = 0;
}
- if (ipv4_is_multicast(daddr)) {
+ if (ipv4_addr_multicast(daddr)) {
if (!ipc.oif)
ipc.oif = inet->mc_index;
if (!saddr)
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 0424e4e..190e8c3 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1535,12 +1535,12 @@ static int __ipv6_isatap_ifid(u8 *eui, __be32 addr)
{
if (addr == 0)
return -1;
- eui[0] = (ipv4_is_zeronet(addr) || ipv4_is_private_10(addr) ||
- ipv4_is_loopback(addr) || ipv4_is_linklocal_169(addr) ||
- ipv4_is_private_172(addr) || ipv4_is_test_192(addr) ||
- ipv4_is_anycast_6to4(addr) || ipv4_is_private_192(addr) ||
- ipv4_is_test_198(addr) || ipv4_is_multicast(addr) ||
- ipv4_is_lbcast(addr)) ? 0x00 : 0x02;
+ eui[0] = (ipv4_addr_zeronet(addr) || ipv4_addr_private_10(addr) ||
+ ipv4_addr_loopback(addr) || ipv4_addr_linklocal_169(addr) ||
+ ipv4_addr_private_172(addr) || ipv4_addr_test_192(addr) ||
+ ipv4_addr_anycast_6to4(addr) || ipv4_addr_private_192(addr) ||
+ ipv4_addr_test_198(addr) || ipv4_addr_multicast(addr) ||
+ ipv4_addr_lbcast(addr)) ? 0x00 : 0x02;
eui[1] = 0;
eui[2] = 0x5E;
eui[3] = 0xFE;
diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c
index 61d8b75..823875c 100644
--- a/net/l2tp/l2tp_ip.c
+++ b/net/l2tp/l2tp_ip.c
@@ -303,7 +303,7 @@ static int l2tp_ip_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len
if (addr_len < sizeof(*lsa))
return -EINVAL;
- if (ipv4_is_multicast(lsa->l2tp_addr.s_addr))
+ if (ipv4_addr_multicast(lsa->l2tp_addr.s_addr))
return -EINVAL;
rc = ip4_datagram_connect(sk, uaddr, addr_len);
diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c
index 9275471..edc8da9 100644
--- a/net/l2tp/l2tp_ip6.c
+++ b/net/l2tp/l2tp_ip6.c
@@ -371,7 +371,7 @@ static int l2tp_ip6_connect(struct sock *sk, struct sockaddr *uaddr,
if (addr_type & IPV6_ADDR_MAPPED) {
daddr = &usin->sin6_addr;
- if (ipv4_is_multicast(daddr->s6_addr32[3]))
+ if (ipv4_addr_multicast(daddr->s6_addr32[3]))
return -EINVAL;
}
diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
index cc4c809..aeee744 100644
--- a/net/netfilter/ipvs/ip_vs_xmit.c
+++ b/net/netfilter/ipvs/ip_vs_xmit.c
@@ -201,7 +201,7 @@ __ip_vs_get_out_rt(struct sk_buff *skb, struct ip_vs_dest *dest,
ip_rt_put(rt);
return NULL;
}
- if (unlikely(!local && ipv4_is_loopback(ip_hdr(skb)->saddr))) {
+ if (unlikely(!local && ipv4_addr_loopback(ip_hdr(skb)->saddr))) {
IP_VS_DBG_RL("Stopping traffic from loopback address %pI4 "
"to non-local address, dest: %pI4\n",
&ip_hdr(skb)->saddr, &daddr);
@@ -604,7 +604,7 @@ ip_vs_nat_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
#endif
/* From world but DNAT to loopback address? */
- if (local && ipv4_is_loopback(cp->daddr.ip) &&
+ if (local && ipv4_addr_loopback(cp->daddr.ip) &&
rt_is_input_route(skb_rtable(skb))) {
IP_VS_DBG_RL_PKT(1, AF_INET, pp, skb, 0, "ip_vs_nat_xmit(): "
"stopping DNAT to loopback address");
@@ -1239,7 +1239,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
#endif
/* From world but DNAT to loopback address? */
- if (local && ipv4_is_loopback(cp->daddr.ip) &&
+ if (local && ipv4_addr_loopback(cp->daddr.ip) &&
rt_is_input_route(skb_rtable(skb))) {
IP_VS_DBG(1, "%s(): "
"stopping DNAT to loopback %pI4\n",
diff --git a/net/netfilter/xt_cluster.c b/net/netfilter/xt_cluster.c
index f4af1bf..266faf0 100644
--- a/net/netfilter/xt_cluster.c
+++ b/net/netfilter/xt_cluster.c
@@ -72,7 +72,7 @@ xt_cluster_is_multicast_addr(const struct sk_buff *skb, u_int8_t family)
switch(family) {
case NFPROTO_IPV4:
- is_multicast = ipv4_is_multicast(ip_hdr(skb)->daddr);
+ is_multicast = ipv4_addr_multicast(ip_hdr(skb)->daddr);
break;
case NFPROTO_IPV6:
is_multicast =
diff --git a/net/netfilter/xt_pkttype.c b/net/netfilter/xt_pkttype.c
index 5b645cb..c65c5c9 100644
--- a/net/netfilter/xt_pkttype.c
+++ b/net/netfilter/xt_pkttype.c
@@ -31,7 +31,7 @@ pkttype_mt(const struct sk_buff *skb, struct xt_action_param *par)
if (skb->pkt_type != PACKET_LOOPBACK)
type = skb->pkt_type;
else if (par->family == NFPROTO_IPV4 &&
- ipv4_is_multicast(ip_hdr(skb)->daddr))
+ ipv4_addr_multicast(ip_hdr(skb)->daddr))
type = PACKET_MULTICAST;
else if (par->family == NFPROTO_IPV6 &&
ipv6_hdr(skb)->daddr.s6_addr[0] == 0xFF)
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 2d51842..405cefc 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -406,13 +406,13 @@ static sctp_scope_t sctp_v4_scope(union sctp_addr *addr)
/* Check for unusable SCTP addresses. */
if (IS_IPV4_UNUSABLE_ADDRESS(addr->v4.sin_addr.s_addr)) {
retval = SCTP_SCOPE_UNUSABLE;
- } else if (ipv4_is_loopback(addr->v4.sin_addr.s_addr)) {
+ } else if (ipv4_addr_loopback(addr->v4.sin_addr.s_addr)) {
retval = SCTP_SCOPE_LOOPBACK;
- } else if (ipv4_is_linklocal_169(addr->v4.sin_addr.s_addr)) {
+ } else if (ipv4_addr_linklocal_169(addr->v4.sin_addr.s_addr)) {
retval = SCTP_SCOPE_LINK;
- } else if (ipv4_is_private_10(addr->v4.sin_addr.s_addr) ||
- ipv4_is_private_172(addr->v4.sin_addr.s_addr) ||
- ipv4_is_private_192(addr->v4.sin_addr.s_addr)) {
+ } else if (ipv4_addr_private_10(addr->v4.sin_addr.s_addr) ||
+ ipv4_addr_private_172(addr->v4.sin_addr.s_addr) ||
+ ipv4_addr_private_192(addr->v4.sin_addr.s_addr)) {
retval = SCTP_SCOPE_PRIVATE;
} else {
retval = SCTP_SCOPE_GLOBAL;
--
1.7.8.111.gad25c.dirty
^ permalink raw reply related
* [PATCH net-next 17/21] infiniband: Convert ipv4_is_<foo> uses to ipv4_addr_<foo>
From: Joe Perches @ 2012-10-19 4:15 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel
In-Reply-To: <cover.1350618006.git.joe@perches.com>
Use the new ipv4_addr_<foo> functions to be consistent with
the ipv6_addr_<foo> and eth_addr_<foo> style.
Signed-off-by: Joe Perches <joe@perches.com>
---
drivers/infiniband/core/cma.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index a7568c3..108f96f 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -683,7 +683,7 @@ static inline int cma_zero_addr(struct sockaddr *addr)
struct in6_addr *ip6;
if (addr->sa_family == AF_INET)
- return ipv4_is_zeronet(
+ return ipv4_addr_zeronet(
((struct sockaddr_in *)addr)->sin_addr.s_addr);
else {
ip6 = &((struct sockaddr_in6 *) addr)->sin6_addr;
@@ -695,7 +695,7 @@ static inline int cma_zero_addr(struct sockaddr *addr)
static inline int cma_loopback_addr(struct sockaddr *addr)
{
if (addr->sa_family == AF_INET)
- return ipv4_is_loopback(
+ return ipv4_addr_loopback(
((struct sockaddr_in *) addr)->sin_addr.s_addr);
else
return ipv6_addr_loopback(
--
1.7.8.111.gad25c.dirty
^ permalink raw reply related
* [PATCH net-next 18/21] ath6kl: Convert ipv4_is_<foo> uses to ipv4_addr_<foo>
From: Joe Perches @ 2012-10-19 4:15 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel
In-Reply-To: <cover.1350618006.git.joe@perches.com>
Use the new ipv4_addr_<foo> functions to be consistent with
the ipv6_addr_<foo> and eth_addr_<foo> style.
Signed-off-by: Joe Perches <joe@perches.com>
---
drivers/net/wireless/ath/ath6kl/wmi.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c
index c30ab4b..a5624f5 100644
--- a/drivers/net/wireless/ath/ath6kl/wmi.c
+++ b/drivers/net/wireless/ath/ath6kl/wmi.c
@@ -2547,8 +2547,8 @@ int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, u8 if_idx,
int ret;
/* Multicast address are not valid */
- if (ipv4_is_multicast(ips0) ||
- ipv4_is_multicast(ips1))
+ if (ipv4_addr_multicast(ips0) ||
+ ipv4_addr_multicast(ips1))
return -EINVAL;
skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_ip_cmd));
--
1.7.8.111.gad25c.dirty
^ permalink raw reply related
* [PATCH net-next 19/21] parisc: Convert ipv4_is_<foo> uses to ipv4_addr_<foo>
From: Joe Perches @ 2012-10-19 4:15 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel
In-Reply-To: <cover.1350618006.git.joe@perches.com>
Use the new ipv4_addr_<foo> functions to be consistent with
the ipv6_addr_<foo> and eth_addr_<foo> style.
Signed-off-by: Joe Perches <joe@perches.com>
---
drivers/parisc/led.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/parisc/led.c b/drivers/parisc/led.c
index f2f501e..8951fd1 100644
--- a/drivers/parisc/led.c
+++ b/drivers/parisc/led.c
@@ -369,7 +369,7 @@ static __inline__ int led_get_net_activity(void)
struct in_device *in_dev = __in_dev_get_rcu(dev);
if (!in_dev || !in_dev->ifa_list)
continue;
- if (ipv4_is_loopback(in_dev->ifa_list->ifa_local))
+ if (ipv4_addr_loopback(in_dev->ifa_list->ifa_local))
continue;
stats = dev_get_stats(dev, &temp);
rx_total += stats->rx_packets;
--
1.7.8.111.gad25c.dirty
^ permalink raw reply related
* [PATCH net-next 20/21] lockd: Convert ipv4_is_<foo> uses to ipv4_addr_<foo>
From: Joe Perches @ 2012-10-19 4:15 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel
In-Reply-To: <cover.1350618006.git.joe@perches.com>
Use the new ipv4_addr_<foo> functions to be consistent with
the ipv6_addr_<foo> and eth_addr_<foo> style.
Signed-off-by: Joe Perches <joe@perches.com>
---
include/linux/lockd/lockd.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index f5a051a..8fa00e0 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -301,7 +301,7 @@ static inline int __nlm_privileged_request4(const struct sockaddr *sap)
if (ntohs(sin->sin_port) > 1023)
return 0;
- return ipv4_is_loopback(sin->sin_addr.s_addr);
+ return ipv4_addr_loopback(sin->sin_addr.s_addr);
}
#if IS_ENABLED(CONFIG_IPV6)
@@ -313,7 +313,7 @@ static inline int __nlm_privileged_request6(const struct sockaddr *sap)
return 0;
if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_MAPPED)
- return ipv4_is_loopback(sin6->sin6_addr.s6_addr32[3]);
+ return ipv4_addr_loopback(sin6->sin6_addr.s6_addr32[3]);
return ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LOOPBACK;
}
--
1.7.8.111.gad25c.dirty
^ permalink raw reply related
* [PATCH net-next 21/21] sctp: Convert ipv4_is_<foo> uses to ipv4_addr_<foo>
From: Joe Perches @ 2012-10-19 4:15 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel
In-Reply-To: <cover.1350618006.git.joe@perches.com>
Use the new ipv4_addr_<foo> functions to be consistent with
the ipv6_addr_<foo> and eth_addr_<foo> style.
Signed-off-by: Joe Perches <joe@perches.com>
---
include/net/sctp/constants.h | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/net/sctp/constants.h b/include/net/sctp/constants.h
index d053d2e..31bae2f 100644
--- a/include/net/sctp/constants.h
+++ b/include/net/sctp/constants.h
@@ -365,12 +365,12 @@ typedef enum {
* Also, RFC 8.4, non-unicast addresses are not considered valid SCTP
* addresses.
*/
-#define IS_IPV4_UNUSABLE_ADDRESS(a) \
- ((htonl(INADDR_BROADCAST) == a) || \
- ipv4_is_multicast(a) || \
- ipv4_is_zeronet(a) || \
- ipv4_is_test_198(a) || \
- ipv4_is_anycast_6to4(a))
+#define IS_IPV4_UNUSABLE_ADDRESS(a) \
+ ((htonl(INADDR_BROADCAST) == a) || \
+ ipv4_addr_multicast(a) || \
+ ipv4_addr_zeronet(a) || \
+ ipv4_addr_test_198(a) || \
+ ipv4_addr_anycast_6to4(a))
/* Flags used for the bind address copy functions. */
#define SCTP_ADDR6_ALLOWED 0x00000001 /* IPv6 address is allowed by
--
1.7.8.111.gad25c.dirty
^ permalink raw reply related
* Re: listen(2) backlog changes in or around Linux 3.1?
From: Vijay Subramanian @ 2012-10-19 6:02 UTC (permalink / raw)
To: enh; +Cc: Venkat Venkatsubra, netdev, Eric Dumazet
In-Reply-To: <CAJgzZooJM7aj=K-idvdbwUOOmtDM6u-=gsVOs2OFZjiZwQP0zw@mail.gmail.com>
>> They all remain on ESTABLISHED state on the client side.
>
> yeah, that's what i see with netstat -t too.
>
> (https://android-review.googlesource.com/#/c/44563/), but i'd love to
> at least understand what's going on here, even if it's just that i
> have a fundamental misunderstanding of what the listen backlog is
> supposed to mean.
>
The listen backlog represents the number of received SYNs that have
not been processed i.e. for which a SYN-ACK has not been sent.
Actually, the number of SYNs
that can be pending for processing is actually backlog+1. With a
backlog of 1, there can be 2 SYNs that can be pending for processing.
Once a SYN is processed by the server socket (in LISTEN state) and a
syn-ack is sent back, a request_sock is created to represent it. Once
the client replies with the last step of connect() i.e. with an ack,
a fully established socket is created. The number of queued
request-socks for a LISTEN socket can be much more than the backlog
limit given in listen() (which is 1 in your case). If after a short
period (after SYNACK_RETRIES), the three way handshake is not
completed, request_socks can be silently discarded.
When a SYN is received, it is processed by tcp_v4_conn_request()
where we have..
if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1)
got drop;
So, for the SYN to be dropped, backlog limit must be exceeded _and_ we
must have recently accepted another SYN request. So, even when backlog
limit is exceeded, SYNs are processed and syn-acks are sent back. It
seems that the listen backlog limit is applied definitively only in
the third step in tcp_v4_syn_recv_sock() and not in the first step.
In tcp_v4_syn_recv_sock(), we have
if (sk_acceptq_is_full(sk))
goto exit_overflow;
This prevents the socket from being created fully. On the client side
however, since the three way handshake has finished, the socket goes
into ESTABLISHED state which is what you see with netstat. In your
test case, typically 2 connections are in state where SYN has to be
processed and rest are as request_sock where synacks have been sent.
However,
they may not become fully created sockets as they will fail in step 3
as described above.
man listen() says
" The backlog argument defines the maximum length to which the
queue of pending connections for sockfd may grow. " In your case where
backlog is 1, there can be a max of 2 pending connections (SYNs not
yet processed) and this is what we see. By this interpretation,
behavior seems correct.
Not sure if this behavior is a bug but the processing in
tcp_v4_conn_request() does look suspicious. Should we terminate
earlier without doing three way hand shake?
Perhaps someone who knows this better can clarify.
Hope this helps.
Vijay
^ permalink raw reply
* [PATCH 0/3] skbtrace v2: A trace infrastructure for networking subsystem
From: Li Yu @ 2012-10-19 6:16 UTC (permalink / raw)
To: Linux Netdev List
Hi,
This patch set introduces to the tracing infrastructure for networking
subsystem, they are based on v3.6 source code.
The changes from last version (v1):
1. IPv4 mapped IPv6 sockets support, I found many applications use
this mean to live on double stack environment.
2. The BPF filter for connection based events, skbtrace constructs
a temporarily sk_buff to run BPF program.
3. Add three TCP trace events for RTTM, show active connection
information, TCP internal timers. and show more states in
tcp_ca_state event.
4. Introduce to primary and secondary event support. That is secondary
event only would be exported after its primary event is triggered.
This could be used for reduce gathered trace points more, we can
see this is another kind of trace point filter.
5. Userland utility modularizaion.
6. Code refactoring and bug fixes.
I am going to add some sk_buff based events in next version (v3), so
we will could know such like how a sk_buff pass stack, how long it stay
in stack, how TSO/GSO/SACK/... split/merge them, and so on.
You can get whole kernel source tree at github:
https://github.com/Rover-Yu/skbtrace-userland
https://github.com/Rover-Yu/skbtrace-kernel
Welcome for suggestions.
Thanks.
Yu
^ permalink raw reply
* [PATCH 1/3] skbtrace v2: core feature and common events
From: Li Yu @ 2012-10-19 6:16 UTC (permalink / raw)
To: Linux Netdev List
From: Li Yu <bingtian.ly@taobao.com>
This patch contains:
1. The glue code of tracepoints subsystem and relay file system.
2. API for particular networking trace points.
3. The skb_rps_info trace point.
Thanks
Sign-off-by: Li Yu <bingtian.ly@taobao.com>
include/linux/skbtrace.h | 478 ++++++++++++
include/linux/skbtrace_api.h | 73 +
include/linux/skbuff.h | 7
include/net/skbtrace_api_common.h | 84 ++
include/net/sock.h | 14
include/trace/events/skbtrace.h | 32
include/trace/events/skbtrace_common.h | 41 +
kernel/trace/Kconfig | 8
net/core/Makefile | 2
net/core/dev.c | 3
net/core/net-traces.c | 24
net/core/skbtrace-core.c | 1226
+++++++++++++++++++++++++++++++++
net/core/skbtrace-events-common.c | 68 +
net/core/skbuff.c | 5
net/core/sock.c | 9
15 files changed, 2073 insertions(+), 1 deletion(-)
============================
diff --git a/include/linux/skbtrace.h b/include/linux/skbtrace.h
new file mode 100644
index 0000000..71fbff0
--- /dev/null
+++ b/include/linux/skbtrace.h
@@ -0,0 +1,478 @@
+/*
+ * skbtrace - sk_buff trace utilty
+ *
+ * API for kernel
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
+ *
+ * 2012 Li Yu <bingtian.ly@taobao.com>
+ *
+ */
+
+#ifndef _LINUX_SKBTRACE_H
+#define _LINUX_SKBTRACE_H
+
+#include <linux/jump_label.h>
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include <linux/net.h>
+#include <linux/skbtrace_api.h>
+#include <asm/atomic.h>
+
+#include <net/sock.h>
+#include <net/inet_timewait_sock.h>
+
+#if defined(CONFIG_SKBTRACE) || defined(CONFIG_SKBTRACE_MODULE)
+#define HAVE_SKBTRACE 1
+#else
+#define HAVE_SKBTRACE 0
+#endif
+
+#if HAVE_SKBTRACE
+
+/* The size parameters of secondary_buffer->slots */
+#define SECONDARY_BUFFER_ORDER 0
+#define SECONDARY_BUFFER_SIZE (PAGE_SIZE<<SECONDARY_BUFFER_ORDER)
+#define SECONDARY_BUFFER_UNIT (128)
+#define SECONDARY_BUFFER_COUNTS
(SECONDARY_BUFFER_SIZE/SECONDARY_BUFFER_UNIT)
+
+struct secondary_buffer {
+ atomic_t refcnt;
+ struct hlist_node node;
+ int action; /* the action of primary event */
+ spinlock_t lock;
+ unsigned long session;
+ int offset; /* next writeable slot */
+ int count; /* count of current cached events in 'slots' */
+ char *slots; /* the cache of secondary events */
+};
+
+
+#define SECONDARY_TABLE_SHIFT 6
+#define SECONDARY_TABLE_SIZE (1<<SECONDARY_TABLE_SHIFT)
+#define SECONDARY_TABLE_MASK (SECONDARY_TABLE_SIZE - 1)
+
+struct secondary_table {
+ spinlock_t lock;
+ struct hlist_head table[SECONDARY_TABLE_SIZE];
+};
+
+struct skbtrace_tracepoint {
+ const char *trace_name;
+ int action;
+ int nr_secondary;
+ size_t block_size;
+ void *probe;
+ int (*setup_options)(struct skbtrace_tracepoint *tp,
+ char *options);
+ void (*enable)(struct skbtrace_tracepoint *tp);
+ void (*disable)(struct skbtrace_tracepoint *tp);
+ char *(*desc)(struct skbtrace_tracepoint *tp);
+ void *private;
+
+ /* Below is for internals, which is not a part of kernel API */
+ unsigned int enabled : 1;
+ struct skbtrace_tracepoint *primary;
+ /* The secondary events of sk_buff based event are */
+ /* cached here. The secondary events of socket based */
+ /* event are cached in hash table skbtrace_context->sec_table */
+ struct secondary_buffer sec_buffer;
+};
+
+extern atomic64_t skbtrace_event_seq;
+extern int sysctl_skbtrace_filter_default;
+
+#define INIT_SKBTRACE_BLOCK(blk, p, act, fl, blk_size) \
+ do {\
+ (blk)->magic = 0xDEADBEEF;\
+ (blk)->len = (blk_size);\
+ (blk)->action = (act);\
+ (blk)->flags = (fl);\
+ (blk)->seq = atomic64_add_return(1, &skbtrace_event_seq);\
+ (blk)->ts = current_kernel_time();\
+ (blk)->ptr = (p);\
+ } while (0)
+
+#define EMPTY_SKBTRACE_TP {.trace_name = NULL, }
+
+struct inet_timewait_sock;
+struct skbtrace_ops {
+ int (*tw_getname)(struct inet_timewait_sock *tw,
+ struct sockaddr *uaddr, int peer);
+ int (*tw_filter_skb)(struct inet_timewait_sock *tw,
+ struct sk_buff *skb);
+ int (*getname)(struct sock *sk, struct sockaddr *uaddr,
+ int *uaddr_len, int peer);
+ int (*filter_skb)(struct sock *sk, struct sk_buff *skb);
+};
+
+struct skbtrace_context {
+ unsigned long session;
+ struct skbtrace_ops *ops;
+ unsigned int active_conn_hit : 1;
+ struct secondary_table sec_table;
+};
+
+extern unsigned long skbtrace_session;
+
+extern int skbtrace_register_proto(int af,
+ struct skbtrace_tracepoint *tp_list,
+ struct skbtrace_ops *ops);
+extern void skbtrace_unregister_proto(int af);
+extern struct skbtrace_ops* skbtrace_ops_get(int af);
+
+extern void __skbtrace_probe(struct skbtrace_tracepoint *tp,
+ struct skbtrace_context *ctx,
+ struct skbtrace_block *blk);
+extern int skbtrace_events_common_init(void);
+
+extern struct static_key skbtrace_filters_enabled;
+extern struct sk_filter *skbtrace_skb_filter;
+extern struct sk_filter *skbtrace_sock_filter;
+
+extern struct sk_buff* skbtrace_get_sock_filter_skb(struct sock *sk);
+static inline void skbtrace_put_sock_filter_skb(struct sk_buff *skb)
+{
+ skb->data = skb->head;
+ skb->len = 0;
+ skb_reset_tail_pointer(skb);
+ skb_reset_transport_header(skb);
+ skb_reset_network_header(skb);
+ local_bh_enable();
+}
+extern struct sk_buff* skbtrace_get_twsk_filter_skb(
+ struct inet_timewait_sock *tw);
+#define skbtrace_put_twsk_filter_skb skbtrace_put_sock_filter_skb
+
+static inline void skbtrace_probe(struct skbtrace_tracepoint *t,
+ struct skbtrace_context *ctx,
+ struct skbtrace_block *blk)
+{
+ if (skbtrace_action_invalid == blk->action)
+ return;
+ __skbtrace_probe(t, ctx, blk);
+}
+
+static inline int skbtrace_bypass_skb(struct sk_buff *skb)
+{
+ if (static_key_false(&skbtrace_filters_enabled)) {
+ if (skb->skbtrace_filtered)
+ return skb->hit_skbtrace;
+ else if (skbtrace_skb_filter) {
+ unsigned int pkt_len;
+
+ pkt_len = SK_RUN_FILTER(skbtrace_skb_filter, skb);
+ skb->hit_skbtrace = !pkt_len;
+ skb->skbtrace_filtered = 1;
+ return skb->hit_skbtrace;
+ }
+ }
+ return 0;
+}
+
+static inline void secondary_buffer_get(struct secondary_buffer *buf)
+{
+ atomic_inc(&buf->refcnt);
+}
+
+static inline void secondary_buffer_put(struct secondary_buffer *buf)
+{
+ if (buf && atomic_dec_and_test(&buf->refcnt)) {
+ free_pages((unsigned long)buf->slots, SECONDARY_BUFFER_ORDER);
+ buf->slots = NULL;
+ }
+}
+
+static inline void secondary_buffer_reset(struct secondary_buffer *buf)
+{
+ buf->offset = 0;
+ buf->count = 0;
+}
+
+static inline int secondary_buffer_init(struct secondary_buffer *buf,
+ struct skbtrace_tracepoint *tp)
+{
+ buf->slots = (char *)__get_free_pages(GFP_ATOMIC,
+ SECONDARY_BUFFER_ORDER);
+ if (!buf->slots)
+ return -ENOMEM;
+
+ INIT_HLIST_NODE(&buf->node);
+ spin_lock_init(&buf->lock);
+ buf->action = tp->action;
+ buf->session = skbtrace_session;
+ atomic_set(&buf->refcnt, 0);
+ secondary_buffer_reset(buf);
+ secondary_buffer_get(buf);
+ return 0;
+}
+
+static inline struct secondary_buffer* secondary_buffer_new(
+ struct skbtrace_tracepoint *tp)
+{
+ struct secondary_buffer *buf;
+
+ buf = kmalloc(sizeof(*buf), GFP_ATOMIC);
+ if (buf && secondary_buffer_init(buf, tp)) {
+ kfree(buf);
+ buf = NULL;
+ }
+ return buf;
+}
+
+static inline void secondary_buffer_destroy(struct secondary_buffer *buf)
+{
+ if (buf) {
+ secondary_buffer_put(buf);
+ kfree(buf);
+ }
+}
+
+static inline struct secondary_buffer* secondary_table_lookup(
+ struct secondary_table *table,
+ struct skbtrace_tracepoint *tp)
+{
+ unsigned int key;
+ struct secondary_buffer *buffer;
+ struct hlist_node *pos;
+
+ key = (47 * tp->action) & SECONDARY_TABLE_MASK;
+ spin_lock_bh(&table->lock);
+ hlist_for_each_entry(buffer, pos, &table->table[key], node) {
+ if (buffer->session != skbtrace_session)
+ continue;
+ if (buffer->action == tp->action)
+ goto unlock;
+ }
+ buffer = NULL;
+unlock:
+ spin_unlock_bh(&table->lock);
+
+ return buffer;
+}
+
+static inline struct secondary_buffer* secondary_table_lookup_or_create(
+ struct secondary_table *table,
+ struct skbtrace_tracepoint *tp)
+{
+ unsigned int key;
+ struct secondary_buffer *buffer;
+ struct hlist_node *pos;
+
+ key = (47 * tp->action) & SECONDARY_TABLE_MASK;
+ spin_lock_bh(&table->lock);
+ hlist_for_each_entry(buffer, pos, &table->table[key], node) {
+ if (buffer->session != skbtrace_session)
+ continue;
+ if (buffer->action == tp->action)
+ goto unlock;
+ }
+ buffer = secondary_buffer_new(tp);
+ if (buffer)
+ hlist_add_head(&buffer->node, &table->table[key]);
+unlock:
+ spin_unlock_bh(&table->lock);
+
+ return buffer;
+}
+
+static inline void secondary_table_clean(struct secondary_table *table)
+{
+ unsigned int key;
+
+ spin_lock_bh(&table->lock);
+ for (key = 0; key < SECONDARY_TABLE_SIZE; key++) {
+ while (!hlist_empty(&table->table[key])) {
+ struct secondary_buffer *buffer;
+
+ buffer = container_of(table->table[key].first,
+ struct secondary_buffer, node);
+ hlist_del(table->table[key].first);
+ secondary_buffer_destroy(buffer);
+ }
+ }
+ spin_unlock_bh(&table->lock);
+}
+
+static inline void secondary_table_init(struct secondary_table *table)
+{
+ unsigned int key;
+
+ spin_lock_init(&table->lock);
+ for (key = 0; key < SECONDARY_TABLE_SIZE; key++)
+ INIT_HLIST_HEAD(&table->table[key]);
+}
+
+extern struct skbtrace_context *skbtrace_context_get(struct sock *sk);
+extern void skbtrace_context_setup(struct skbtrace_context *ctx,
+ struct skbtrace_ops *ops);
+
+static inline void skbtrace_context_destroy(struct skbtrace_context **ctx)
+{
+ if (!*ctx)
+ return;
+ secondary_table_clean(&(*ctx)->sec_table);
+ kfree(*ctx);
+ *ctx = NULL;
+}
+
+static inline void sock_skbtrace_reset(struct sock *sk)
+{
+ sk->sk_skbtrace = NULL;
+}
+
+static inline void* secondary_buffer_get_block(struct secondary_buffer
*buf,
+ struct skbtrace_tracepoint *primary)
+{
+ void *ret;
+
+ if (!buf->slots && secondary_buffer_init(buf, primary))
+ return NULL;
+
+ spin_lock_bh(&buf->lock);
+ ret = &buf->slots[buf->offset * SECONDARY_BUFFER_UNIT];
+ if (buf->count < SECONDARY_BUFFER_COUNTS)
+ buf->count++;
+ if (++buf->offset >= SECONDARY_BUFFER_COUNTS)
+ buf->offset = 0;
+ spin_unlock_bh(&buf->lock);
+ return ret;
+}
+
+static inline void* skbtrace_block_get(struct skbtrace_tracepoint *tp,
+ struct skbtrace_context *ctx,
+ void *fast)
+{
+ struct skbtrace_tracepoint *pri;
+
+ if (!tp || !tp->primary)
+ return fast;
+
+ pri = tp->primary;
+ if (ctx) {
+ struct secondary_buffer *buf;
+ struct secondary_table *table;
+
+ table = &ctx->sec_table;
+ buf = secondary_table_lookup_or_create(table, pri);
+ if (!buf)
+ return fast;
+ return secondary_buffer_get_block(buf, pri) ? : fast;
+ }
+ return secondary_buffer_get_block(&pri->sec_buffer, pri) ? : fast;
+}
+
+static inline void* skbtrace_block_sk_get(struct skbtrace_tracepoint *tp,
+ struct sock *sk,
+ void *fast)
+{
+ return skbtrace_block_get(tp, skbtrace_context_get(sk), fast);
+}
+
+#define SKBTRACE_SKB_EVENT_BEGIN \
+{\
+ if (skbtrace_bypass_skb(skb)) {\
+ return; \
+ } else {
+
+#define SKBTRACE_SKB_EVENT_END \
+ } \
+}
+
+extern u32 skbtrace_sock_filter_id;
+static inline int skbtrace_bypass_sock(struct sock *sk)
+{
+ if (static_key_false(&skbtrace_filters_enabled)) {
+ if (likely(sk->sk_skbtrace_filtered &&
+ (skbtrace_sock_filter_id == sk->sk_skbtrace_fid))) {
+ return sk->sk_hit_skbtrace;
+ }
+ if (skbtrace_sock_filter) {
+ unsigned int pkt_len;
+ struct sk_buff *skb;
+
+ skb = skbtrace_get_sock_filter_skb(sk);
+ if (skb) {
+ pkt_len = SK_RUN_FILTER(skbtrace_sock_filter, skb);
+ sk->sk_hit_skbtrace = !pkt_len;
+ sk->sk_skbtrace_filtered = 1;
+ skbtrace_put_sock_filter_skb(skb);
+ sk->sk_skbtrace_fid = skbtrace_sock_filter_id;
+ return sk->sk_hit_skbtrace;
+ }
+ return sysctl_skbtrace_filter_default;
+ }
+ }
+ return 0;
+}
+
+static inline int skbtrace_bypass_twsk(struct inet_timewait_sock *tw)
+{
+ if (static_key_false(&skbtrace_filters_enabled)) {
+ if (likely(tw->tw_skbtrace_filtered &&
+ (skbtrace_sock_filter_id == tw->tw_skbtrace_fid))) {
+ return tw->tw_hit_skbtrace;
+ }
+ if (skbtrace_sock_filter) {
+ unsigned int pkt_len;
+ struct sk_buff *skb;
+
+ skb = skbtrace_get_twsk_filter_skb(tw);
+ if (skb) {
+ pkt_len = SK_RUN_FILTER(skbtrace_sock_filter, skb);
+ tw->tw_hit_skbtrace = !pkt_len;
+ tw->tw_skbtrace_filtered = 1;
+ skbtrace_put_twsk_filter_skb(skb);
+ tw->tw_skbtrace_fid = skbtrace_sock_filter_id;
+ return tw->tw_hit_skbtrace;
+ }
+ return sysctl_skbtrace_filter_default;
+ }
+ }
+ return 0;
+}
+
+#define SKBTRACE_SOCK_EVENT_BEGIN \
+{\
+ if (skbtrace_bypass_sock(sk)) {\
+ return; \
+ } else {
+
+#define SKBTRACE_SOCK_EVENT_END \
+ } \
+}
+
+extern int inet_filter_skb(struct sock *sk, struct sk_buff *skb);
+extern int inet_tw_getname(struct inet_timewait_sock *tw,
+ struct sockaddr *uaddr, int peer);
+extern int inet_tw_filter_skb(struct inet_timewait_sock *tw,
+ struct sk_buff *skb);
+extern int tcp_tw_filter_skb(struct inet_timewait_sock *tw,
+ struct sk_buff *skb);
+extern int tcp_filter_skb(struct sock *sk, struct sk_buff *skb);
+
+#else /* HAVE_SKBTRACE */
+
+static inline void sock_skbtrace_reset(struct sock *sk)
+{
+}
+
+static inline void skbtrace_context_destroy(struct skbtrace_context **ctx)
+{
+}
+
+#endif /* HAVE_SKBTRACE */
+
+#endif /* _LINUX_SKBTRACE_H */
diff --git a/include/linux/skbtrace_api.h b/include/linux/skbtrace_api.h
new file mode 100644
index 0000000..2d14ff6
--- /dev/null
+++ b/include/linux/skbtrace_api.h
@@ -0,0 +1,73 @@
+/*
+ * skbtrace - sk_buff trace utilty
+ *
+ * User/Kernel Interface
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
+ *
+ * 2012 Li Yu <bingtian.ly@taobao.com>
+ *
+ */
+#ifndef _LINUX_SKBTRACE_API_H
+#define _LINUX_SKBTRACE_API_H
+
+#include <linux/types.h>
+
+#ifdef __KERNEL__
+#include <linux/time.h>
+#else
+#include <time.h>
+#define __packed __attribute__ ((__packed__))
+#endif
+
+#define TRACE_SPEC_MAX_LEN 256
+
+#define SKBTRACE_DEF_SUBBUF_SIZE (1<<12)
+#define SKBTRACE_DEF_SUBBUF_NR (1<<11)
+
+#define SKBTRACE_MIN_SUBBUF_SIZE SKBTRACE_DEF_SUBBUF_SIZE
+#define SKBTRACE_MIN_SUBBUF_NR SKBTRACE_DEF_SUBBUF_NR
+
+#define SKBTRACE_MAX_SUBBUF_SIZE (1<<16)
+#define SKBTRACE_MAX_SUBBUF_NR (1<<20)
+
+#define SC 0 /* for tracepoints in process context */
+#define SI 1 /* for tracepoints in softirq context */
+#define HW 2 /* for tracepoints in hardirq context */
+#define NR_CHANNELS 3
+
+/* struct skbtrace_block - be used in kernel/user interaction */
+/* @len: whole data structure size in bytes */
+/* @action: action of this skbtrace_block */
+/* @flags: the flags depend on above action field */
+/* @ts: the timestamp of this event. */
+/* @ptr: the major source kernel data structure */
+/* of this event, for gerneral, a sk_buff or sock */
+/* PLEASE: */
+/* Keep 64 bits alignment */
+struct skbtrace_block {
+ __u64 magic;
+ __u16 len;
+ __u16 action;
+ __u32 flags;
+ struct timespec ts;
+ __u64 seq;
+ void *ptr;
+} __packed;
+
+#include <net/skbtrace_api_common.h>
+#include <net/skbtrace_api_ipv4.h>
+
+#endif
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 7632c87..27a0fe0 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -351,6 +351,8 @@ typedef unsigned char *sk_buff_data_t;
* @peeked: this packet has been seen already, so stats have been
* done for it, don't do them again
* @nf_trace: netfilter packet trace flag
+ * @hit_skbtrace: is this should be skipped by skbtrace filter?
+ * @skbtrace_filtered: is this already processed by skbtrace filter?
* @protocol: Packet protocol from driver
* @destructor: Destruct function
* @nfct: Associated connection, if any
@@ -469,7 +471,10 @@ struct sk_buff {
__u8 wifi_acked:1;
__u8 no_fcs:1;
__u8 head_frag:1;
- /* 8/10 bit hole (depending on ndisc_nodetype presence) */
+#if defined(CONFIG_SKBTRACE) || defined(CONFIG_SKBTRACE_MODULE)
+ __u8 hit_skbtrace:1;
+ __u8 skbtrace_filtered:1;
+#endif
kmemcheck_bitfield_end(flags2);
#ifdef CONFIG_NET_DMA
diff --git a/include/net/skbtrace_api_common.h
b/include/net/skbtrace_api_common.h
new file mode 100644
index 0000000..87892d6
--- /dev/null
+++ b/include/net/skbtrace_api_common.h
@@ -0,0 +1,84 @@
+/*
+ * skbtrace - sk_buff trace utilty
+ *
+ * User/Kernel Interface
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
+ *
+ * 2012 Li Yu <bingtian.ly@taobao.com>
+ *
+ */
+#ifndef _NET_SKBTRACE_API_COMMON_H
+#define _NET_SKBTRACE_API_COMMON_H
+
+#include <linux/types.h>
+
+/********************* Common section *********************/
+
+/* skbtrace_block->action */
+enum {
+ skbtrace_action_invalid = 0,
+ skbtrace_action_common_min = 1,
+ skbtrace_action_skb_rps_info = 1,
+ skbtrace_action_sk_timer = 2,
+ skbtrace_action_common_max = 99,
+};
+
+/* common skbtrace_block->flags */
+/* miss_secondary - none secondary events or no enough memory to cache
them */
+enum {
+ skbtrace_flags_reserved_min = 28,
+ skbtrace_flags_miss_secondary = 28,
+ skbtrace_flags_reserved_max = 31,
+};
+
+/* it is copied from <net/flow_keys.h>, except pad fields and packed */
+struct skbtrace_flow_keys {
+ __u32 src;
+ __u32 dst;
+ union {
+ __u32 ports;
+ __u16 port16[2];
+ };
+ __u32 ip_proto;
+} __packed;
+
+struct skbtrace_skb_rps_info_blk {
+ struct skbtrace_block blk;
+ __u16 rx_queue;
+ __u16 pad;
+ __u32 rx_hash;
+ __u32 cpu;
+ __u32 ifindex;
+ struct skbtrace_flow_keys keys;
+} __packed;
+
+
+/* socket timers */
+/* flags */
+enum {
+ skbtrace_sk_timer_setup = 0,
+ skbtrace_sk_timer_reset = 1,
+ skbtrace_sk_timer_stop = 2,
+ skbtrace_sk_timer_last = 3,
+};
+
+struct skbtrace_sk_timer_blk {
+ struct skbtrace_block blk;
+ __s32 proto;
+ __s32 timeout;
+} __packed;
+
+#endif
diff --git a/include/net/sock.h b/include/net/sock.h
index adb7da2..7a1d861 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -190,6 +190,8 @@ struct sock_common {
};
struct cg_proto;
+struct skbtrace_context;
+
/**
* struct sock - network layer representation of sockets
* @__sk_common: shared layout with inet_timewait_sock
@@ -332,7 +334,12 @@ struct sock {
sk_userlocks : 4,
sk_protocol : 8,
sk_type : 16;
+#if defined(CONFIG_SKBTRACE) || defined(CONFIG_SKBTRACE_MODULE)
+ unsigned int sk_hit_skbtrace : 1,
+ sk_skbtrace_filtered : 1;
+#endif
kmemcheck_bitfield_end(flags);
+ unsigned int sk_skbtrace_fid;
int sk_wmem_queued;
gfp_t sk_allocation;
netdev_features_t sk_route_caps;
@@ -373,6 +380,9 @@ struct sock {
__u32 sk_mark;
u32 sk_classid;
struct cg_proto *sk_cgrp;
+#if defined(CONFIG_SKBTRACE) || defined(CONFIG_SKBTRACE_MODULE)
+ struct skbtrace_context *sk_skbtrace;
+#endif
void (*sk_state_change)(struct sock *sk);
void (*sk_data_ready)(struct sock *sk, int bytes);
void (*sk_write_space)(struct sock *sk);
@@ -842,6 +852,10 @@ struct module;
* transport -> network interface is defined by struct inet_proto
*/
struct proto {
+#if defined(CONFIG_SKBTRACE) || defined(CONFIG_SKBTRACE_MODULE)
+ int (*filter_skb)(struct sock *sk,
+ struct sk_buff *skb);
+#endif
void (*close)(struct sock *sk,
long timeout);
int (*connect)(struct sock *sk,
diff --git a/include/trace/events/skbtrace.h
b/include/trace/events/skbtrace.h
new file mode 100644
index 0000000..91567bf
--- /dev/null
+++ b/include/trace/events/skbtrace.h
@@ -0,0 +1,32 @@
+/*
+ * skbtrace - sk_buff trace utilty
+ *
+ * Events
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
+ *
+ * 2012 Li Yu <bingtian.ly@taobao.com>
+ *
+ */
+
+#if !defined(_TRACE_EVENTS_SKBTRACE_H)
+#define _TRACE_EVENTS_SKBTRACE_H
+
+#include <linux/tracepoint.h>
+
+#include <trace/events/skbtrace_common.h>
+#include <trace/events/skbtrace_ipv4.h>
+
+#endif
diff --git a/include/trace/events/skbtrace_common.h
b/include/trace/events/skbtrace_common.h
new file mode 100644
index 0000000..4352564
--- /dev/null
+++ b/include/trace/events/skbtrace_common.h
@@ -0,0 +1,41 @@
+/*
+ * skbtrace - sk_buff trace utilty
+ *
+ * Comon events
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
+ *
+ * 2012 Li Yu <bingtian.ly@taobao.com>
+ *
+ */
+
+#if !defined(_TRACE_EVENTS_SKBTRACE_COMMON_H)
+#define _TRACE_EVENTS_SKBTRACE_COMMON_H
+
+#include <linux/tracepoint.h>
+
+struct sk_buff;
+struct net_device;
+struct timer_list;
+
+DECLARE_TRACE(skb_rps_info,
+ TP_PROTO(struct sk_buff *skb, struct net_device *dev, int cpu),
+ TP_ARGS(skb, dev, cpu));
+
+DECLARE_TRACE(sk_timer,
+ TP_PROTO(void *sk, struct timer_list *timer, int action),
+ TP_ARGS(sk, timer, action));
+
+#endif
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index 8c4c070..cc49b26 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -367,6 +367,14 @@ config BLK_DEV_IO_TRACE
If unsure, say N.
+config SKBTRACE
+ tristate "skbtrace : flexible networking tracing"
+ help
+ A blktrace like utility for networking subsystem, you can enable
this feature
+ as a kernel module.
+
+ If unsure, say N.
+
config KPROBE_EVENT
depends on KPROBES
depends on HAVE_REGS_AND_STACK_ACCESS_API
diff --git a/net/core/Makefile b/net/core/Makefile
index 674641b..6a80a85 100644
--- a/net/core/Makefile
+++ b/net/core/Makefile
@@ -18,6 +18,8 @@ obj-$(CONFIG_NETPOLL) += netpoll.o
obj-$(CONFIG_NET_DMA) += user_dma.o
obj-$(CONFIG_FIB_RULES) += fib_rules.o
obj-$(CONFIG_TRACEPOINTS) += net-traces.o
+obj-${CONFIG_SKBTRACE} += skbtrace.o
+skbtrace-objs := skbtrace-core.o skbtrace-events-common.o
obj-$(CONFIG_NET_DROP_MONITOR) += drop_monitor.o
obj-$(CONFIG_NETWORK_PHY_TIMESTAMPING) += timestamping.o
obj-$(CONFIG_NETPRIO_CGROUP) += netprio_cgroup.o
diff --git a/net/core/dev.c b/net/core/dev.c
index 89e33a5..b363716 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -129,6 +129,8 @@
#include <trace/events/napi.h>
#include <trace/events/net.h>
#include <trace/events/skb.h>
+#include <trace/events/skbtrace_common.h>
+#include <linux/skbtrace.h>
#include <linux/pci.h>
#include <linux/inetdevice.h>
#include <linux/cpu_rmap.h>
@@ -2813,6 +2815,7 @@ static int get_rps_cpu(struct net_device *dev,
struct sk_buff *skb,
}
done:
+ trace_skb_rps_info(skb, dev, cpu);
return cpu;
}
diff --git a/net/core/net-traces.c b/net/core/net-traces.c
index ba3c012..41e1766 100644
--- a/net/core/net-traces.c
+++ b/net/core/net-traces.c
@@ -21,6 +21,7 @@
#include <linux/netlink.h>
#include <linux/net_dropmon.h>
#include <linux/slab.h>
+#include <linux/skbtrace.h>
#include <asm/unaligned.h>
#include <asm/bitops.h>
@@ -31,7 +32,30 @@
#include <trace/events/napi.h>
#include <trace/events/sock.h>
#include <trace/events/udp.h>
+#include <trace/events/skbtrace.h>
EXPORT_TRACEPOINT_SYMBOL_GPL(kfree_skb);
EXPORT_TRACEPOINT_SYMBOL_GPL(napi_poll);
+
+#if HAVE_SKBTRACE
+
+#define NEW_SKBTRACE_TP(name) \
+ DEFINE_TRACE(name); \
+ EXPORT_TRACEPOINT_SYMBOL_GPL(name);
+
+NEW_SKBTRACE_TP(skb_rps_info);
+NEW_SKBTRACE_TP(sk_timer);
+
+NEW_SKBTRACE_TP(tcp_congestion);
+NEW_SKBTRACE_TP(tcp_connection);
+NEW_SKBTRACE_TP(icsk_connection);
+NEW_SKBTRACE_TP(tcp_sendlimit);
+NEW_SKBTRACE_TP(tcp_active_conn);
+NEW_SKBTRACE_TP(tcp_rttm);
+NEW_SKBTRACE_TP(tcp_ca_state);
+
+unsigned long skbtrace_session;
+EXPORT_SYMBOL(skbtrace_session);
+
+#endif
diff --git a/net/core/skbtrace-core.c b/net/core/skbtrace-core.c
new file mode 100644
index 0000000..2c2ac3e
--- /dev/null
+++ b/net/core/skbtrace-core.c
@@ -0,0 +1,1226 @@
+/*
+ * skbtrace - sk_buff trace utilty
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
+ *
+ * 2012 Li Yu <bingtian.ly@taobao.com>
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/relay.h>
+#include <linux/debugfs.h>
+#include <linux/slab.h>
+#include <linux/ctype.h>
+#include <linux/jhash.h>
+
+#include <linux/net.h>
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include <linux/filter.h>
+#include <linux/skbtrace.h>
+#include <net/sock.h>
+
+#define SKBTRACE_VERSION "1"
+#define SKBTRACE_DIR "skbtrace"
+
+static unsigned long skbtrace_dropped[NR_CHANNELS][NR_CPUS];
+/* +1 for quick indexing trick in __skbtrace_probe() */
+static struct rchan *skbtrace_channels[NR_CHANNELS + 1];
+
+int sysctl_skbtrace_filter_default = 0;
+EXPORT_SYMBOL_GPL(sysctl_skbtrace_filter_default);
+static struct sk_buff **sock_filter_skb;
+static struct sock_fprog skb_filter_fprog;
+static struct sock_fprog sock_filter_fprog;
+struct sk_filter *skbtrace_skb_filter;
+EXPORT_SYMBOL_GPL(skbtrace_skb_filter);
+
+u32 skbtrace_sock_filter_id;
+EXPORT_SYMBOL_GPL(skbtrace_sock_filter_id);
+struct sk_filter *skbtrace_sock_filter;
+EXPORT_SYMBOL_GPL(skbtrace_sock_filter);
+
+static struct dentry *skbtrace_dentry;
+static struct dentry *enabled_control;
+static struct dentry *dropped_control;
+static struct dentry *version_control;
+static struct dentry *subbuf_nr_control;
+static struct dentry *subbuf_size_control;
+static struct dentry *filters_control;
+static struct dentry *sock_filters_control;
+
+static const struct file_operations enabled_fops;
+static const struct file_operations dropped_fops;
+static const struct file_operations version_fops;
+static const struct file_operations subbuf_nr_fops;
+static const struct file_operations subbuf_size_fops;
+static const struct file_operations filters_fops;
+static const struct file_operations sock_filters_fops;
+
+static int nr_skbtrace_enabled_tp;
+static int subbuf_nr = SKBTRACE_DEF_SUBBUF_NR;
+static int subbuf_size = SKBTRACE_DEF_SUBBUF_SIZE;
+
+static bool should_load_proto;
+
+struct static_key skbtrace_filters_enabled = STATIC_KEY_INIT_FALSE;
+EXPORT_SYMBOL_GPL(skbtrace_filters_enabled);
+
+atomic64_t skbtrace_event_seq = ATOMIC64_INIT(0);
+EXPORT_SYMBOL_GPL(skbtrace_event_seq);
+
+/* protect agaist af_tp_list and skbtrace_channels */
+static struct mutex skbtrace_lock;
+static struct skbtrace_tracepoint *af_tp_list[AF_MAX];
+struct skbtrace_ops* skbtrace_ops[AF_MAX];
+
+static int create_controls(void);
+static void remove_controls(void);
+static int create_channels(void);
+static void flush_channels(void);
+static void destroy_channels(void);
+static ssize_t sk_filter_read(struct sock_fprog *fprog, char __user
*buffer,
+ size_t count);
+static ssize_t sk_filter_write(struct sock_fprog *sk_fprog,
+ struct sk_filter **sk_filter,
+ const char __user *buffer, size_t count);
+static void reset_filter(struct sock_fprog *fprog, struct sk_filter
**filter);
+static void skbtrace_filters_clean(void);
+
+struct skbtrace_ops* skbtrace_ops_get(int af)
+{
+ return skbtrace_ops[af];
+}
+EXPORT_SYMBOL_GPL(skbtrace_ops_get);
+
+static void skbtrace_proto_load(void)
+{
+ int af;
+
+ if (!should_load_proto)
+ return;
+
+ should_load_proto = false;
+
+ for (af = AF_UNSPEC; af < AF_MAX; af++) {
+ /* load proto-specific events */
+ if (!af_tp_list[af])
+ request_module("skbtrace-af-%d", af);
+ }
+}
+
+void __skbtrace_block_probe(struct skbtrace_block *blk)
+{
+ unsigned int chan_id;
+ struct rchan *rchan;
+
+ chan_id = (!!in_irq()) << 1;
+ chan_id |= !!in_softirq(); /* make sparse happy */
+ rchan = skbtrace_channels[chan_id];
+
+ if (unlikely(chan_id >= HW))
+ relay_write(rchan, blk, blk->len);
+ else {
+ local_bh_disable();
+ __relay_write(rchan, blk, blk->len);
+ local_bh_enable();
+ }
+ blk->action = skbtrace_action_invalid;
+}
+
+void __skbtrace_do_probe(struct skbtrace_tracepoint *tp,
+ struct skbtrace_context *ctx,
+ struct skbtrace_block *blk)
+{
+ int i;
+ char *sec_blk;
+ struct secondary_buffer *buf;
+
+ if (ctx)
+ buf = secondary_table_lookup(&ctx->sec_table, tp);
+ else
+ buf = &tp->sec_buffer;
+
+ if (!buf) {
+ if (tp->nr_secondary)
+ blk->flags |= 1<<skbtrace_flags_miss_secondary;
+ goto quit;
+ }
+
+ spin_lock_bh(&buf->lock);
+ for (i = 0; i < buf->count; i++) {
+ if (--buf->offset < 0)
+ buf->offset = SECONDARY_BUFFER_COUNTS - 1;
+ sec_blk = &buf->slots[buf->offset * SECONDARY_BUFFER_UNIT];
+ __skbtrace_block_probe((struct skbtrace_block*)sec_blk);
+ }
+ secondary_buffer_reset(buf);
+ spin_unlock_bh(&buf->lock);
+
+quit:
+ __skbtrace_block_probe(blk);
+}
+
+void __skbtrace_probe(struct skbtrace_tracepoint *tp,
+ struct skbtrace_context *ctx,
+ struct skbtrace_block *blk)
+{
+ if (!tp)
+ return;
+ if (!tp->primary)
+ __skbtrace_do_probe(tp, ctx, blk);
+}
+EXPORT_SYMBOL_GPL(__skbtrace_probe);
+
+static void __skbtrace_setup_tracepoints(struct skbtrace_tracepoint
*tp_list)
+{
+ struct skbtrace_tracepoint *tp;
+
+ tp = tp_list;
+ while (tp && tp->trace_name) {
+ secondary_buffer_init(&tp->sec_buffer, tp);
+ tp->primary = NULL;
+ tp->enabled = 0;
+ tp++;
+ }
+}
+
+static int __skbtrace_register_tracepoints(int af,
+ struct skbtrace_tracepoint *tp_list)
+{
+ int ret = 0;
+
+ if (af_tp_list[af])
+ ret = -EEXIST;
+
+ if (tp_list) {
+ __skbtrace_setup_tracepoints(tp_list);
+ if (tp_list[0].trace_name)
+ af_tp_list[af] = tp_list;
+ else
+ ret = -EINVAL;
+ } else
+ af_tp_list[af] = NULL;
+
+ return ret;
+}
+
+static void __skbtrace_unregister_tracepoints(int af)
+{
+ struct skbtrace_tracepoint *tp;
+
+ tp = af_tp_list[af];
+ while (tp && tp->trace_name) {
+ if (tp->enabled) {
+ tp->enabled = 0;
+ --nr_skbtrace_enabled_tp;
+ tracepoint_probe_unregister(tp->trace_name,
+ tp->probe, tp);
+ secondary_buffer_put(&tp->sec_buffer);
+ }
+ tp++;
+ }
+ af_tp_list[af] = NULL;
+}
+
+static inline int __skbtrace_register_ops(int af, struct skbtrace_ops *ops)
+{
+ if (skbtrace_ops[af])
+ return -EEXIST;
+ skbtrace_ops[af] = ops;
+ return 0;
+}
+
+static inline void __skbtrace_unregister_ops(int af)
+{
+ skbtrace_ops[af] = NULL;
+}
+
+int skbtrace_register_proto(int af,
+ struct skbtrace_tracepoint *tp_list,
+ struct skbtrace_ops *ops)
+{
+ int ret;
+
+ if (af < 0 || af >= AF_MAX)
+ return -EINVAL;
+
+ mutex_lock(&skbtrace_lock);
+ ret = __skbtrace_register_tracepoints(af, tp_list);
+ if (!ret) {
+ ret = __skbtrace_register_ops(af, ops);
+ if (ret)
+ __skbtrace_unregister_tracepoints(af);
+ }
+ mutex_unlock(&skbtrace_lock);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(skbtrace_register_proto);
+
+void skbtrace_unregister_proto(int af)
+{
+ if (af < 0 || af >= AF_MAX)
+ return;
+
+ mutex_lock(&skbtrace_lock);
+ __skbtrace_unregister_tracepoints(af);
+ __skbtrace_unregister_ops(af);
+ mutex_unlock(&skbtrace_lock);
+
+ flush_channels();
+ should_load_proto = true;
+}
+EXPORT_SYMBOL_GPL(skbtrace_unregister_proto);
+
+void skbtrace_context_setup(struct skbtrace_context *ctx,
+ struct skbtrace_ops *ops)
+{
+ ctx->ops = ops;
+ ctx->session = skbtrace_session;
+ secondary_table_init(&ctx->sec_table);
+}
+EXPORT_SYMBOL(skbtrace_context_setup);
+
+struct skbtrace_context *skbtrace_context_get(struct sock *sk)
+{
+ struct skbtrace_ops *ops;
+ struct skbtrace_context *ctx;
+
+ ops = skbtrace_ops_get(sk->sk_family);
+ if (!ops)
+ return NULL;
+ local_bh_disable();
+
+ if (sk->sk_skbtrace &&
+ (skbtrace_session != sk->sk_skbtrace->session))
+ skbtrace_context_destroy(&sk->sk_skbtrace);
+
+ if (!sk->sk_skbtrace) {
+ ctx = kzalloc(sizeof(struct skbtrace_context), GFP_ATOMIC);
+ if (likely(ctx)) {
+ skbtrace_context_setup(ctx, ops);
+ sk->sk_skbtrace = ctx;
+ }
+ }
+
+ local_bh_enable();
+ return sk->sk_skbtrace;
+}
+EXPORT_SYMBOL(skbtrace_context_get);
+
+static int subbuf_start_handler(struct rchan_buf *buf,
+ void *subbuf,
+ void *prev_subbuf,
+ size_t prev_padding)
+{
+ if (relay_buf_full(buf)) {
+ long trace, cpu;
+
+ trace = (long)buf->chan->private_data;
+ cpu = buf->cpu;
+ skbtrace_dropped[trace][cpu]++;
+ return 0;
+ }
+ return 1;
+}
+
+static struct dentry *create_buf_file_handler(const char *filename,
+ struct dentry *parent,
+ umode_t mode,
+ struct rchan_buf *buf,
+ int *is_global)
+{
+ return debugfs_create_file(filename, mode, parent, buf,
+ &relay_file_operations);
+}
+
+static int remove_buf_file_handler(struct dentry *dentry)
+{
+ debugfs_remove(dentry);
+ return 0;
+}
+
+static struct rchan_callbacks relayfs_callbacks = {
+ .subbuf_start = subbuf_start_handler,
+ .create_buf_file = create_buf_file_handler,
+ .remove_buf_file = remove_buf_file_handler,
+};
+
+/* caller must hold skbtrace_lock */
+static int create_channels(void)
+{
+ unsigned long i, created;
+ const char *skbtrace_names[NR_CHANNELS] = { "trace.syscall.cpu",
+ "trace.softirq.cpu",
+ "trace.hardirq.cpu" };
+ created = 0;
+ for (i = 0; i < NR_CHANNELS; i++) {
+ if (skbtrace_channels[i])
+ continue;
+ skbtrace_channels[i] = relay_open(skbtrace_names[i],
+ skbtrace_dentry, subbuf_size, subbuf_nr,
+ &relayfs_callbacks, (void *)i);
+ if (!skbtrace_channels[i]) {
+ destroy_channels();
+ return -ENOMEM;
+ }
+ created = 1;
+ }
+ skbtrace_channels[HW + 1] = skbtrace_channels[HW];
+
+ if (created)
+ __module_get(THIS_MODULE);
+ return 0;
+}
+
+static void flush_channels(void)
+{
+ int i;
+ for (i = 0; i < NR_CHANNELS; i++) {
+ if (skbtrace_channels[i])
+ relay_flush(skbtrace_channels[i]);
+ }
+}
+
+/* caller must hold skbtrace_lock */
+static void destroy_channels(void)
+{
+ int i, removed;
+
+ removed = 0;
+ for (i = 0; i < NR_CHANNELS; i++) {
+ if (skbtrace_channels[i]) {
+ relay_flush(skbtrace_channels[i]);
+ relay_close(skbtrace_channels[i]);
+ skbtrace_channels[i] = NULL;
+ removed = 1;
+ }
+ }
+ skbtrace_channels[HW + 1] = NULL;
+
+ if (removed)
+ module_put(THIS_MODULE);
+}
+
+static void remove_controls(void)
+{
+#define REMOVE_DEBUGFS_FILE(name) \
+ do {\
+ if (name##_control) \
+ debugfs_remove(name##_control); \
+ } while(0);
+
+ REMOVE_DEBUGFS_FILE(enabled)
+ REMOVE_DEBUGFS_FILE(dropped)
+ REMOVE_DEBUGFS_FILE(version)
+ REMOVE_DEBUGFS_FILE(subbuf_nr)
+ REMOVE_DEBUGFS_FILE(subbuf_size)
+ REMOVE_DEBUGFS_FILE(filters)
+ REMOVE_DEBUGFS_FILE(sock_filters)
+}
+
+static int create_controls(void)
+{
+#define CREATE_DEBUGFS_FILE(name)\
+ do {\
+ name##_control = debugfs_create_file(#name, 0,\
+ skbtrace_dentry, NULL, &name##_fops);\
+ if (name##_control)\
+ break;\
+ pr_err("skbtrace: couldn't create relayfs file '" #name "'\n");\
+ goto fail;\
+ } while (0);
+
+ CREATE_DEBUGFS_FILE(enabled)
+ CREATE_DEBUGFS_FILE(dropped)
+ CREATE_DEBUGFS_FILE(version)
+ CREATE_DEBUGFS_FILE(subbuf_nr)
+ CREATE_DEBUGFS_FILE(subbuf_size)
+ CREATE_DEBUGFS_FILE(filters)
+ CREATE_DEBUGFS_FILE(sock_filters)
+
+#undef CREATE_DEBUGFS_FILE
+ return 0;
+fail:
+ remove_controls();
+ return -1;
+}
+
+static char *skbtrace_tracepoint_default_desc(struct
skbtrace_tracepoint *t)
+{
+ char *desc;
+ int n;
+
+ n = strlen(t->trace_name) + 64;
+ desc = kmalloc(n, GFP_KERNEL);
+ if (!desc)
+ return NULL;
+
+ snprintf(desc, n, "%s enabled:%d\n", t->trace_name, !!t->enabled);
+ return desc;
+}
+
+static char *skbtrace_tracepoint_desc(struct skbtrace_tracepoint *tp)
+{
+ if (tp->desc)
+ return tp->desc(tp);
+ return skbtrace_tracepoint_default_desc(tp);
+}
+
+static ssize_t enabled_read(struct file *filp, char __user *buffer,
+ size_t count, loff_t *ppos)
+{
+ size_t ret, offset, len;
+ struct skbtrace_tracepoint *tp;
+ int af;
+ char *desc = NULL;
+
+ skbtrace_proto_load();
+
+ ret = offset = 0;
+ mutex_lock(&skbtrace_lock);
+ for (af = AF_UNSPEC; af < AF_MAX; af++) {
+ tp = af_tp_list[af];
+ while (tp && tp->trace_name) {
+ kfree(desc);
+ desc = skbtrace_tracepoint_desc(tp);
+ if (!desc)
+ return -ENOMEM;
+ len = strlen(desc);
+ offset += len;
+ if (offset <= *ppos) {
+ ++tp;
+ continue;
+ }
+ if (count < len) {
+ ret = -EINVAL;
+ goto unlock;
+ }
+ if (copy_to_user(buffer, desc, len)) {
+ ret = -EFAULT;
+ goto unlock;
+ }
+ *ppos += len;
+ ret = len;
+ goto unlock;
+ }
+ }
+unlock:
+ kfree(desc);
+ mutex_unlock(&skbtrace_lock);
+
+ return ret;
+}
+
+static struct skbtrace_tracepoint *skbtrace_lookup_tp(char *name)
+{
+ int af;
+ struct skbtrace_tracepoint *tp;
+
+ for (af = AF_UNSPEC; af < AF_MAX; af++) {
+ tp = af_tp_list[af];
+ while (tp && tp->trace_name) {
+ if (!strcmp(name, tp->trace_name))
+ return tp;
+ ++tp;
+ }
+ }
+
+ return NULL;
+}
+
+struct skbtrace_options_context {
+ char *name;
+ char *options;
+ struct skbtrace_tracepoint *primary;
+};
+
+struct option_handler {
+ char *key;
+ int (*handler)(struct skbtrace_options_context *ctx, char *val);
+};
+
+static int handle_primary_option(struct skbtrace_options_context *ctx,
char *val)
+{
+ ctx->primary = skbtrace_lookup_tp(val);
+ if (!ctx->primary)
+ return -EINVAL;
+ return 0;
+}
+
+static struct option_handler common_handlers[] = {
+ {
+ .key = "primary=",
+ .handler = handle_primary_option,
+ },
+ {
+ .key = NULL,
+ },
+};
+
+static int handle_options(char *event_spec, struct option_handler
*handlers,
+ struct skbtrace_options_context *ctx)
+{
+ char *option;
+
+ memset(ctx, 0, sizeof(*ctx));
+ ctx->options = strchr(event_spec, ',');
+ if (!ctx->options)
+ return 0;
+ *(ctx->options) = '\x0';
+ option = ++(ctx->options);
+
+ while (option && *option) {
+ char *end;
+ struct option_handler *h;
+
+ end = strchr(option, ',');
+ if (end)
+ *end = '\x0';
+ h = &handlers[0];
+ while (h->key) {
+ if (strstr(option, h->key) == option) {
+ int ret;
+ char *val;
+
+ val = option + strlen(h->key);
+ ret = h->handler(ctx, val);
+ if (!ret)
+ break;
+ else
+ return -EINVAL;
+ }
+ h++;
+ }
+ if (!h->key) {
+ if (end) {
+ *end = ',';
+ option = end + 1;
+ } else
+ break;
+ } else {
+ if (end) {
+ memmove(option, end + 1, strlen(end + 1) + 1);
+ } else
+ *option = '\x0';
+ }
+ }
+
+ return 0;
+}
+
+static int __enable_tp(struct skbtrace_tracepoint *tp,
+ struct skbtrace_options_context *ctx)
+{
+ int ret = 0;
+
+ if (tp->enabled)
+ return -EBUSY;
+
+ if (tp->enable)
+ tp->enable(tp);
+ ret = tracepoint_probe_register(tp->trace_name, tp->probe, tp);
+ if (!ret) {
+ tp->primary = ctx->primary;
+ if (tp->primary)
+ tp->primary->nr_secondary++;
+ tp->enabled = 1;
+ } else {
+ if (tp->disable)
+ tp->disable(tp);
+ }
+
+ return ret;
+}
+
+static int __disable_tp(struct skbtrace_tracepoint *tp)
+{
+ int ret;
+
+ if (!tp->enabled)
+ return -EINVAL;
+
+ ret = tracepoint_probe_unregister(tp->trace_name, tp->probe, tp);
+ if (ret)
+ return ret;
+
+ if (tp->disable)
+ tp->disable(tp);
+ if (tp->primary) {
+ secondary_buffer_put(&tp->primary->sec_buffer);
+ tp->primary->nr_secondary--;
+ }
+ tp->enabled = 0;
+ return 0;
+}
+
+static int skbtrace_enable_tp(char *event_spec)
+{
+ struct skbtrace_options_context ctx;
+ int ret;
+ struct skbtrace_tracepoint *tp;
+
+ ret = handle_options(event_spec, common_handlers, &ctx);
+ if (ret)
+ return ret;
+ ctx.name = event_spec;
+
+ mutex_lock(&skbtrace_lock);
+ if (!nr_skbtrace_enabled_tp) {
+ ret = create_channels();
+ if (ret)
+ goto unlock;
+ }
+
+ tp = skbtrace_lookup_tp(ctx.name);
+ if (!tp || tp->enabled) {
+ ret = -EINVAL;
+ goto unlock;
+ }
+
+ if (ctx.options && tp->setup_options) {
+ ret = tp->setup_options(tp, ctx.options);
+ if (ret)
+ goto unlock;
+ }
+
+ ret = __enable_tp(tp, &ctx);
+
+ if (ret && !nr_skbtrace_enabled_tp)
+ destroy_channels();
+ else if (!ret)
+ ++nr_skbtrace_enabled_tp;
+
+unlock:
+ mutex_unlock(&skbtrace_lock);
+ return ret;
+}
+
+static int skbtrace_disable_all_tp(void)
+{
+ int ret, af;
+ struct skbtrace_tracepoint *tp;
+
+ /*
+ * '-*' has two meanings:
+ *
+ * (0) first time, it disables all tracepoints, and flush channels.
+ * (1) second time, it removes all channels.
+ */
+
+ if (!nr_skbtrace_enabled_tp) {
+ skbtrace_filters_clean();
+ ++skbtrace_session;
+ destroy_channels();
+ return 0;
+ }
+
+ ret = -EINVAL;
+ mutex_lock(&skbtrace_lock);
+ for (af = AF_UNSPEC; af < AF_MAX; af++) {
+ tp = af_tp_list[af];
+ while (tp && tp->trace_name) {
+ ret = __disable_tp(tp);
+ if (!ret)
+ --nr_skbtrace_enabled_tp;
+ ++tp;
+ }
+ }
+ mutex_unlock(&skbtrace_lock);
+ flush_channels();
+
+ return ret;
+}
+
+/* The user given buffer should contains such like string:
+ * (0) To enable a skbtrace event: "TRACE_NAME,opt1=val1,opt2=val2,..."
+ * (1) To disable all skbtrace events:"-*"
+ */
+static ssize_t enabled_write(struct file *filp, const char __user *buffer,
+ size_t count, loff_t *ppos)
+{
+ char kbuf[TRACE_SPEC_MAX_LEN+1];
+ int ret;
+
+ skbtrace_proto_load();
+
+ if (count >= TRACE_SPEC_MAX_LEN)
+ return -EINVAL;
+ if (copy_from_user(kbuf, buffer, count))
+ return -EFAULT;
+ kbuf[count] = '\x0';
+
+ if (strcmp("-*", kbuf))
+ ret = skbtrace_enable_tp(&kbuf[0]);
+ else
+ ret = skbtrace_disable_all_tp();
+
+ return ret ?: count;
+}
+
+static int kmod_open(struct inode *inodep, struct file *filp)
+{
+ __module_get(THIS_MODULE);
+ return 0;
+}
+
+static int kmod_release(struct inode *inodep, struct file *filp)
+{
+ module_put(THIS_MODULE);
+ return 0;
+}
+
+static const struct file_operations enabled_fops = {
+ .owner = THIS_MODULE,
+ .open = kmod_open,
+ .release = kmod_release,
+ .read = enabled_read,
+ .write = enabled_write,
+};
+
+static ssize_t dropped_read(struct file *filp, char __user *buffer,
+ size_t count, loff_t *ppos)
+{
+
+ char buf[256];
+ unsigned long skbtrace_total_dropped[NR_CHANNELS] = {0, 0, 0};
+ int cpu;
+
+ for_each_possible_cpu(cpu) {
+ skbtrace_total_dropped[HW] += skbtrace_dropped[HW][cpu];
+ skbtrace_total_dropped[SI] += skbtrace_dropped[SI][cpu];
+ skbtrace_total_dropped[SC] += skbtrace_dropped[SC][cpu];
+ }
+
+ snprintf(buf, sizeof(buf), "%lu %lu %lu\n",
+ skbtrace_total_dropped[HW],
+ skbtrace_total_dropped[SI],
+ skbtrace_total_dropped[SC]
+ );
+
+ return simple_read_from_buffer(buffer, count, ppos,
+ buf, strlen(buf));
+}
+
+static ssize_t dropped_write(struct file *filp, const char __user *buffer,
+ size_t count, loff_t *ppos)
+{
+ memset(skbtrace_dropped, 0, sizeof(skbtrace_dropped));
+ return count;
+}
+
+static const struct file_operations dropped_fops = {
+ .owner = THIS_MODULE,
+ .open = kmod_open,
+ .release = kmod_release,
+ .read = dropped_read,
+ .write = dropped_write,
+};
+
+static ssize_t version_read(struct file *filp, char __user *buffer,
+ size_t count, loff_t *ppos)
+{
+ return simple_read_from_buffer(buffer, count, ppos,
+ SKBTRACE_VERSION "\n",
+ strlen(SKBTRACE_VERSION "\n"));
+}
+
+static const struct file_operations version_fops = {
+ .owner = THIS_MODULE,
+ .open = kmod_open,
+ .release = kmod_release,
+ .read = version_read,
+};
+
+static ssize_t subbuf_x_read(struct file *filp, char __user *buffer,
+ size_t count, loff_t *ppos, int which)
+{
+ char buf[24];
+
+ sprintf(buf, "%d\n", which);
+ return simple_read_from_buffer(buffer, count, ppos,
+ buf, strlen(buf));
+}
+
+static ssize_t subbuf_x_write(struct file *filp, const char __user *buffer,
+ size_t count, loff_t *ppos,
+ int *which, int min_val, int max_val)
+{
+ char buf[24];
+ int v;
+
+ if (nr_skbtrace_enabled_tp)
+ return -EBUSY;
+
+ if (!buffer || count > sizeof(buf) - 1)
+ return -EINVAL;
+ memset(buf, 0, sizeof(buf));
+ if (copy_from_user(buf, buffer, count))
+ return -EFAULT;
+ if (sscanf(buf, "%d", &v) != 1)
+ return -EINVAL;
+ if (v < min_val || v > max_val)
+ return -EINVAL;
+
+ *which = v;
+ return count;
+}
+
+static ssize_t subbuf_nr_read(struct file *filp, char __user *buffer,
+ size_t count, loff_t *ppos)
+{
+ return subbuf_x_read(filp, buffer, count, ppos, subbuf_nr);
+}
+
+static ssize_t subbuf_nr_write(struct file *filp, const char __user
*buffer,
+ size_t count, loff_t *ppos)
+{
+ return subbuf_x_write(filp, buffer, count, ppos, &subbuf_nr,
+ SKBTRACE_MIN_SUBBUF_NR, SKBTRACE_MAX_SUBBUF_NR);
+}
+
+static const struct file_operations subbuf_nr_fops = {
+ .owner = THIS_MODULE,
+ .open = kmod_open,
+ .release = kmod_release,
+ .read = subbuf_nr_read,
+ .write = subbuf_nr_write,
+};
+
+static ssize_t subbuf_size_read(struct file *filp, char __user *buffer,
+ size_t count, loff_t *ppos)
+{
+ return subbuf_x_read(filp, buffer, count, ppos, subbuf_size);
+}
+
+static ssize_t subbuf_size_write(struct file *filp, const char __user
*buffer,
+ size_t count, loff_t *ppos)
+{
+ return subbuf_x_write(filp, buffer, count, ppos, &subbuf_size,
+ SKBTRACE_MIN_SUBBUF_SIZE, SKBTRACE_MAX_SUBBUF_SIZE);
+}
+
+static const struct file_operations subbuf_size_fops = {
+ .owner = THIS_MODULE,
+ .open = kmod_open,
+ .release = kmod_release,
+ .read = subbuf_size_read,
+ .write = subbuf_size_write,
+};
+
+struct sk_buff* skbtrace_get_twsk_filter_skb(struct inet_timewait_sock *tw)
+{
+ unsigned int cpu;
+ struct sk_buff **p_skb;
+ int ret;
+ struct skbtrace_ops *ops;
+
+ local_bh_disable();
+
+ ops = skbtrace_ops_get(tw->tw_family);
+ if (!ops || !ops->filter_skb) {
+ local_bh_enable();
+ return NULL;
+ }
+
+ cpu = smp_processor_id();
+ p_skb = per_cpu_ptr(sock_filter_skb, cpu);
+ if (unlikely(!*p_skb)) {
+ *p_skb = alloc_skb(1500, GFP_ATOMIC);
+ if (!*p_skb) {
+ local_bh_enable();
+ return NULL;
+ }
+ }
+
+ ret = ops->tw_filter_skb(tw, *p_skb);
+ if (ret < 0) {
+ skbtrace_put_twsk_filter_skb(*p_skb);
+ return NULL;
+ }
+
+ return *p_skb;
+}
+EXPORT_SYMBOL_GPL(skbtrace_get_twsk_filter_skb);
+
+struct sk_buff* skbtrace_get_sock_filter_skb(struct sock *sk)
+{
+ unsigned int cpu;
+ struct sk_buff **p_skb;
+ int ret;
+ struct skbtrace_ops *ops;
+
+ local_bh_disable();
+
+ ops = skbtrace_ops_get(sk->sk_family);
+ if (!ops || !ops->filter_skb) {
+ local_bh_enable();
+ return NULL;
+ }
+
+ cpu = smp_processor_id();
+ p_skb = per_cpu_ptr(sock_filter_skb, cpu);
+ if (unlikely(!*p_skb)) {
+ *p_skb = alloc_skb(1500, GFP_ATOMIC);
+ if (!*p_skb) {
+ local_bh_enable();
+ return NULL;
+ }
+ }
+
+ ret = ops->filter_skb(sk, *p_skb);
+ if (ret < 0) {
+ skbtrace_put_sock_filter_skb(*p_skb);
+ return NULL;
+ }
+
+ return *p_skb;
+}
+EXPORT_SYMBOL_GPL(skbtrace_get_sock_filter_skb);
+
+static ssize_t sk_filter_read(struct sock_fprog *fprog, char __user
*buffer,
+ size_t count)
+{
+ int sz_filter;
+ struct sock_filter __user *user_filter;
+
+ if (!fprog || !fprog->filter)
+ return -EINVAL;
+ sz_filter = fprog->len * sizeof(struct sock_filter);
+ if (count < sizeof(struct sock_fprog) + sz_filter)
+ return -EINVAL;
+
+ if (copy_to_user(buffer, &fprog->len, sizeof(short)))
+ return -EFAULT;
+
+ if (copy_from_user(&user_filter,
+ buffer + sizeof(short), sizeof(user_filter)))
+ return -EFAULT;
+ if (copy_to_user(user_filter, fprog->filter, sz_filter))
+ return -EFAULT;
+
+ return sizeof(struct sock_fprog) + sz_filter;
+}
+
+static ssize_t sk_filter_write(struct sock_fprog *sk_fprog,
+ struct sk_filter **sk_filter,
+ const char __user *buffer, size_t count)
+{
+ int sz_filter, ret;
+ struct sock_filter __user *user_filter;
+
+ if (count < sizeof(struct sock_fprog) || sk_fprog->filter)
+ return -EINVAL;
+ if (copy_from_user(sk_fprog, buffer, sizeof(struct sock_fprog)))
+ return -EFAULT;
+ sz_filter = sk_fprog->len * sizeof(struct sock_filter);
+ user_filter = sk_fprog->filter;
+
+ sk_fprog->filter = kzalloc(sz_filter, GFP_KERNEL);
+ if (!sk_fprog->filter)
+ ret = -ENOMEM;
+
+ ret = -EFAULT;
+ if (!copy_from_user(sk_fprog->filter, user_filter, sz_filter)) {
+ ret = sk_unattached_filter_create(sk_filter, sk_fprog);
+ if (ret) {
+ reset_filter(sk_fprog, sk_filter);
+ return ret;
+ }
+ }
+ static_key_slow_inc(&skbtrace_filters_enabled);
+ return sizeof(struct sock_fprog) + sz_filter;
+}
+
+static ssize_t filters_read(struct file *filp, char __user *buffer,
+ size_t count, loff_t *ppos, struct sock_fprog *fprog)
+{
+ return sk_filter_read(fprog, buffer, count);
+}
+
+static ssize_t skb_filters_read(struct file *filp, char __user *buffer,
+ size_t count, loff_t *ppos)
+{
+ return filters_read(filp, buffer, count, ppos, &skb_filter_fprog);
+}
+
+static ssize_t sock_filters_read(struct file *filp, char __user *buffer,
+ size_t count, loff_t *ppos)
+{
+ return filters_read(filp, buffer, count, ppos, &sock_filter_fprog);
+}
+
+static ssize_t filters_write(struct file *filp, const char __user *buffer,
+ size_t count, loff_t *ppos,
+ struct sock_fprog *fprog, struct sk_filter **filter)
+
+{
+ skbtrace_proto_load();
+
+ if (nr_skbtrace_enabled_tp)
+ return -EBUSY;
+ reset_filter(fprog, filter);
+ return sk_filter_write(fprog, filter, buffer, count);
+}
+
+static ssize_t skb_filters_write(struct file *filp, const char __user
*buffer,
+ size_t count, loff_t *ppos)
+{
+ return filters_write(filp, buffer, count, ppos,
+ &skb_filter_fprog, &skbtrace_skb_filter);
+}
+
+static ssize_t sock_filters_write(struct file *filp, const char __user
*buffer,
+ size_t count, loff_t *ppos)
+{
+ if (unlikely(!++skbtrace_sock_filter_id))
+ skbtrace_sock_filter_id = 1;
+ return filters_write(filp, buffer, count, ppos,
+ &sock_filter_fprog, &skbtrace_sock_filter);
+}
+
+static const struct file_operations filters_fops = {
+ .owner = THIS_MODULE,
+ .open = kmod_open,
+ .release = kmod_release,
+ .read = skb_filters_read,
+ .write = skb_filters_write,
+};
+
+static const struct file_operations sock_filters_fops = {
+ .owner = THIS_MODULE,
+ .open = kmod_open,
+ .release = kmod_release,
+ .read = sock_filters_read,
+ .write = sock_filters_write,
+};
+
+static void reset_filter(struct sock_fprog *fprog, struct sk_filter
**filter)
+{
+ if (fprog->filter)
+ kfree(fprog->filter);
+ memset(fprog, 0, sizeof(struct sock_fprog));
+
+ if (*filter) {
+ static_key_slow_dec(&skbtrace_filters_enabled);
+ sk_unattached_filter_destroy(*filter);
+ *filter = NULL;
+ }
+}
+
+static void skbtrace_filters_clean(void)
+{
+ reset_filter(&sock_filter_fprog, &skbtrace_sock_filter);
+ reset_filter(&skb_filter_fprog, &skbtrace_skb_filter);
+}
+
+static void clean_skbtrace_filters(void)
+{
+ unsigned int cpu;
+
+ if (skb_filter_fprog.filter)
+ kfree(skb_filter_fprog.filter);
+ if (skbtrace_skb_filter) {
+ static_key_slow_dec(&skbtrace_filters_enabled);
+ sk_unattached_filter_destroy(skbtrace_skb_filter);
+ }
+
+ if (sock_filter_fprog.filter)
+ kfree(sock_filter_fprog.filter);
+ if (skbtrace_sock_filter) {
+ static_key_slow_dec(&skbtrace_filters_enabled);
+ sk_unattached_filter_destroy(skbtrace_sock_filter);
+ }
+
+ for_each_possible_cpu(cpu) {
+ struct sk_buff **p_skb;
+
+ p_skb = per_cpu_ptr(sock_filter_skb, cpu);
+ if (*p_skb)
+ kfree_skb(*p_skb);
+ }
+ free_percpu(sock_filter_skb);
+}
+
+static int setup_skbtrace_filters(void)
+{
+ unsigned int cpu, err;
+
+ skbtrace_sock_filter_id = random32();
+
+ skbtrace_filters_clean();
+
+ sock_filter_skb = alloc_percpu(struct sk_buff*);
+ err = 0;
+ for_each_possible_cpu(cpu) {
+ struct sk_buff **p_skb;
+
+ p_skb = per_cpu_ptr(sock_filter_skb, cpu);
+ if (cpu_online(cpu)) {
+ *p_skb = alloc_skb(1500, GFP_KERNEL);
+ if (!*p_skb)
+ err = 1;
+ } else
+ *p_skb = NULL;
+ }
+
+ if (err) {
+ clean_skbtrace_filters();
+ return -ENOMEM;
+ }
+ return 0;
+}
+
+static int skbtrace_init(void)
+{
+ mutex_init(&skbtrace_lock);
+ if (!skbtrace_session)
+ skbtrace_session = random32();
+
+ if (setup_skbtrace_filters() < 0)
+ return -ENOMEM;
+
+ if (skbtrace_events_common_init())
+ return -ENODEV;
+
+ skbtrace_dentry = debugfs_create_dir(SKBTRACE_DIR, NULL);
+ if (!skbtrace_dentry)
+ return -ENOMEM;
+
+ if (create_controls()) {
+ debugfs_remove(skbtrace_dentry);
+ return -ENOMEM;
+ }
+
+ should_load_proto = true;
+ return 0;
+}
+
+static void skbtrace_exit(void)
+{
+ skbtrace_disable_all_tp(); /* disable all enabled tracepoints */
+ skbtrace_disable_all_tp(); /* remove channels in debugfs at 2nd time */
+ if (unlikely(nr_skbtrace_enabled_tp))
+ pr_err("skbtrace: failed to clean tracepoints.\n");
+ remove_controls();
+ debugfs_remove(skbtrace_dentry);
+ clean_skbtrace_filters();
+}
+
+module_init(skbtrace_init);
+module_exit(skbtrace_exit);
+MODULE_LICENSE("GPL");
diff --git a/net/core/skbtrace-events-common.c
b/net/core/skbtrace-events-common.c
new file mode 100644
index 0000000..30a3730
--- /dev/null
+++ b/net/core/skbtrace-events-common.c
@@ -0,0 +1,68 @@
+/*
+ * skbtrace - sk_buff trace utilty
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
+ *
+ * 2012 Li Yu <bingtian.ly@taobao.com>
+ *
+ */
+
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include <linux/socket.h>
+#include <linux/skbtrace_api.h>
+#include <linux/skbtrace.h>
+#include <net/flow_keys.h>
+
+static void skbtrace_skb_rps_info(struct skbtrace_tracepoint *t,
+ struct sk_buff *skb, struct net_device *dev, int cpu)
+SKBTRACE_SKB_EVENT_BEGIN
+ struct skbtrace_skb_rps_info_blk blk, *b;
+ struct flow_keys keys;
+
+ b = skbtrace_block_get(t, NULL, &blk);
+ INIT_SKBTRACE_BLOCK(&b->blk, skb,
+ skbtrace_action_skb_rps_info,
+ 0,
+ sizeof(blk));
+ b->rx_hash = skb->rxhash;
+ if (skb_rx_queue_recorded(skb))
+ b->rx_queue = skb_get_rx_queue(skb);
+ else
+ b->rx_queue = 0;
+ skb_flow_dissect(skb, &keys);
+ b->keys.src = keys.src;
+ b->keys.dst = keys.dst;
+ b->keys.ports = keys.ports;
+ b->keys.ip_proto = keys.ip_proto;
+ b->cpu = cpu;
+ b->ifindex = dev->ifindex;
+ skbtrace_probe(t, NULL, &b->blk);
+SKBTRACE_SKB_EVENT_END
+
+static struct skbtrace_tracepoint common[] = {
+ {
+ .trace_name = "skb_rps_info",
+ .action = skbtrace_action_skb_rps_info,
+ .block_size = sizeof(struct skbtrace_skb_rps_info_blk),
+ .probe = skbtrace_skb_rps_info,
+ },
+ EMPTY_SKBTRACE_TP
+};
+
+int skbtrace_events_common_init(void)
+{
+ return skbtrace_register_proto(AF_UNSPEC, common, NULL);
+}
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index e33ebae..15954ae 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -70,6 +70,7 @@
#include <asm/uaccess.h>
#include <trace/events/skb.h>
#include <linux/highmem.h>
+#include <linux/skbtrace.h>
struct kmem_cache *skbuff_head_cache __read_mostly;
static struct kmem_cache *skbuff_fclone_cache __read_mostly;
@@ -700,6 +701,10 @@ static void __copy_skb_header(struct sk_buff *new,
const struct sk_buff *old)
new->ooo_okay = old->ooo_okay;
new->l4_rxhash = old->l4_rxhash;
new->no_fcs = old->no_fcs;
+#if HAVE_SKBTRACE
+ new->hit_skbtrace = old->hit_skbtrace;
+ new->skbtrace_filtered = old->skbtrace_filtered;
+#endif
#ifdef CONFIG_XFRM
new->sp = secpath_get(old->sp);
#endif
diff --git a/net/core/sock.c b/net/core/sock.c
index a6000fb..b818961 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -132,8 +132,10 @@
#include <net/netprio_cgroup.h>
#include <linux/filter.h>
+#include <linux/skbtrace.h>
#include <trace/events/sock.h>
+#include <trace/events/skbtrace_common.h>
#ifdef CONFIG_INET
#include <net/tcp.h>
@@ -1272,6 +1274,7 @@ struct sock *sk_alloc(struct net *net, int family,
gfp_t priority,
sock_update_classid(sk);
sock_update_netprioidx(sk, current);
+ sock_skbtrace_reset(sk);
}
return sk;
@@ -1292,6 +1295,8 @@ static void __sk_free(struct sock *sk)
RCU_INIT_POINTER(sk->sk_filter, NULL);
}
+ skbtrace_context_destroy(&sk->sk_skbtrace);
+
sock_disable_timestamp(sk, SK_FLAGS_TIMESTAMP);
if (atomic_read(&sk->sk_omem_alloc))
@@ -1440,6 +1445,8 @@ struct sock *sk_clone_lock(const struct sock *sk,
const gfp_t priority)
if (newsk->sk_flags & SK_FLAGS_TIMESTAMP)
net_enable_timestamp();
+
+ sock_skbtrace_reset(newsk);
}
out:
return newsk;
@@ -2124,6 +2131,7 @@ void sk_reset_timer(struct sock *sk, struct
timer_list* timer,
{
if (!mod_timer(timer, expires))
sock_hold(sk);
+ trace_sk_timer(sk, timer, skbtrace_sk_timer_reset);
}
EXPORT_SYMBOL(sk_reset_timer);
@@ -2131,6 +2139,7 @@ void sk_stop_timer(struct sock *sk, struct
timer_list* timer)
{
if (timer_pending(timer) && del_timer(timer))
__sock_put(sk);
+ trace_sk_timer(sk, timer, skbtrace_sk_timer_stop);
}
EXPORT_SYMBOL(sk_stop_timer);
^ permalink raw reply related
* [PATCH 2/3] skbtrace v2: TCP/IPv4 family support
From: Li Yu @ 2012-10-19 6:16 UTC (permalink / raw)
To: Linux Netdev List
From: Li Yu <bingtian.ly@taobao.com>
This patch contains:
1. Modifications for TCP/IP protocol family.
2. The connection based trace points for TCP:
tcp_congestion - trace for TCP congestion events
tcp_connection - trace for basic TCP connection state migration
icsk_connection - trace for TCP LISTEN state
tcp_sendlimit - trace for TCP send limit reasons
tcp_active_conn - trace for active TCP connections
tcp_rttm - trace for TCP RTT measurement
tcp_ca_state - trace for TCP congestion avoid state machine
sk_timer - trace for all TCP timers
Thanks.
Sign-off-by: Li Yu <bingtian.ly@taobao.com>
---
include/net/inet_common.h | 2
include/net/inet_timewait_sock.h | 12
include/net/skbtrace_api_ipv4.h | 181 +++++++
include/net/tcp.h | 2
include/trace/events/skbtrace_ipv4.h | 59 ++
net/ipv4/Kconfig | 7
net/ipv4/Makefile | 1
net/ipv4/af_inet.c | 36 +
net/ipv4/inet_connection_sock.c | 11
net/ipv4/inet_timewait_sock.c | 8
net/ipv4/skbtrace-ipv4.c | 797
+++++++++++++++++++++++++++++++++++
net/ipv4/tcp.c | 5
net/ipv4/tcp_input.c | 12
net/ipv4/tcp_ipv4.c | 32 +
net/ipv4/tcp_minisocks.c | 35 +
net/ipv4/tcp_output.c | 63 ++
16 files changed, 1234 insertions(+), 29 deletions(-)
diff --git a/include/net/inet_common.h b/include/net/inet_common.h
index 2340087..cb2e357 100644
--- a/include/net/inet_common.h
+++ b/include/net/inet_common.h
@@ -31,6 +31,8 @@ extern int inet_shutdown(struct socket *sock, int how);
extern int inet_listen(struct socket *sock, int backlog);
extern void inet_sock_destruct(struct sock *sk);
extern int inet_bind(struct socket *sock, struct sockaddr *uaddr, int
addr_len);
+extern int inet_sock_getname(struct sock *sk, struct sockaddr *uaddr,
+ int *uaddr_len, int peer);
extern int inet_getname(struct socket *sock, struct sockaddr *uaddr,
int *uaddr_len, int peer);
extern int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned
long arg);
diff --git a/include/net/inet_timewait_sock.h
b/include/net/inet_timewait_sock.h
index ba52c83..d75747d 100644
--- a/include/net/inet_timewait_sock.h
+++ b/include/net/inet_timewait_sock.h
@@ -89,6 +89,8 @@ extern void inet_twdr_twcal_tick(unsigned long data);
struct inet_bind_bucket;
+struct skbtrace_context;
+
/*
* This is a TIME_WAIT sock. It works around the memory consumption
* problems of sockets in such a state on heavily loaded servers, but
@@ -125,10 +127,18 @@ struct inet_timewait_sock {
/* And these are ours. */
unsigned int tw_ipv6only : 1,
tw_transparent : 1,
- tw_pad : 6, /* 6 bits hole */
+#if defined(CONFIG_SKBTRACE) || defined(CONFIG_SKBTRACE_MODULE)
+ tw_skbtrace_filtered : 1,
+ tw_hit_skbtrace : 1,
+#endif
+ tw_pad : 4, /* 4 bits hole */
tw_tos : 8,
tw_ipv6_offset : 16;
kmemcheck_bitfield_end(flags);
+#if defined(CONFIG_SKBTRACE) || defined(CONFIG_SKBTRACE_MODULE)
+ unsigned int tw_skbtrace_fid;
+ struct skbtrace_context *tw_skbtrace;
+#endif
unsigned long tw_ttd;
struct inet_bind_bucket *tw_tb;
struct hlist_node tw_death_node;
diff --git a/include/net/skbtrace_api_ipv4.h
b/include/net/skbtrace_api_ipv4.h
new file mode 100644
index 0000000..ab60df1
--- /dev/null
+++ b/include/net/skbtrace_api_ipv4.h
@@ -0,0 +1,181 @@
+/*
+ * skbtrace - sk_buff trace utilty
+ *
+ * User/Kernel Interface
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
+ *
+ * 2012 Li Yu <bingtian.ly@taobao.com>
+ *
+ */
+#ifndef _NET_SKBTRACE_API_IPV4_H
+#define _NET_SKBTRACE_API_IPV4_H
+
+#include <linux/types.h>
+
+#ifdef __KERNEL__
+#include <linux/in.h>
+#include <linux/in6.h>
+#endif
+
+/********************* TCP section *********************/
+
+/* skbtrace_block->action */
+enum {
+ skbtrace_action_tcp_min = 101,
+ skbtrace_action_tcp_congestion = 101,
+ skbtrace_action_tcp_connection = 102,
+ skbtrace_action_tcp_sendlimit = 103,
+ skbtrace_action_tcp_active_conn = 104,
+ skbtrace_action_tcp_rttm = 105,
+ skbtrace_action_tcp_ca_state = 106,
+ skbtrace_action_tcp_max = 199,
+};
+
+/* TCP congestion event (101) */
+
+/* flags */
+enum {
+ skbtrace_tcp_cong_cwr = 0,
+ skbtrace_tcp_cong_loss = 1,
+ skbtrace_tcp_cong_fastrtx = 2,
+ skbtrace_tcp_cong_frto = 3,
+ skbtrace_tcp_cong_frto_loss = 4,
+ skbtrace_tcp_cong_leave = 5,
+};
+
+struct skbtrace_tcp_cong_blk {
+ struct skbtrace_block blk;
+ __u32 rto;
+ __u32 cwnd;
+ __u32 sndnxt;
+ __u32 snduna;
+} __packed;
+
+/* TCP basic connection events */
+struct skbtrace_tcp_conn_blk {
+ struct skbtrace_block blk;
+ union {
+ struct {
+ struct sockaddr local;
+ struct sockaddr peer;
+ };
+ struct {
+ struct sockaddr_in local;
+ struct sockaddr_in peer;
+ } inet;
+ struct {
+ struct sockaddr_in6 local;
+ struct sockaddr_in6 peer;
+ } inet6;
+ } addr;
+} __packed;
+
+/* TCP send limit event */
+enum {
+ skbtrace_tcp_sndlim_cwnd = 0,
+ skbtrace_tcp_sndlim_swnd = 1,
+ skbtrace_tcp_sndlim_nagle = 2,
+ skbtrace_tcp_sndlim_tso = 3,
+ skbtrace_tcp_sndlim_frag = 4, /* most likely ENOMEM errors */
+ skbtrace_tcp_sndlim_pushone = 5,
+ skbtrace_tcp_sndlim_other = 6,
+ skbtrace_tcp_sndlim_ok = 7,
+};
+
+
+/* val member:
+ * skbtrace_tcp_sndlim_other: the return value of tcp_transmit_skb()
+ * skbtrace_tcp_sndlim_ok: total sent pkts
+ * other cases: send limit occurs under MTU probe if 1, otherwise,
it is 0
+ */
+struct skbtrace_tcp_sendlim_blk {
+ struct skbtrace_block blk;
+ __u32 val;
+ __u32 count;
+ struct timespec begin;
+ __u32 snd_ssthresh;
+ __u32 snd_cwnd;
+ __u32 snd_cwnd_cnt;
+ __u32 snd_wnd;
+} __packed;
+
+/* TCP active connections */
+/* Use skbtrace_tcp_conn_blk */
+
+/* TCP RTTM */
+struct skbtrace_tcp_rttm_blk {
+ struct skbtrace_block blk;
+ __u32 pad;
+ __u32 snd_una;
+ __u32 rtt_seq;
+ __u32 rtt;
+ __u32 rttvar;
+ __u32 srtt;
+ __u32 mdev;
+ __u32 mdev_max;
+} __packed;
+
+/* TCP CA state */
+struct skbtrace_tcp_ca_state_blk {
+ struct skbtrace_block blk;
+
+ __u32 cwnd;
+ __u32 rto;
+ __u32 snduna;
+ __u32 sndnxt;
+
+ __u32 snd_ssthresh;
+ __u32 snd_wnd;
+ __u32 rcv_wnd;
+ __u32 high_seq;
+
+ __u32 packets_out;
+ __u32 lost_out;
+ __u32 retrans_out;
+ __u32 sacked_out;
+
+ __u32 fackets_out;
+ __u32 prior_ssthresh;
+ __u32 undo_marker;
+ __u32 undo_retrans;
+
+ __u32 total_retrans;
+ __u32 reordering;
+ __u32 prior_cwnd;
+ __u32 mss_cache;
+
+} __packed;
+
+/* TCP timer flags */
+enum {
+ skbtrace_tcp_timer_rexmit = skbtrace_sk_timer_last + 1,
+ skbtrace_tcp_timer_probe,
+ skbtrace_tcp_timer_keepalive,
+ skbtrace_tcp_timer_delack,
+};
+
+/********************* icsk section *********************/
+
+/* skbtrace_block->action */
+enum {
+ skbtrace_action_icsk_min = 201,
+ skbtrace_action_icsk_connection = 201,
+ skbtrace_action_icsk_max = 299,
+};
+
+/* Use skbtrace_tcp_active_conn */
+
+#endif
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 1f000ff..cb4d896 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -46,6 +46,7 @@
#include <linux/seq_file.h>
#include <linux/memcontrol.h>
+#include <trace/events/skbtrace_ipv4.h>
extern struct inet_hashinfo tcp_hashinfo;
@@ -805,6 +806,7 @@ static inline void tcp_set_ca_state(struct sock *sk,
const u8 ca_state)
if (icsk->icsk_ca_ops->set_state)
icsk->icsk_ca_ops->set_state(sk, ca_state);
icsk->icsk_ca_state = ca_state;
+ trace_tcp_ca_state(sk, ca_state);
}
static inline void tcp_ca_event(struct sock *sk, const enum
tcp_ca_event event)
diff --git a/include/trace/events/skbtrace_ipv4.h
b/include/trace/events/skbtrace_ipv4.h
new file mode 100644
index 0000000..b82b81f
--- /dev/null
+++ b/include/trace/events/skbtrace_ipv4.h
@@ -0,0 +1,59 @@
+ /*
+ * skbtrace - sk_buff trace utilty
+ *
+ * The IPv4 related skbtrace events
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
+ *
+ * Thanks for Web10G project here, some sources reference to it.
+ *
+ * 2012 Li Yu <bingtian.ly@taobao.com>
+ *
+ */
+
+#if !defined(_TRACE_EVENTS_SKBTRACE_IPV4_H)
+#define _TRACE_EVENTS_SKBTRACE_IPV4_H
+
+#include <linux/tracepoint.h>
+
+DECLARE_TRACE(icsk_connection,
+ TP_PROTO(void *sk, __u32 state),
+ TP_ARGS(sk, state));
+
+DECLARE_TRACE(tcp_congestion,
+ TP_PROTO(void *sk, int reason),
+ TP_ARGS(sk, reason));
+
+DECLARE_TRACE(tcp_connection,
+ TP_PROTO(void *sk, __u32 state),
+ TP_ARGS(sk, state));
+
+DECLARE_TRACE(tcp_sendlimit,
+ TP_PROTO(void *sk, int reason, int val),
+ TP_ARGS(sk, reason, val));
+
+DECLARE_TRACE(tcp_active_conn,
+ TP_PROTO(void *sk),
+ TP_ARGS(sk));
+
+DECLARE_TRACE(tcp_rttm,
+ TP_PROTO(void *sk, __u32 seq_rtt),
+ TP_ARGS(sk, seq_rtt));
+
+DECLARE_TRACE(tcp_ca_state,
+ TP_PROTO(void *sk, __u8 state),
+ TP_ARGS(sk, state));
+
+#endif
diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig
index 5a19aeb..24dba85 100644
--- a/net/ipv4/Kconfig
+++ b/net/ipv4/Kconfig
@@ -426,6 +426,13 @@ config INET_UDP_DIAG
Support for UDP socket monitoring interface used by the ss tool.
If unsure, say Y.
+config SKBTRACE_IPV4
+ tristate "IPv4 protocol suite support for skbtrace"
+ depends on SKBTRACE
+ default m
+ ---help---
+ Support for IPv4 part of skbtrace.
+
menuconfig TCP_CONG_ADVANCED
bool "TCP: advanced congestion control"
---help---
diff --git a/net/ipv4/Makefile b/net/ipv4/Makefile
index 15ca63e..0c7b5c3 100644
--- a/net/ipv4/Makefile
+++ b/net/ipv4/Makefile
@@ -51,6 +51,7 @@ obj-$(CONFIG_TCP_CONG_YEAH) += tcp_yeah.o
obj-$(CONFIG_TCP_CONG_ILLINOIS) += tcp_illinois.o
obj-$(CONFIG_MEMCG_KMEM) += tcp_memcontrol.o
obj-$(CONFIG_NETLABEL) += cipso_ipv4.o
+obj-${CONFIG_SKBTRACE_IPV4} += skbtrace-ipv4.o
obj-$(CONFIG_XFRM) += xfrm4_policy.o xfrm4_state.o xfrm4_input.o \
xfrm4_output.o
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index fe4582c..6781a12 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -119,6 +119,7 @@
#include <linux/mroute.h>
#endif
+#include <linux/skbtrace.h>
/* The inetsw table contains everything that inet_create needs to
* build a new socket.
@@ -713,23 +714,14 @@ do_err:
}
EXPORT_SYMBOL(inet_accept);
-
-/*
- * This does both peername and sockname.
- */
-int inet_getname(struct socket *sock, struct sockaddr *uaddr,
+int inet_sock_getname(struct sock *sk, struct sockaddr *uaddr,
int *uaddr_len, int peer)
{
- struct sock *sk = sock->sk;
struct inet_sock *inet = inet_sk(sk);
DECLARE_SOCKADDR(struct sockaddr_in *, sin, uaddr);
sin->sin_family = AF_INET;
if (peer) {
- if (!inet->inet_dport ||
- (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_SYN_SENT)) &&
- peer == 1))
- return -ENOTCONN;
sin->sin_port = inet->inet_dport;
sin->sin_addr.s_addr = inet->inet_daddr;
} else {
@@ -740,9 +732,31 @@ int inet_getname(struct socket *sock, struct
sockaddr *uaddr,
sin->sin_addr.s_addr = addr;
}
memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
- *uaddr_len = sizeof(*sin);
+ if (uaddr_len)
+ *uaddr_len = sizeof(*sin);
return 0;
}
+EXPORT_SYMBOL(inet_sock_getname);
+
+/*
+ * This does both peername and sockname.
+ */
+int inet_getname(struct socket *sock, struct sockaddr *uaddr,
+ int *uaddr_len, int peer)
+{
+ struct sock *sk = sock->sk;
+ struct inet_sock *inet = inet_sk(sk);
+
+ if (peer) {
+ if (!inet->inet_dport)
+ return -ENOTCONN;
+ if (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_SYN_SENT)) &&
+ peer == 1)
+ return -ENOTCONN;
+ }
+
+ return inet_sock_getname(sk, uaddr, uaddr_len, peer);
+}
EXPORT_SYMBOL(inet_getname);
int inet_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
*msg,
diff --git a/net/ipv4/inet_connection_sock.c
b/net/ipv4/inet_connection_sock.c
index 7f75f21..4e1c45f 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -15,6 +15,9 @@
#include <linux/module.h>
#include <linux/jhash.h>
+#include <linux/skbtrace.h>
+#include <trace/events/skbtrace_common.h>
+#include <trace/events/skbtrace_ipv4.h>
#include <net/inet_connection_sock.h>
#include <net/inet_hashtables.h>
@@ -335,9 +338,16 @@ void inet_csk_init_xmit_timers(struct sock *sk,
setup_timer(&icsk->icsk_retransmit_timer, retransmit_handler,
(unsigned long)sk);
+ trace_sk_timer(sk, &icsk->icsk_retransmit_timer,
+ skbtrace_sk_timer_setup);
+
setup_timer(&icsk->icsk_delack_timer, delack_handler,
(unsigned long)sk);
+ trace_sk_timer(sk, &icsk->icsk_delack_timer, skbtrace_sk_timer_setup);
+
setup_timer(&sk->sk_timer, keepalive_handler, (unsigned long)sk);
+ trace_sk_timer(sk, &sk->sk_timer, skbtrace_sk_timer_setup);
+
icsk->icsk_pending = icsk->icsk_ack.pending = 0;
}
EXPORT_SYMBOL(inet_csk_init_xmit_timers);
@@ -704,6 +714,7 @@ int inet_csk_listen_start(struct sock *sk, const int
nr_table_entries)
sk_dst_reset(sk);
sk->sk_prot->hash(sk);
+ trace_icsk_connection(sk, TCP_LISTEN);
return 0;
}
diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c
index 2784db3..c34dbbc 100644
--- a/net/ipv4/inet_timewait_sock.c
+++ b/net/ipv4/inet_timewait_sock.c
@@ -12,6 +12,8 @@
#include <linux/kmemcheck.h>
#include <linux/slab.h>
#include <linux/module.h>
+#include <linux/skbtrace.h>
+#include <trace/events/skbtrace_ipv4.h>
#include <net/inet_hashtables.h>
#include <net/inet_timewait_sock.h>
#include <net/ip.h>
@@ -106,6 +108,7 @@ static noinline void inet_twsk_free(struct
inet_timewait_sock *tw)
#ifdef SOCK_REFCNT_DEBUG
pr_debug("%s timewait_sock %p released\n", tw->tw_prot->name, tw);
#endif
+ skbtrace_context_destroy(&tw->tw_skbtrace);
release_net(twsk_net(tw));
kmem_cache_free(tw->tw_prot->twsk_prot->twsk_slab, tw);
module_put(owner);
@@ -196,6 +199,10 @@ struct inet_timewait_sock *inet_twsk_alloc(const
struct sock *sk, const int stat
tw->tw_ipv6only = 0;
tw->tw_transparent = inet->transparent;
tw->tw_prot = sk->sk_prot_creator;
+ tw->tw_skbtrace_fid = 0;
+#if HAVE_SKBTRACE
+ tw->tw_skbtrace = NULL;
+#endif
twsk_net_set(tw, hold_net(sock_net(sk)));
/*
* Because we use RCU lookups, we should not set tw_refcnt
@@ -205,6 +212,7 @@ struct inet_timewait_sock *inet_twsk_alloc(const
struct sock *sk, const int stat
atomic_set(&tw->tw_refcnt, 0);
inet_twsk_dead_node_init(tw);
__module_get(tw->tw_prot->owner);
+ trace_tcp_connection(tw, state + TCP_MAX_STATES);
}
return tw;
diff --git a/net/ipv4/skbtrace-ipv4.c b/net/ipv4/skbtrace-ipv4.c
new file mode 100644
index 0000000..28e3532
--- /dev/null
+++ b/net/ipv4/skbtrace-ipv4.c
@@ -0,0 +1,797 @@
+/*
+ * skbtrace - sk_buff trace for TCP/IPv4 protocol suite support
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
+ *
+ * 2012 Li Yu <bingtian.ly@taobao.com>
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/relay.h>
+#include <linux/debugfs.h>
+#include <linux/slab.h>
+#include <linux/ctype.h>
+#include <linux/jhash.h>
+#include <linux/inet.h>
+
+#include <linux/skbtrace.h>
+#include <linux/tcp.h>
+#include <net/inet_common.h>
+#include <net/inet_connection_sock.h>
+#include <net/tcp.h>
+
+static int mask_options_setup(struct skbtrace_tracepoint *t,
+ char *names[], int masks[], int nr_masks,
+ char *option_string);
+static char* mask_options_desc(struct skbtrace_tracepoint *t,
+ char *names[], int masks[], int nr_masks);
+
+static struct skbtrace_context *skbtrace_context_twsk_get(
+ struct inet_timewait_sock *tw)
+{
+ struct skbtrace_ops *ops;
+ struct skbtrace_context *ctx;
+
+ ops = skbtrace_ops_get(tw->tw_family);
+ if (!ops)
+ return NULL;
+ local_bh_disable();
+
+ if (tw->tw_skbtrace &&
+ (skbtrace_session != tw->tw_skbtrace->session)) {
+ skbtrace_context_destroy(&tw->tw_skbtrace);
+ }
+
+ if (!tw->tw_skbtrace) {
+ ctx = kzalloc(sizeof(struct skbtrace_context), GFP_ATOMIC);
+ if (likely(ctx)) {
+ skbtrace_context_setup(ctx, ops);
+ tw->tw_skbtrace = ctx;
+ }
+ }
+ local_bh_enable();
+ return tw->tw_skbtrace;
+}
+EXPORT_SYMBOL(skbtrace_context_twsk_get);
+
+static char* tcp_cong_options[] = {
+ "cwr",
+ "loss",
+ "fastrtx",
+ "frto",
+ "frto-loss",
+ "leave",
+};
+
+static int tcp_cong_masks[] = {
+ skbtrace_tcp_cong_cwr,
+ skbtrace_tcp_cong_loss,
+ skbtrace_tcp_cong_fastrtx,
+ skbtrace_tcp_cong_frto,
+ skbtrace_tcp_cong_frto_loss,
+ skbtrace_tcp_cong_leave,
+};
+
+static int tcp_cong_setup_options(struct skbtrace_tracepoint *t,
+ char *options)
+{
+ return mask_options_setup(t,
+ tcp_cong_options,
+ tcp_cong_masks,
+ sizeof(tcp_cong_masks)/sizeof(int),
+ options);
+}
+
+static char *tcp_cong_desc(struct skbtrace_tracepoint *t)
+{
+ return mask_options_desc(t,
+ tcp_cong_options,
+ tcp_cong_masks,
+ sizeof(tcp_cong_masks)/sizeof(int));
+}
+
+static void skbtrace_tcp_congestion(struct skbtrace_tracepoint *t,
+ struct sock *sk, int reason)
+SKBTRACE_SOCK_EVENT_BEGIN
+ struct skbtrace_tcp_cong_blk blk, *b;
+ struct tcp_sock *tp;
+ struct skbtrace_context *ctx;
+ unsigned long mask = (unsigned long)t->private;
+
+ if (mask & (1<<reason))
+ return;
+
+ tp = tcp_sk(sk);
+ ctx = skbtrace_context_get(sk);
+ b = skbtrace_block_get(t, ctx, &blk);
+ INIT_SKBTRACE_BLOCK(&b->blk, tp,
+ skbtrace_action_tcp_congestion,
+ 1 << reason,
+ sizeof(*b));
+ b->cwnd = tp->snd_cwnd * tp->mss_cache;
+ b->rto = inet_csk(sk)->icsk_rto;
+ b->snduna = tp->snd_una;
+ b->sndnxt = tp->snd_nxt;
+ skbtrace_probe(t, ctx, &b->blk);
+SKBTRACE_SOCK_EVENT_END
+
+static void skbtrace_tcp_connection(struct skbtrace_tracepoint *t,
+ void *ptr, u32 state)
+{
+ struct sock *sk = ptr;
+ struct inet_timewait_sock *tw = inet_twsk(ptr);
+ struct skbtrace_context *ctx;
+
+ switch (state) {
+ case TCP_TIME_WAIT + TCP_MAX_STATES:
+ case TCP_FIN_WAIT2 + TCP_MAX_STATES:
+ {
+ struct skbtrace_tcp_conn_blk blk, *b;
+ struct skbtrace_context *ctx;
+
+ if (skbtrace_bypass_twsk(tw))
+ return;
+
+ ctx = skbtrace_context_twsk_get(tw);
+ b = skbtrace_block_get(t, ctx, &blk);
+ state -= TCP_MAX_STATES;
+ INIT_SKBTRACE_BLOCK(&b->blk, tw,
+ skbtrace_action_tcp_connection,
+ 1 << state,
+ sizeof(blk));
+ b->addr.inet.local.sin_family = AF_INET;
+ b->addr.inet.local.sin_port = tw->tw_sport;
+ b->addr.inet.local.sin_addr.s_addr = tw->tw_rcv_saddr;
+ b->addr.inet.peer.sin_family = AF_INET;
+ b->addr.inet.peer.sin_port = tw->tw_dport;
+ b->addr.inet.peer.sin_addr.s_addr = tw->tw_daddr;
+ skbtrace_probe(t, ctx, &b->blk);
+ break;
+ }
+ case TCP_ESTABLISHED:
+ case TCP_FIN_WAIT1:
+ case TCP_CLOSE:
+ case TCP_CLOSE_WAIT:
+ case TCP_LAST_ACK:
+ case TCP_SYN_SENT:
+ case TCP_SYN_RECV:
+ case TCP_CLOSING:
+ {
+ struct skbtrace_tcp_conn_blk blk, *b;
+ struct skbtrace_ops *ops;
+
+ if (skbtrace_bypass_sock(sk))
+ return;
+
+ if (TCP_CLOSE == sk->sk_state &&
+ SHUTDOWN_MASK == sk->sk_shutdown)
+ /* for active TCP connections, we will call
+ * tcp_set_state(sk, TCP_CLOSE) two times,
+ * this hack help skip second one */
+ return;
+
+ ops = skbtrace_ops_get(sk->sk_family);
+ if (!ops)
+ return;
+
+ ctx = skbtrace_context_get(sk);
+ b = skbtrace_block_get(t, ctx, &blk);
+ INIT_SKBTRACE_BLOCK(&b->blk, ptr,
+ skbtrace_action_tcp_connection,
+ 1 << state,
+ sizeof(blk));
+ ops->getname(sk, &b->addr.local, NULL, 0);
+ if (TCP_LISTEN != state)
+ ops->getname(sk, &b->addr.peer, NULL, 1);
+ skbtrace_probe(t, ctx, &b->blk);
+ break;
+ }
+ }
+}
+
+static void skbtrace_icsk_connection(struct skbtrace_tracepoint *t,
+ struct sock *sk, u32 state)
+SKBTRACE_SOCK_EVENT_BEGIN
+ struct skbtrace_tcp_conn_blk blk, *b;
+ struct skbtrace_ops *ops;
+ struct skbtrace_context *ctx;
+
+ if (TCP_LISTEN != state)
+ return;
+ ops = skbtrace_ops_get(sk->sk_family);
+ if (!ops)
+ return;
+
+ ctx = skbtrace_context_get(sk);
+ b = skbtrace_block_get(t, ctx, &blk);
+ INIT_SKBTRACE_BLOCK(&b->blk, sk,
+ skbtrace_action_icsk_connection,
+ 1 << state,
+ sizeof(blk));
+ ops->getname(sk, &b->addr.local, NULL, 0);
+ skbtrace_probe(t, ctx, &b->blk);
+SKBTRACE_SOCK_EVENT_END
+
+static char* tcp_sendlimit_options[] = {
+ "cwnd",
+ "swnd",
+ "nagle",
+ "tso",
+ "frag",
+ "pushone",
+ "other",
+ "ok",
+};
+
+static int tcp_sendlimit_masks[] = {
+ skbtrace_tcp_sndlim_cwnd,
+ skbtrace_tcp_sndlim_swnd,
+ skbtrace_tcp_sndlim_nagle,
+ skbtrace_tcp_sndlim_tso,
+ skbtrace_tcp_sndlim_frag,
+ skbtrace_tcp_sndlim_pushone,
+ skbtrace_tcp_sndlim_other,
+ skbtrace_tcp_sndlim_ok,
+};
+
+static int tcp_sendlimit_setup_options(struct skbtrace_tracepoint *t,
+ char *options)
+{
+ return mask_options_setup(t,
+ tcp_sendlimit_options,
+ tcp_sendlimit_masks,
+ sizeof(tcp_sendlimit_masks)/sizeof(int),
+ options);
+}
+
+static char *tcp_sendlimit_desc(struct skbtrace_tracepoint *t)
+{
+ return mask_options_desc(t,
+ tcp_sendlimit_options,
+ tcp_sendlimit_masks,
+ sizeof(tcp_sendlimit_masks)/sizeof(int));
+}
+
+static void skbtrace_tcp_sendlimit(struct skbtrace_tracepoint *t,
+ struct sock *sk, int reason, int val)
+SKBTRACE_SOCK_EVENT_BEGIN
+ struct skbtrace_tcp_sendlim_blk blk, *b;
+ unsigned long mask = (unsigned long)t->private;
+ struct tcp_sock *tp = tcp_sk(sk);
+ struct skbtrace_context *ctx;
+
+ if (mask & (1<<reason))
+ return;
+
+ if (skbtrace_tcp_sndlim_ok == reason && !val)
+ return;
+
+ ctx = skbtrace_context_get(sk);
+ b = skbtrace_block_get(t, ctx, &blk);
+ INIT_SKBTRACE_BLOCK(&b->blk, tp,
+ skbtrace_action_tcp_sendlimit,
+ 1 << reason,
+ sizeof(*b));
+
+ b->val = val;
+ b->count = 1;
+ b->begin = current_kernel_time();
+
+ b->snd_ssthresh = tp->snd_ssthresh;
+ b->snd_cwnd = tp->snd_cwnd;
+ b->snd_cwnd_cnt = tp->snd_cwnd_cnt;
+ b->snd_wnd = tp->snd_wnd;
+
+ skbtrace_probe(t, ctx, &b->blk);
+SKBTRACE_SOCK_EVENT_END
+
+static void skbtrace_tcp_active_conn(struct skbtrace_tracepoint *t,
+ struct sock *sk)
+SKBTRACE_SOCK_EVENT_BEGIN
+ struct skbtrace_tcp_conn_blk blk, *b;
+ struct skbtrace_context *ctx;
+
+ ctx = skbtrace_context_get(sk);
+ if (ctx) {
+ if (ctx->active_conn_hit)
+ return;
+ ctx->active_conn_hit = 1;
+ }
+
+ b = skbtrace_block_get(t, ctx, &blk);
+ INIT_SKBTRACE_BLOCK(&b->blk, sk,
+ skbtrace_action_tcp_active_conn, 0, sizeof(blk));
+ if (ctx && ctx->ops) {
+ ctx->ops->getname(sk, &b->addr.local, NULL, 0);
+ ctx->ops->getname(sk, &b->addr.peer, NULL, 1);
+ } else
+ memset(&b->addr, 0, sizeof(b->addr));
+ skbtrace_probe(t, ctx, &b->blk);
+SKBTRACE_SOCK_EVENT_END
+
+static void skbtrace_tcp_rttm(struct skbtrace_tracepoint *t,
+ struct sock *sk, u32 seq_rtt)
+SKBTRACE_SOCK_EVENT_BEGIN
+ struct tcp_sock *tp = tcp_sk(sk);
+ struct skbtrace_tcp_rttm_blk blk, *b;
+ struct skbtrace_context *ctx;
+
+ ctx = skbtrace_context_get(sk);
+ b = skbtrace_block_get(t, ctx, &blk);
+ INIT_SKBTRACE_BLOCK(&b->blk, sk,
+ skbtrace_action_tcp_rttm, 0, sizeof(blk));
+ b->rtt_seq = tp->rtt_seq;
+ b->snd_una = tp->snd_una;
+ b->rtt = seq_rtt;
+ b->srtt = tp->srtt;
+ b->rttvar = tp->rttvar;
+ b->mdev = tp->mdev;
+ b->mdev_max = tp->mdev_max;
+ skbtrace_probe(t, ctx, &b->blk);
+SKBTRACE_SOCK_EVENT_END
+
+static char* tcp_ca_state_options[] = {
+ "open",
+ "disorder",
+ "cwr",
+ "recovery",
+ "loss",
+};
+
+static int tcp_ca_state_masks[] = {
+ TCP_CA_Open,
+ TCP_CA_Disorder,
+ TCP_CA_CWR,
+ TCP_CA_Recovery,
+ TCP_CA_Loss,
+};
+
+static int tcp_ca_state_setup_options(struct skbtrace_tracepoint *t,
+ char *options)
+{
+ return mask_options_setup(t,
+ tcp_ca_state_options,
+ tcp_ca_state_masks,
+ sizeof(tcp_ca_state_masks)/sizeof(int),
+ options);
+}
+
+static char *tcp_ca_state_desc(struct skbtrace_tracepoint *t)
+{
+ return mask_options_desc(t,
+ tcp_ca_state_options,
+ tcp_ca_state_masks,
+ sizeof(tcp_ca_state_masks)/sizeof(int));
+}
+
+static void skbtrace_tcp_ca_state(struct skbtrace_tracepoint *t,
+ struct sock *sk, u8 state)
+SKBTRACE_SOCK_EVENT_BEGIN
+ struct tcp_sock *tp = tcp_sk(sk);
+ struct skbtrace_tcp_ca_state_blk blk, *b;
+ struct skbtrace_context *ctx;
+ unsigned long mask = (unsigned long)t->private;
+
+ if (mask & (1<<state))
+ return;
+
+ ctx = skbtrace_context_get(sk);
+ b = skbtrace_block_get(t, ctx, &blk);
+ INIT_SKBTRACE_BLOCK(&b->blk, sk,
+ skbtrace_action_tcp_ca_state, 1<<state, sizeof(blk));
+
+ b->cwnd = tp->snd_cwnd;
+ b->rto = inet_csk(sk)->icsk_rto;
+ b->snduna = tp->snd_una;
+ b->sndnxt = tp->snd_nxt;
+
+ b->snd_ssthresh = tp->snd_ssthresh;
+ b->snd_wnd = tp->snd_wnd;
+ b->rcv_wnd = tp->rcv_wnd;
+ b->high_seq = tp->high_seq;
+
+ b->packets_out = tp->packets_out;
+ b->lost_out = tp->lost_out;
+ b->retrans_out = tp->retrans_out;
+ b->sacked_out = tp->sacked_out;
+
+ b->fackets_out = tp->fackets_out;
+ b->prior_ssthresh = tp->prior_ssthresh;
+ b->undo_marker = tp->undo_marker;
+ b->undo_retrans = tp->undo_retrans;
+
+ b->total_retrans = tp->total_retrans;
+ b->reordering = tp->reordering;
+ b->prior_cwnd = tp->prior_cwnd;
+ b->mss_cache = tp->mss_cache;
+
+ skbtrace_probe(t, ctx, &b->blk);
+SKBTRACE_SOCK_EVENT_END
+
+static char* tcp_timer_options[] = {
+ "setup",
+ "reset",
+ "stop",
+
+ "rexmit",
+ "probe",
+ "keepalive",
+ "delack",
+};
+
+static int tcp_timer_masks[] = {
+ skbtrace_sk_timer_setup,
+ skbtrace_sk_timer_reset,
+ skbtrace_sk_timer_stop,
+
+ skbtrace_tcp_timer_rexmit,
+ skbtrace_tcp_timer_probe,
+ skbtrace_tcp_timer_keepalive,
+ skbtrace_tcp_timer_delack,
+};
+
+static int tcp_timer_setup_options(struct skbtrace_tracepoint *t,
+ char *options)
+{
+ return mask_options_setup(t,
+ tcp_timer_options,
+ tcp_timer_masks,
+ sizeof(tcp_timer_masks)/sizeof(int),
+ options);
+}
+
+static char *tcp_timer_desc(struct skbtrace_tracepoint *t)
+{
+ return mask_options_desc(t,
+ tcp_timer_options,
+ tcp_timer_masks,
+ sizeof(tcp_timer_masks)/sizeof(int));
+}
+
+#define LONG_SIGN_MASK (1UL<<(BITS_PER_LONG - 1))
+#define LONG_SIGN(l) (l & LONG_SIGN_MASK)
+
+static s32 timer_timeout_msecs(struct timer_list *timer, unsigned long now)
+{
+ s32 timeout;
+
+ if (unlikely(LONG_SIGN(timer->expires) != LONG_SIGN(now))) {
+ timeout = (s32)timer->expires;
+ timeout += (s32)(ULONG_MAX - now);
+ } else
+ timeout = timer->expires - now;
+
+ return jiffies_to_msecs(timeout);
+}
+
+static void skbtrace_tcp_timer(struct skbtrace_tracepoint *t,
+ struct sock *sk, struct timer_list *timer, int action)
+SKBTRACE_SOCK_EVENT_BEGIN
+ struct inet_connection_sock *icsk = inet_csk(sk);
+ struct skbtrace_sk_timer_blk blk, *b;
+ s32 f_timer, timeout;
+ u32 timer_bits;
+ struct skbtrace_context *ctx;
+ unsigned long mask = (unsigned long)t->private;
+
+ if (IPPROTO_TCP != sk->sk_protocol)
+ return;
+
+ if (mask & (1<<action))
+ return;
+
+ if (timer == &icsk->icsk_retransmit_timer) {
+ f_timer = (icsk->icsk_pending == ICSK_TIME_PROBE0 ?
+ skbtrace_tcp_timer_probe : skbtrace_tcp_timer_rexmit);
+ } else if (timer == &icsk->icsk_delack_timer)
+ f_timer = skbtrace_tcp_timer_delack;
+ else if (timer == &sk->sk_timer)
+ f_timer = skbtrace_tcp_timer_keepalive;
+ else
+ f_timer = 0;
+ timer_bits = f_timer ? (1<<f_timer) : 0;
+
+ if (mask & timer_bits)
+ return;
+
+ /* TCP rexmit timer and probe0 share same timer_list */
+ if (f_timer == skbtrace_tcp_timer_rexmit
+ && action == skbtrace_sk_timer_setup) {
+ if (mask & (1<<skbtrace_tcp_timer_probe))
+ return;
+ timer_bits |= 1<<skbtrace_tcp_timer_probe;
+ }
+
+ ctx = skbtrace_context_get(sk);
+ b = skbtrace_block_get(t, ctx, &blk);
+ INIT_SKBTRACE_BLOCK(&b->blk, sk,
+ skbtrace_action_sk_timer, 1<<action, sizeof(blk));
+ b->proto = IPPROTO_TCP;
+
+ if (skbtrace_sk_timer_reset == action) {
+ timeout = timer_timeout_msecs(timer, jiffies);
+ } else
+ timeout = 0;
+
+ b->blk.flags |= timer_bits;
+ b->timeout = timeout;
+ skbtrace_probe(t, ctx, &b->blk);
+SKBTRACE_SOCK_EVENT_END
+
+static struct skbtrace_tracepoint tp_inet4[] = {
+ {
+ .trace_name = "tcp_congestion",
+ .action = skbtrace_action_tcp_congestion,
+ .block_size = sizeof(struct skbtrace_tcp_cong_blk),
+ .probe = skbtrace_tcp_congestion,
+ .setup_options = tcp_cong_setup_options,
+ .desc = tcp_cong_desc,
+ },
+ {
+ .trace_name = "tcp_connection",
+ .action = skbtrace_action_tcp_connection,
+ .block_size = sizeof(struct skbtrace_tcp_conn_blk),
+ .probe = skbtrace_tcp_connection,
+ },
+ {
+ .trace_name = "icsk_connection",
+ .action = skbtrace_action_icsk_connection,
+ .block_size = sizeof(struct skbtrace_tcp_conn_blk),
+ .probe = skbtrace_icsk_connection,
+ },
+ {
+ .trace_name = "tcp_sendlimit",
+ .action = skbtrace_action_tcp_sendlimit,
+ .block_size = sizeof(struct skbtrace_tcp_sendlim_blk),
+ .probe = skbtrace_tcp_sendlimit,
+ .setup_options = tcp_sendlimit_setup_options,
+ .desc = tcp_sendlimit_desc,
+ },
+ {
+ .trace_name = "tcp_active_conn",
+ .action = skbtrace_action_tcp_active_conn,
+ .block_size = sizeof(struct skbtrace_tcp_conn_blk),
+ .probe = skbtrace_tcp_active_conn,
+ },
+ {
+ .trace_name = "tcp_rttm",
+ .action = skbtrace_action_tcp_rttm,
+ .block_size = sizeof(struct skbtrace_tcp_rttm_blk),
+ .probe = skbtrace_tcp_rttm,
+ },
+ {
+ .trace_name = "tcp_ca_state",
+ .action = skbtrace_action_tcp_ca_state,
+ .block_size = sizeof(struct skbtrace_tcp_ca_state_blk),
+ .probe = skbtrace_tcp_ca_state,
+ .setup_options = tcp_ca_state_setup_options,
+ .desc = tcp_ca_state_desc,
+ },
+ {
+ .trace_name = "sk_timer",
+ .action = skbtrace_action_sk_timer,
+ .block_size = sizeof(struct skbtrace_sk_timer_blk),
+ .probe = skbtrace_tcp_timer,
+ .setup_options = tcp_timer_setup_options,
+ .desc = tcp_timer_desc,
+ },
+ EMPTY_SKBTRACE_TP
+};
+
+static int __inet_filter_skb(struct sock *sk, struct sk_buff *skb)
+{
+ struct inet_sock *inet = inet_sk(sk);
+ struct iphdr *iph;
+
+ skb_reset_network_header(skb);
+ iph = ip_hdr(skb);
+ *((__be16 *)iph) = htons((4 << 12) | (5 << 8));
+ iph->frag_off = 0;
+ iph->ttl = 0;
+ iph->protocol = sk->sk_protocol;
+ iph->saddr = inet->inet_saddr;
+ iph->daddr = inet->inet_daddr;
+ iph->id = 0;
+ iph->tot_len = htons(sizeof(struct iphdr) + sizeof(struct tcphdr));
+
+ return sizeof(struct iphdr);
+}
+
+int inet_filter_skb(struct sock *sk, struct sk_buff *skb)
+{
+ int size, prot_size;
+
+ if (!skb || !sk->sk_prot->filter_skb) {
+ return -EINVAL;
+ }
+
+ size = __inet_filter_skb(sk, skb);
+ if (size < 0)
+ return -EINVAL;
+ skb->len += size;
+ skb->tail += size;
+ skb->data += size;
+
+ prot_size = sk->sk_prot->filter_skb(sk, skb);
+ if (prot_size < 0)
+ return -EINVAL;
+ skb->len += prot_size;
+ skb->tail += prot_size;
+
+ skb->data -= size;
+ return 0;
+}
+EXPORT_SYMBOL_GPL(inet_filter_skb);
+
+int inet_tw_getname(struct inet_timewait_sock *tw,
+ struct sockaddr *addr, int peer)
+{
+ struct sockaddr_in *in = (struct sockaddr_in*)addr;
+
+ in->sin_family = AF_INET;
+ if (!peer) {
+ in->sin_port = tw->tw_sport;
+ in->sin_addr.s_addr = tw->tw_rcv_saddr;
+ } else {
+ in->sin_port = tw->tw_dport;
+ in->sin_addr.s_addr = tw->tw_daddr;
+ }
+ return 0;
+}
+EXPORT_SYMBOL_GPL(inet_tw_getname);
+
+static int __inet_tw_filter_skb(struct inet_timewait_sock *tw,
+ struct sk_buff *skb)
+{
+ struct iphdr *iph;
+
+ skb_reset_network_header(skb);
+ iph = ip_hdr(skb);
+ *((__be16 *)iph) = htons((4 << 12) | (5 << 8));
+ iph->frag_off = 0;
+ iph->ttl = 0;
+ iph->protocol = IPPROTO_TCP;
+ iph->saddr = tw->tw_rcv_saddr;
+ iph->daddr = tw->tw_daddr;
+ iph->id = 0;
+ iph->tot_len = htons(sizeof(struct iphdr) + sizeof(struct tcphdr));
+
+ return sizeof(struct iphdr);
+}
+
+int inet_tw_filter_skb(struct inet_timewait_sock *tw, struct sk_buff *skb)
+{
+ int size, prot_size;
+
+ if (!skb)
+ return -EINVAL;
+
+ size = __inet_tw_filter_skb(tw, skb);
+ if (size < 0)
+ return -EINVAL;
+ skb->len += size;
+ skb->tail += size;
+ skb->data += size;
+
+ prot_size = tcp_tw_filter_skb(tw, skb);
+ if (size < 0)
+ return -EINVAL;
+ skb->len += prot_size;
+ skb->tail += prot_size;
+
+ skb->data -= size;
+ return 0;
+}
+EXPORT_SYMBOL_GPL(inet_tw_filter_skb);
+
+static int mask_options_setup(struct skbtrace_tracepoint *t,
+ char *names[], int *masks, int nr_masks,
+ char *option_string)
+{
+ unsigned long mask = 0UL;
+ char *cur, *tail = NULL;
+ int ret = 0;
+
+ option_string = strstr(option_string, "mask=");
+ if (option_string) {
+ if (strncmp(option_string, "mask=", sizeof("mask=") - 1)) {
+ option_string = NULL;
+ ret = -EINVAL;
+ } else
+ option_string += sizeof("mask=") - 1;
+ }
+
+ if (!option_string || '\x0' == *option_string)
+ goto quit;
+
+ tail = strchr(option_string, ',');
+ if (tail)
+ *tail = '\x0';
+
+ mask = 0UL;
+ cur = strsep(&option_string, ":");
+ while (cur) {
+ int i;
+
+ for (i = 0; i < nr_masks; i++) {
+ if (!strcmp(cur, names[i])) {
+ mask |= 1 << masks[i];
+ break;
+ }
+ }
+ if (i >= nr_masks) {
+ mask = 0UL;
+ ret = -EINVAL;
+ }
+ cur = strsep(&option_string, ":");
+ }
+
+quit:
+ if (tail)
+ *tail = ',';
+ t->private = (void *)(mask);
+ return ret;
+}
+
+static char* mask_options_desc(struct skbtrace_tracepoint *t,
+ char *names[],
+ int *masks, int nr_masks)
+{
+ char *desc;
+ unsigned long mask = (unsigned long)t->private;
+ int i, copied;
+
+ desc = kmalloc(strlen(t->trace_name) + 128, GFP_KERNEL);
+ if (!desc)
+ return NULL;
+
+ copied = sprintf(desc, "%s enabled:%d mask=", t->trace_name, t->enabled);
+ for (i = 0; i < nr_masks; i++) {
+ int this_m;
+ const char *this_n;
+
+ this_m = masks[i];
+ this_n = names[i];
+ if (!t->enabled || (t->enabled && (mask & (1 << this_m))))
+ copied += sprintf(desc + copied, "%s:", this_n);
+ }
+
+ sprintf(desc + copied - 1, "\n");
+ return desc;
+}
+
+
+static struct skbtrace_ops ops_inet4 = {
+ .tw_getname = inet_tw_getname,
+ .tw_filter_skb = inet_tw_filter_skb,
+ .getname = inet_sock_getname,
+ .filter_skb = inet_filter_skb,
+};
+
+static int skbtrace_ipv4_init(void)
+{
+ return skbtrace_register_proto(AF_INET, tp_inet4, &ops_inet4);
+}
+
+static void skbtrace_ipv4_cleanup(void)
+{
+ skbtrace_unregister_proto(AF_INET);
+}
+
+module_init(skbtrace_ipv4_init);
+module_exit(skbtrace_ipv4_cleanup);
+MODULE_ALIAS("skbtrace-af-" __stringify(AF_INET));
+MODULE_LICENSE("GPL");
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 5f64193..04c5113 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -280,6 +280,9 @@
#include <asm/uaccess.h>
#include <asm/ioctls.h>
+#include <linux/skbtrace.h>
+#include <trace/events/skbtrace_ipv4.h>
+
int sysctl_tcp_fin_timeout __read_mostly = TCP_FIN_TIMEOUT;
struct percpu_counter tcp_orphan_count;
@@ -1989,6 +1992,8 @@ void tcp_set_state(struct sock *sk, int state)
TCP_DEC_STATS(sock_net(sk), TCP_MIB_CURRESTAB);
}
+ trace_tcp_connection(sk, state);
+
/* Change state AFTER socket is unhashed to avoid closed
* socket sitting in hash tables.
*/
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index d377f48..483ee29 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -74,6 +74,8 @@
#include <linux/ipsec.h>
#include <asm/unaligned.h>
#include <net/netdma.h>
+#include <linux/skbtrace.h>
+#include <trace/events/skbtrace_ipv4.h>
int sysctl_tcp_timestamps __read_mostly = 1;
int sysctl_tcp_window_scaling __read_mostly = 1;
@@ -760,6 +762,7 @@ void tcp_enter_cwr(struct sock *sk, const int
set_ssthresh)
tcp_set_ca_state(sk, TCP_CA_CWR);
}
+ trace_tcp_congestion(sk, skbtrace_tcp_cong_cwr);
}
/*
@@ -1970,6 +1973,8 @@ void tcp_enter_frto(struct sock *sk)
tcp_set_ca_state(sk, TCP_CA_Disorder);
tp->high_seq = tp->snd_nxt;
tp->frto_counter = 1;
+
+ trace_tcp_congestion(sk, skbtrace_tcp_cong_frto);
}
/* Enter Loss state after F-RTO was applied. Dupack arrived after RTO,
@@ -2037,6 +2042,8 @@ static void tcp_enter_frto_loss(struct sock *sk,
int allowed_segments, int flag)
TCP_ECN_queue_cwr(tp);
tcp_clear_all_retrans_hints(tp);
+
+ trace_tcp_congestion(sk, skbtrace_tcp_cong_frto_loss);
}
static void tcp_clear_retrans_partial(struct tcp_sock *tp)
@@ -2066,6 +2073,8 @@ void tcp_enter_loss(struct sock *sk, int how)
struct tcp_sock *tp = tcp_sk(sk);
struct sk_buff *skb;
+ trace_tcp_congestion(sk, skbtrace_tcp_cong_loss);
+
/* Reduce ssthresh if it has not yet been made inside this window. */
if (icsk->icsk_ca_state <= TCP_CA_Disorder || tp->snd_una ==
tp->high_seq ||
(icsk->icsk_ca_state == TCP_CA_Loss && !icsk->icsk_retransmits)) {
@@ -3039,6 +3048,7 @@ static void tcp_fastretrans_alert(struct sock *sk,
int pkts_acked,
/* Otherwise enter Recovery state */
tcp_enter_recovery(sk, (flag & FLAG_ECE));
fast_rexmit = 1;
+ trace_tcp_congestion(sk, skbtrace_tcp_cong_fastrtx);
}
if (do_lost || (tcp_is_fack(tp) && tcp_head_timedout(sk)))
@@ -3051,6 +3061,7 @@ static void tcp_fastretrans_alert(struct sock *sk,
int pkts_acked,
void tcp_valid_rtt_meas(struct sock *sk, u32 seq_rtt)
{
tcp_rtt_estimator(sk, seq_rtt);
+ trace_tcp_rttm(sk, seq_rtt);
tcp_set_rto(sk);
inet_csk(sk)->icsk_backoff = 0;
}
@@ -5391,6 +5402,7 @@ int tcp_rcv_established(struct sock *sk, struct
sk_buff *skb,
{
struct tcp_sock *tp = tcp_sk(sk);
+ trace_tcp_active_conn(sk);
if (unlikely(sk->sk_rx_dst == NULL))
inet_csk(sk)->icsk_af_ops->sk_rx_dst_set(sk, skb);
/*
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 00a748d..77be917 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -85,6 +85,9 @@
#include <linux/crypto.h>
#include <linux/scatterlist.h>
+#include <linux/skbtrace.h>
+#include <trace/events/skbtrace_ipv4.h>
+
int sysctl_tcp_tw_reuse __read_mostly;
int sysctl_tcp_low_latency __read_mostly;
EXPORT_SYMBOL(sysctl_tcp_low_latency);
@@ -1525,6 +1528,7 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk,
struct sk_buff *skb,
if (__inet_inherit_port(sk, newsk) < 0)
goto put_and_exit;
__inet_hash_nolisten(newsk, NULL);
+ trace_tcp_connection(newsk, TCP_SYN_RECV);
return newsk;
@@ -2604,9 +2608,37 @@ int tcp4_gro_complete(struct sk_buff *skb)
return tcp_gro_complete(skb);
}
+#if HAVE_SKBTRACE
+int tcp_filter_skb(struct sock *sk, struct sk_buff *skb)
+{
+ struct inet_sock *inet;
+ struct tcphdr *th;
+
+ inet = inet_sk(sk);
+
+ skb_reset_transport_header(skb);
+
+ th = tcp_hdr(skb);
+ th->source = inet->inet_sport;
+ th->dest = inet->inet_dport;
+ th->seq = 0;
+ th->ack_seq = 0;
+ th->window = 0;
+ th->check = 0;
+ th->urg_ptr = 0;
+ *(((__be16 *)th) + 6) = htons((sizeof(struct tcphdr) >> 2) << 12);
+
+ return sizeof(struct tcphdr);
+}
+EXPORT_SYMBOL_GPL(tcp_filter_skb);
+#endif
+
struct proto tcp_prot = {
.name = "TCP",
.owner = THIS_MODULE,
+#if HAVE_SKBTRACE
+ .filter_skb = tcp_filter_skb,
+#endif
.close = tcp_close,
.connect = tcp_v4_connect,
.disconnect = tcp_disconnect,
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 6ff7f10..e955132 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -23,10 +23,13 @@
#include <linux/slab.h>
#include <linux/sysctl.h>
#include <linux/workqueue.h>
+#include <linux/skbtrace.h>
#include <net/tcp.h>
#include <net/inet_common.h>
#include <net/xfrm.h>
+#include <trace/events/skbtrace_ipv4.h>
+
int sysctl_tcp_syncookies __read_mostly = 1;
EXPORT_SYMBOL(sysctl_tcp_syncookies);
@@ -143,6 +146,7 @@ kill_with_rst:
/* FIN arrived, enter true time-wait state. */
tw->tw_substate = TCP_TIME_WAIT;
+ trace_tcp_connection(tw, TCP_TIME_WAIT + TCP_MAX_STATES);
tcptw->tw_rcv_nxt = TCP_SKB_CB(skb)->end_seq;
if (tmp_opt.saw_tstamp) {
tcptw->tw_ts_recent_stamp = get_seconds();
@@ -258,6 +262,28 @@ kill:
}
EXPORT_SYMBOL(tcp_timewait_state_process);
+#if HAVE_SKBTRACE
+int tcp_tw_filter_skb(struct inet_timewait_sock *tw, struct sk_buff *skb)
+{
+ struct tcphdr *th;
+
+ skb_reset_transport_header(skb);
+
+ th = tcp_hdr(skb);
+ th->source = tw->tw_sport;
+ th->dest = tw->tw_dport;
+ th->seq = 0;
+ th->ack_seq = 0;
+ th->window = 0;
+ th->check = 0;
+ th->urg_ptr = 0;
+ *(((__be16 *)th) + 6) = htons((sizeof(struct tcphdr) >> 2) << 12);
+
+ return sizeof(struct tcphdr);
+}
+EXPORT_SYMBOL_GPL(tcp_tw_filter_skb);
+#endif
+
/*
* Move a socket to time-wait or dead fin-wait-2 state.
*/
@@ -320,6 +346,15 @@ void tcp_time_wait(struct sock *sk, int state, int
timeo)
} while (0);
#endif
+#if HAVE_SKBTRACE
+{
+ if (!tw->tw_skbtrace) {
+ tw->tw_skbtrace = sk->sk_skbtrace;
+ sock_skbtrace_reset(sk);
+ }
+}
+#endif
+
/* Linkage updates. */
__inet_twsk_hashdance(tw, sk, &tcp_hashinfo);
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index d046326..5a00d89 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -42,6 +42,9 @@
#include <linux/gfp.h>
#include <linux/module.h>
+#include <linux/skbtrace.h>
+#include <trace/events/skbtrace_ipv4.h>
+
/* People can turn this off for buggy TCP's found in printers etc. */
int sysctl_tcp_retrans_collapse __read_mostly = 1;
@@ -996,6 +999,8 @@ static int tcp_transmit_skb(struct sock *sk, struct
sk_buff *skb, int clone_it,
BUG_ON(!skb || !tcp_skb_pcount(skb));
+ trace_tcp_active_conn(sk);
+
/* If congestion control is doing timestamping, we must
* take such a timestamp before we potentially clone/copy.
*/
@@ -1853,15 +1858,18 @@ static int tcp_mtu_probe(struct sock *sk)
if (tp->snd_wnd < size_needed)
return -1;
- if (after(tp->snd_nxt + size_needed, tcp_wnd_end(tp)))
+ if (after(tp->snd_nxt + size_needed, tcp_wnd_end(tp))) {
+ trace_tcp_sendlimit(sk, skbtrace_tcp_sndlim_swnd, 1);
return 0;
-
+ }
/* Do we need to wait to drain cwnd? With none in flight, don't stall */
if (tcp_packets_in_flight(tp) + 2 > tp->snd_cwnd) {
if (!tcp_packets_in_flight(tp))
return -1;
- else
+ else {
+ trace_tcp_sendlimit(sk, skbtrace_tcp_sndlim_cwnd, 1);
return 0;
+ }
}
/* We're allowed to probe. Build it now. */
@@ -1956,7 +1964,7 @@ static bool tcp_write_xmit(struct sock *sk,
unsigned int mss_now, int nonagle,
struct sk_buff *skb;
unsigned int tso_segs, sent_pkts;
int cwnd_quota;
- int result;
+ int retval, result, sndlim;
sent_pkts = 0;
@@ -1970,6 +1978,8 @@ static bool tcp_write_xmit(struct sock *sk,
unsigned int mss_now, int nonagle,
}
}
+ sndlim = skbtrace_tcp_sndlim_ok;
+ result = 0;
while ((skb = tcp_send_head(sk))) {
unsigned int limit;
@@ -1978,20 +1988,27 @@ static bool tcp_write_xmit(struct sock *sk,
unsigned int mss_now, int nonagle,
BUG_ON(!tso_segs);
cwnd_quota = tcp_cwnd_test(tp, skb);
- if (!cwnd_quota)
+ if (!cwnd_quota) {
+ sndlim = skbtrace_tcp_sndlim_cwnd;
break;
+ }
- if (unlikely(!tcp_snd_wnd_test(tp, skb, mss_now)))
+ if (unlikely(!tcp_snd_wnd_test(tp, skb, mss_now))) {
+ sndlim = skbtrace_tcp_sndlim_swnd;
break;
-
+ }
if (tso_segs == 1) {
if (unlikely(!tcp_nagle_test(tp, skb, mss_now,
- (tcp_skb_is_last(sk, skb) ?
- nonagle : TCP_NAGLE_PUSH))))
+ (tcp_skb_is_last(sk, skb) ?
+ nonagle : TCP_NAGLE_PUSH)))) {
+ sndlim = skbtrace_tcp_sndlim_nagle;
break;
+ }
} else {
- if (!push_one && tcp_tso_should_defer(sk, skb))
+ if (!push_one && tcp_tso_should_defer(sk, skb)) {
+ sndlim = skbtrace_tcp_sndlim_tso;
break;
+ }
}
/* TSQ : sk_wmem_alloc accounts skb truesize,
@@ -2009,14 +2026,18 @@ static bool tcp_write_xmit(struct sock *sk,
unsigned int mss_now, int nonagle,
sk->sk_gso_max_segs));
if (skb->len > limit &&
- unlikely(tso_fragment(sk, skb, limit, mss_now, gfp)))
+ unlikely(tso_fragment(sk, skb, limit, mss_now, gfp))) {
+ sndlim = skbtrace_tcp_sndlim_frag;
break;
+ }
TCP_SKB_CB(skb)->when = tcp_time_stamp;
- if (unlikely(tcp_transmit_skb(sk, skb, 1, gfp)))
+ result = tcp_transmit_skb(sk, skb, 1, gfp);
+ if (unlikely(result)) {
+ sndlim = skbtrace_tcp_sndlim_other;
break;
-
+ }
/* Advance the send_head. This one is sent out.
* This call will increment packets_out.
*/
@@ -2025,17 +2046,25 @@ static bool tcp_write_xmit(struct sock *sk,
unsigned int mss_now, int nonagle,
tcp_minshall_update(tp, mss_now, skb);
sent_pkts += tcp_skb_pcount(skb);
- if (push_one)
+ if (push_one) {
+ sndlim = skbtrace_tcp_sndlim_pushone;
break;
+ }
}
if (inet_csk(sk)->icsk_ca_state == TCP_CA_Recovery)
tp->prr_out += sent_pkts;
if (likely(sent_pkts)) {
+ trace_tcp_sendlimit(sk, skbtrace_tcp_sndlim_ok, sent_pkts);
tcp_cwnd_validate(sk);
- return false;
- }
- return !tp->packets_out && tcp_send_head(sk);
+ retval = false;
+ } else
+ retval = !tp->packets_out && tcp_send_head(sk);
+
+ if (skbtrace_tcp_sndlim_ok != sndlim)
+ trace_tcp_sendlimit(sk, sndlim, result);
+
+ return retval;
}
/* Push out any pending frames which were held back due to
^ permalink raw reply related
* [PATCH 3/3] skbtrace v2: TCP/IPv6 family support
From: Li Yu @ 2012-10-19 6:16 UTC (permalink / raw)
To: Linux Netdev List
From: Li Yu <bingtian.ly@taobao.com>
This patch contains skbtrace support for IPv4 mapped IPv6 protocol family.
The complete support for IPv6 still is a TODO yet.
Thanks.
Sign-off-by: Li Yu <bingtian.ly@taobao.com>
---
include/net/ipv6.h | 2
net/ipv6/Kconfig | 7 +
net/ipv6/Makefile | 1
net/ipv6/af_inet6.c | 37 ++++++---
net/ipv6/skbtrace-ipv6.c | 192
+++++++++++++++++++++++++++++++++++++++++++++++
net/ipv6/tcp_ipv6.c | 5 +
6 files changed, 232 insertions(+), 12 deletions(-)
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 01c34b3..b90f529 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -640,6 +640,8 @@ extern void ipv6_local_rxpmtu(struct sock *sk,
struct flowi6 *fl6, u32 mtu);
extern int inet6_release(struct socket *sock);
extern int inet6_bind(struct socket *sock, struct sockaddr *uaddr,
int addr_len);
+extern int inet6_sock_getname(struct sock *sk, struct sockaddr *uaddr,
+ int *uaddr_len, int peer);
extern int inet6_getname(struct socket *sock, struct sockaddr *uaddr,
int *uaddr_len, int peer);
extern int inet6_ioctl(struct socket *sock, unsigned int cmd,
diff --git a/net/ipv6/Kconfig b/net/ipv6/Kconfig
index 5728695..2eba870 100644
--- a/net/ipv6/Kconfig
+++ b/net/ipv6/Kconfig
@@ -250,4 +250,11 @@ config IPV6_PIMSM_V2
Support for IPv6 PIM multicast routing protocol PIM-SMv2.
If unsure, say N.
+config SKBTRACE_IPV6
+ tristate "IPv6 protocol suite support for skbtrace"
+ depends on SKBTRACE
+ default m
+ ---help---
+ Support for IPv6 part of skbtrace.
+
endif # IPV6
diff --git a/net/ipv6/Makefile b/net/ipv6/Makefile
index 686934a..7d8acb6 100644
--- a/net/ipv6/Makefile
+++ b/net/ipv6/Makefile
@@ -36,6 +36,7 @@ obj-$(CONFIG_NETFILTER) += netfilter/
obj-$(CONFIG_IPV6_SIT) += sit.o
obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o
+obj-${CONFIG_SKBTRACE_IPV6} += skbtrace-ipv6.o
obj-y += addrconf_core.o exthdrs_core.o
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index e22e6d8..554b698 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -437,15 +437,10 @@ void inet6_destroy_sock(struct sock *sk)
}
EXPORT_SYMBOL_GPL(inet6_destroy_sock);
-/*
- * This does both peername and sockname.
- */
-
-int inet6_getname(struct socket *sock, struct sockaddr *uaddr,
+int inet6_sock_getname(struct sock *sk, struct sockaddr *uaddr,
int *uaddr_len, int peer)
{
struct sockaddr_in6 *sin = (struct sockaddr_in6 *)uaddr;
- struct sock *sk = sock->sk;
struct inet_sock *inet = inet_sk(sk);
struct ipv6_pinfo *np = inet6_sk(sk);
@@ -453,11 +448,6 @@ int inet6_getname(struct socket *sock, struct
sockaddr *uaddr,
sin->sin6_flowinfo = 0;
sin->sin6_scope_id = 0;
if (peer) {
- if (!inet->inet_dport)
- return -ENOTCONN;
- if (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_SYN_SENT)) &&
- peer == 1)
- return -ENOTCONN;
sin->sin6_port = inet->inet_dport;
sin->sin6_addr = np->daddr;
if (np->sndflow)
@@ -472,9 +462,32 @@ int inet6_getname(struct socket *sock, struct
sockaddr *uaddr,
}
if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL)
sin->sin6_scope_id = sk->sk_bound_dev_if;
- *uaddr_len = sizeof(*sin);
+ if (uaddr_len)
+ *uaddr_len = sizeof(*sin);
return 0;
}
+EXPORT_SYMBOL(inet6_sock_getname);
+
+/*
+ * This does both peername and sockname.
+ */
+
+int inet6_getname(struct socket *sock, struct sockaddr *uaddr,
+ int *uaddr_len, int peer)
+{
+ struct sock *sk = sock->sk;
+ struct inet_sock *inet = inet_sk(sk);
+
+ if (peer) {
+ if (!inet->inet_dport)
+ return -ENOTCONN;
+ if (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_SYN_SENT)) &&
+ peer == 1)
+ return -ENOTCONN;
+ }
+
+ return inet6_sock_getname(sk, uaddr, uaddr_len, peer);
+}
EXPORT_SYMBOL(inet6_getname);
int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
diff --git a/net/ipv6/skbtrace-ipv6.c b/net/ipv6/skbtrace-ipv6.c
new file mode 100644
index 0000000..3759738
--- /dev/null
+++ b/net/ipv6/skbtrace-ipv6.c
@@ -0,0 +1,192 @@
+/*
+ * skbtrace - sk_buff trace for TCP/IPv6 protocol suite support
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
+ *
+ * 2012 Li Yu <bingtian.ly@taobao.com>
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/relay.h>
+#include <linux/debugfs.h>
+#include <linux/slab.h>
+#include <linux/ctype.h>
+#include <linux/jhash.h>
+#include <linux/inet.h>
+
+#include <linux/skbtrace.h>
+#include <linux/tcp.h>
+#include <net/inet_common.h>
+#include <net/inet_connection_sock.h>
+#include <net/inet6_connection_sock.h>
+#include <net/ipv6.h>
+#include <net/tcp.h>
+
+static int is_mapped_ipv4(struct sock *sk)
+{
+ struct in6_addr mapped_prefix;
+ struct ipv6_pinfo *np = inet6_sk(sk);
+
+ if (sk->sk_gso_type == SKB_GSO_TCPV4 && sk->sk_state == TCP_SYN_RECV)
+ return 1;
+
+ ipv6_addr_set(&mapped_prefix, 0, 0, htonl(0x0000FFFF), 0);
+ return ipv6_prefix_equal(&mapped_prefix, &np->saddr, 96);
+}
+
+static int inetX_sock_getname(struct sock *sk, struct sockaddr *uaddr,
+ int *uaddr_len, int peer)
+{
+ if (is_mapped_ipv4(sk))
+ return inet_sock_getname(sk, uaddr, uaddr_len, peer);
+ return inet6_sock_getname(sk, uaddr, uaddr_len, peer);
+}
+
+static int __inet6_filter_skb(struct sock *sk, struct sk_buff *skb)
+{
+ struct ipv6_pinfo *np = inet6_sk(sk);
+ struct ipv6hdr *iph;
+
+ skb_reset_network_header(skb);
+ iph = ipv6_hdr(skb);
+
+ *(__be32 *)iph = htonl(0x60000000);
+ iph->hop_limit = 0;
+ iph->nexthdr = sk->sk_protocol;
+ iph->saddr = np->saddr;
+ iph->daddr = np->daddr;
+ iph->payload_len = htons(sizeof(struct ipv6hdr) + sizeof(struct tcphdr));
+
+ return sizeof(struct ipv6hdr);
+}
+
+static int inetX_filter_skb(struct sock *sk, struct sk_buff *skb)
+{
+ int size, prot_size;
+
+ if (!skb || !sk->sk_prot->filter_skb) {
+ return -EINVAL;
+ }
+
+ if (is_mapped_ipv4(sk))
+ return inet_filter_skb(sk, skb);
+
+ size = __inet6_filter_skb(sk, skb);
+ if (size < 0)
+ return -EINVAL;
+ skb->len += size;
+ skb->data += size;
+ skb->tail += size;
+
+ prot_size = sk->sk_prot->filter_skb(sk, skb);
+ if (prot_size < 0)
+ return -EINVAL;
+ skb->len += prot_size;
+ skb->tail += prot_size;
+
+ skb->data -= size;
+ return 0;
+}
+
+static int inetX_tw_getname(struct inet_timewait_sock *tw,
+ struct sockaddr *addr, int peer)
+{
+ struct sockaddr_in6 *in6 = (struct sockaddr_in6*)addr;
+ struct inet6_timewait_sock *tw6;
+
+ if (tw->tw_family == AF_INET)
+ return inet_tw_getname(tw, addr, peer);
+
+ tw6 = inet6_twsk((struct sock *)tw);
+ in6->sin6_family = AF_INET6;
+ if (!peer) {
+ in6->sin6_port = tw->tw_sport;
+ in6->sin6_addr = tw6->tw_v6_rcv_saddr;
+ } else {
+ in6->sin6_port = tw->tw_dport;
+ in6->sin6_addr = tw6->tw_v6_daddr;
+ }
+ return 0;
+}
+
+static int __inet6_tw_filter_skb(struct inet_timewait_sock *tw,
+ struct sk_buff *skb)
+{
+ struct ipv6hdr *iph;
+ struct inet6_timewait_sock *tw6;
+
+ tw6 = inet6_twsk((struct sock *)tw);
+
+ skb_reset_network_header(skb);
+ iph = ipv6_hdr(skb);
+ *(__be32 *)iph = htonl(0x60000000);
+ iph->hop_limit = 0;
+ iph->nexthdr = IPPROTO_TCP;
+ iph->saddr = tw6->tw_v6_rcv_saddr;
+ iph->daddr = tw6->tw_v6_daddr;
+ iph->payload_len = htons(sizeof(struct ipv6hdr) + sizeof(struct tcphdr));
+
+ return sizeof(struct ipv6hdr);
+}
+
+static int inetX_tw_filter_skb(struct inet_timewait_sock *tw, struct
sk_buff *skb)
+{
+ int size, prot_size;
+
+ if (!skb)
+ return -EINVAL;
+
+ if (AF_INET == tw->tw_family)
+ return inet_tw_filter_skb(tw, skb);
+
+ size = __inet6_tw_filter_skb(tw, skb);
+ if (size < 0)
+ return -EINVAL;
+ skb->len += size;
+ skb->data += size;
+ skb->tail += size;
+
+ prot_size = tcp_tw_filter_skb(tw, skb);
+ if (prot_size < 0)
+ return -EINVAL;
+ skb->len += prot_size;
+ skb->tail += prot_size;
+
+ skb->data -= size;
+ return 0;
+}
+
+static struct skbtrace_ops ops_inet6 = {
+ .tw_getname = inetX_tw_getname,
+ .tw_filter_skb = inetX_tw_filter_skb,
+ .getname = inetX_sock_getname,
+ .filter_skb = inetX_filter_skb,
+};
+
+static int skbtrace_ipv6_init(void)
+{
+ return skbtrace_register_proto(AF_INET6, NULL, &ops_inet6);
+}
+
+static void skbtrace_ipv6_cleanup(void)
+{
+ skbtrace_unregister_proto(AF_INET6);
+}
+
+module_init(skbtrace_ipv6_init);
+module_exit(skbtrace_ipv6_cleanup);
+MODULE_ALIAS("skbtrace-af-" __stringify(AF_INET6));
+MODULE_LICENSE("GPL");
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index acd32e3..502af37 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -72,6 +72,8 @@
#include <linux/crypto.h>
#include <linux/scatterlist.h>
+#include <linux/skbtrace.h>
+
static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
struct request_sock *req);
@@ -2006,6 +2008,9 @@ void tcp6_proc_exit(struct net *net)
struct proto tcpv6_prot = {
.name = "TCPv6",
.owner = THIS_MODULE,
+#if HAVE_SKBTRACE
+ .filter_skb = tcp_filter_skb,
+#endif
.close = tcp_close,
.connect = tcp_v6_connect,
.disconnect = tcp_disconnect,
^ permalink raw reply related
* [PATCH net-next] unix: Remove unused field from unix_sock
From: Pavel Emelyanov @ 2012-10-19 6:28 UTC (permalink / raw)
To: David Miller, Linux Netdev List
The struct sock *other one seem to be unused. Grep and make do not object.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
---
diff --git a/include/net/af_unix.h b/include/net/af_unix.h
index b5f8988..0a996a3 100644
--- a/include/net/af_unix.h
+++ b/include/net/af_unix.h
@@ -53,7 +53,6 @@ struct unix_sock {
struct path path;
struct mutex readlock;
struct sock *peer;
- struct sock *other;
struct list_head link;
atomic_long_t inflight;
spinlock_t lock;
^ permalink raw reply related
* Re: [PATCH net-next 02/14] net: cdc_ncm: use device rx_max value if update failed
From: Bjørn Mork @ 2012-10-19 6:41 UTC (permalink / raw)
To: Alexey Orishko
Cc: Oliver Neukum, netdev, linux-usb, Greg Kroah-Hartman, Greg Suarez,
Fangxiaozhi (Franko), Dan Williams, Aleksander Morgado
In-Reply-To: <CAL_Kpj0j9umyQBFFDVqWqEjH1057EjR0cZRcScdZG30E54=M0w@mail.gmail.com>
Alexey Orishko <alexey.orishko@gmail.com> writes:
> On Fri, Oct 19, 2012 at 12:09 AM, Bjørn Mork <bjorn@mork.no> wrote:
>> Oliver Neukum <oliver@neukum.org> writes:
>>> On Thursday 18 October 2012 22:40:55 Bjørn Mork wrote:
>>>> If the device refuses our updated value, then we must be prepared
>>>> to receive URBs as big as the device wants to send. Set rx_max
>>>> to the device provided value on error.
>>>
>>> Problematic in principle. How do you allocate a buffer of arbitrary size?
>>
>> You cannot of course. You can only try and give up if it doesn't work.
>> rx_submit would end up returning -ENOMEM, but we are not always checking
>> that so it will most likely fail silently.
>>
>> But I don't think we can just continue with the smaller buffer size
>> without having the device agree to that either. That is also likely to
>> fail silently. Note that this patch was added exactly because one of
>> the MBIM test devices did refuse the lower rx_max we tried to enforce.
>> The device insists on using 128kB buffers.
>>
>> Maybe we should cap it at some arbitrary reasonable value, and just bail
>> out from bind if the device insists on a larger buffer? Would that be
>> OK? How big buffers are (semi-)reasonable?
>>
>
> I recommend to drop this.
OK, will drop patch 01 (only necessary if some usbnet minidriver uses
buffers > 60 * 1518) and 02 from the next version of this series.
> Vendor has to fix firmware.
I agree in principle, and I'll report the problem to them. But as usual
I believe we have to support any weird firmware we encounter, if at all
possible.
> Current version of the driver supports 16-bit NTB, which means you can address
> (64K only - NTB header). So, how do you plan to use 64K-128K buffer space,
> if it can't be addressed by 16 bit offset?
This is of course true. The device does obey the 16bit header choice,
so I would hope that it does not send us buffers it can't use. But it
does send buffers in the range 32K-64K, which makes the current driver
fail in a rather ugly way.
I assume the current CDC_NCM_NTB_MAX_SIZE_RX is set to 32K as a sane
default, but how about allowing up to 64K for devices which does not
accept this? The other options are
- silently failing, or
- refusing to load with an error the user cannot do anything with,
and I don't think either of those are wanted, even if the NCM spec is
quite clear that the device is wrong here.
> Another angle to big buffers, even while using 64K buffers your TCP connection
> will suffer, so what's the point making huge buffers?
Agreed. There is no point. It's bloat. Which makes you kind of wonder
why they bothered to define a separate 32bit header format at all,
complicating the protocol quite a lot... Or why those writing the MBIM
spec didn't take their opportunity to remove this useless complication?
I am not holding it against you though ;-)
A nice side effect of the refactoring done to support MBIM is that most
of the 16bit header parsing has been isolated in separate functions,
making it trivial to implement the missing 32bit header support. Maybe
we should do that?
Bjørn
^ permalink raw reply
* Re: listen(2) backlog changes in or around Linux 3.1?
From: Eric Dumazet @ 2012-10-19 6:50 UTC (permalink / raw)
To: Vijay Subramanian; +Cc: enh, Venkat Venkatsubra, netdev
In-Reply-To: <CAGK4HS-tOE1uZR2PE+_DShEb3y5ZAn=dtECY1AmmyO2AmTVzTA@mail.gmail.com>
On Thu, 2012-10-18 at 23:02 -0700, Vijay Subramanian wrote:
> >> They all remain on ESTABLISHED state on the client side.
> >
> > yeah, that's what i see with netstat -t too.
> >
>
> > (https://android-review.googlesource.com/#/c/44563/), but i'd love to
> > at least understand what's going on here, even if it's just that i
> > have a fundamental misunderstanding of what the listen backlog is
> > supposed to mean.
> >
>
> The listen backlog represents the number of received SYNs that have
> not been processed i.e. for which a SYN-ACK has not been sent.
> Actually, the number of SYNs
> that can be pending for processing is actually backlog+1. With a
> backlog of 1, there can be 2 SYNs that can be pending for processing.
>
> Once a SYN is processed by the server socket (in LISTEN state) and a
> syn-ack is sent back, a request_sock is created to represent it. Once
> the client replies with the last step of connect() i.e. with an ack,
> a fully established socket is created. The number of queued
> request-socks for a LISTEN socket can be much more than the backlog
> limit given in listen() (which is 1 in your case). If after a short
> period (after SYNACK_RETRIES), the three way handshake is not
> completed, request_socks can be silently discarded.
>
> When a SYN is received, it is processed by tcp_v4_conn_request()
> where we have..
> if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1)
> got drop;
>
> So, for the SYN to be dropped, backlog limit must be exceeded _and_ we
> must have recently accepted another SYN request. So, even when backlog
> limit is exceeded, SYNs are processed and syn-acks are sent back. It
> seems that the listen backlog limit is applied definitively only in
> the third step in tcp_v4_syn_recv_sock() and not in the first step.
> In tcp_v4_syn_recv_sock(), we have
> if (sk_acceptq_is_full(sk))
> goto exit_overflow;
>
> This prevents the socket from being created fully. On the client side
> however, since the three way handshake has finished, the socket goes
> into ESTABLISHED state which is what you see with netstat. In your
> test case, typically 2 connections are in state where SYN has to be
> processed and rest are as request_sock where synacks have been sent.
> However,
> they may not become fully created sockets as they will fail in step 3
> as described above.
>
> man listen() says
> " The backlog argument defines the maximum length to which the
> queue of pending connections for sockfd may grow. " In your case where
> backlog is 1, there can be a max of 2 pending connections (SYNs not
> yet processed) and this is what we see. By this interpretation,
> behavior seems correct.
>
> Not sure if this behavior is a bug but the processing in
> tcp_v4_conn_request() does look suspicious. Should we terminate
> earlier without doing three way hand shake?
> Perhaps someone who knows this better can clarify.
>
> Hope this helps.
> Vijay
I came to the same analysis than you.
Current behavior is stupid, because the traffic for such 'sockets' is
insane :
As we sent a SYNACK, client sends the 3rd packet (ACK), and we ignore
it.
Then we keep retransmitting SYNACKS....
Oh well.
21:38:27.459937 IP glaptop.53627 > 172.30.42.23.9877: Flags [S], seq
1124582230, win 14600, options [mss 1460,sackOK,TS val 84038374 ecr
0,nop,wscale 7], length 0
21:38:27.460007 IP 172.30.42.23.9877 > glaptop.53627: Flags [S.], seq
1077519728, ack 1124582231, win 14480, options [mss 1460,sackOK,TS val
4230664 ecr 84038374,nop,wscale 7], length 0
21:38:27.460235 IP glaptop.53627 > 172.30.42.23.9877: Flags [.], ack 1,
win 115, options [nop,nop,TS val 84038374 ecr 4230664], length 0
21:38:28.661139 IP 172.30.42.23.9877 > glaptop.53627: Flags [S.], seq
1077519728, ack 1124582231, win 14480, options [mss 1460,sackOK,TS val
4231866 ecr 84038374,nop,wscale 7], length 0
21:38:28.661428 IP glaptop.53627 > 172.30.42.23.9877: Flags [.], ack 1,
win 115, options [nop,nop,TS val 84038494 ecr 4231866,nop,nop,sack 1
{0:1}], length 0
21:38:30.661138 IP 172.30.42.23.9877 > glaptop.53627: Flags [S.], seq
1077519728, ack 1124582231, win 14480, options [mss 1460,sackOK,TS val
4233866 ecr 84038494,nop,wscale 7], length 0
21:38:30.661412 IP glaptop.53627 > 172.30.42.23.9877: Flags [.], ack 1,
win 115, options [nop,nop,TS val 84038694 ecr 4233866,nop,nop,sack 1
{0:1}], length 0
21:38:35.061135 IP 172.30.42.23.9877 > glaptop.53627: Flags [S.], seq
1077519728, ack 1124582231, win 14480, options [mss 1460,sackOK,TS val
4238266 ecr 84038694,nop,wscale 7], length 0
21:38:35.061413 IP glaptop.53627 > 172.30.42.23.9877: Flags [.], ack 1,
win 115, options [nop,nop,TS val 84039134 ecr 4238266,nop,nop,sack 1
{0:1}], length 0
21:38:43.061118 IP 172.30.42.23.9877 > glaptop.53627: Flags [S.], seq
1077519728, ack 1124582231, win 14480, options [mss 1460,sackOK,TS val
4246266 ecr 84039134,nop,wscale 7], length 0
21:38:43.061357 IP glaptop.53627 > 172.30.42.23.9877: Flags [.], ack 1,
win 115, options [nop,nop,TS val 84039934 ecr 4246266,nop,nop,sack 1
{0:1}], length 0
21:38:59.061135 IP 172.30.42.23.9877 > glaptop.53627: Flags [S.], seq
1077519728, ack 1124582231, win 14480, options [mss 1460,sackOK,TS val
4262266 ecr 84039934,nop,wscale 7], length 0
21:38:59.061434 IP glaptop.53627 > 172.30.42.23.9877: Flags [.], ack 1,
win 115, options [nop,nop,TS val 84041534 ecr 4262266,nop,nop,sack 1
{0:1}], length 0
^ permalink raw reply
* Re: [PATCH net-next 00/21] treewide: Use consistent api style for address testing
From: Eric Dumazet @ 2012-10-19 7:04 UTC (permalink / raw)
To: Joe Perches
Cc: linux-mips, linux-usb, linux-doc, brcm80211-dev-list,
linux-kernel, linux-sctp, devel, dev, linux-s390,
user-mode-linux-devel, linux-scsi, linux-rdma, bridge, lvs-devel,
coreteam, b43-dev, cbe-oss-dev, devel, wimax, devicetree-discuss,
linux-nfs, netfilter, user-mode-linux-user, linux-arm-kernel,
davinci-linux-open-source, linux-parisc, netdev, b.a.t.m.a.n,
linux-wireless, us
In-Reply-To: <cover.1350618006.git.joe@perches.com>
On Thu, 2012-10-18 at 20:55 -0700, Joe Perches wrote:
> ethernet, ipv4, and ipv6 address testing uses 3 different api naming styles.
>
> ethernet uses: is_<foo>_ether_addr
> ipv4 uses: ipv4_is_<foo>
> ipv6 uses: ipv6_addr_<foo>
>
> Standardize on the ipv6 style of <prefix>_addr_<type> to reduce
> the number of styles to remember.
>
> The new consistent styles are:
>
> eth_addr_<foo>(const u8 *)
> ipv4_addr_<foo>(__be32)
> ipv6_addr_<foo>(const struct in6_addr *)
>
> Add temporary backward compatibility #defines for the old names too.
>
> Joe Perches (21):
> etherdevice: Rename is_<foo>_ether_addr tests to eth_addr_<foo>
> net: Convert is_<foo>_ether_addr uses to eth_addr_<foo>
> arch: Convert is_<foo>_ether_addr uses to eth_addr_<foo>
> wireless: Convert is_<foo>_ether_addr uses to eth_addr_<foo>
> drivers: net: Convert is_<foo>_ether_addr uses to eth_addr_<foo>
> staging: Convert is_<foo>_ether_addr uses to eth_addr_<foo>
> infiniband: Convert is_<foo>_ether_addr uses to eth_addr_<foo>
> scsi: Convert is_<foo>_ether_addr uses to eth_addr_<foo>
> of: Convert is_<foo>_ether_addr uses to eth_addr_<foo>
> s390: Convert is_<foo>_ether_addr uses to eth_addr_<foo>
> usb: Convert is_<foo>_ether_addr uses to eth_addr_<foo>
> uwb: Convert is_<foo>_ether_addr uses to eth_addr_<foo>
> Documentation: networking: Convert is_<foo>_ether_addr uses to eth_addr_<foo>
> llc_if.h: Convert is_<foo>_ether_addr uses to eth_addr_<foo>
> in.h: Rename ipv4_is_<foo> functions to ipv4_addr_<foo>
> net: Convert ipv4_is_<foo> uses to ipv4_addr_<foo>
> infiniband: Convert ipv4_is_<foo> uses to ipv4_addr_<foo>
> ath6kl: Convert ipv4_is_<foo> uses to ipv4_addr_<foo>
> parisc: Convert ipv4_is_<foo> uses to ipv4_addr_<foo>
> lockd: Convert ipv4_is_<foo> uses to ipv4_addr_<foo>
> sctp: Convert ipv4_is_<foo> uses to ipv4_addr_<foo>
Yes they are some names discrepancies, thats a big deal.
And we have alloc_skb() / kfree_skb() / skb_clone()
Why not skb_alloc() / skb_free() / skb_clone() ?
Some people actually know current code by name of functions, they dont
want to change their mind and having to grep include files and git log
to learn the new names of an old function, especially when traveling and
using a laptop.
Sure, when we want to use eth_random_addr(), a grep into include files
to check if its still the right name (old one was random_ether_addr())
is OK because we dont use this one often.
If you think about it, eth_random_addr() was not the perfect name.
Think about all the documentation you can find outside of kernel tree,
RFC and things like that, copy/pasting some linux kernel code.
This kind of changes make our life more difficult, when we have to
backport patches or rebase code, or even perform some searches to find
prior issues/discussions.
Life of a kernel developer is not only dealing with latest Linus (or
-next) tree, and using automatic 'tools'.
Thats a real pain for me at least.
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox