aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/core/dst.c10
-rw-r--r--net/core/skbuff.c90
-rw-r--r--net/sctp/command.c10
-rw-r--r--net/sctp/sm_statefuns.c8
4 files changed, 104 insertions, 14 deletions
diff --git a/net/core/dst.c b/net/core/dst.c
index 694cd2a3f6d2..fe03266130b6 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -259,6 +259,16 @@ again:
259 return NULL; 259 return NULL;
260} 260}
261 261
262void dst_release(struct dst_entry *dst)
263{
264 if (dst) {
265 WARN_ON(atomic_read(&dst->__refcnt) < 1);
266 smp_mb__before_atomic_dec();
267 atomic_dec(&dst->__refcnt);
268 }
269}
270EXPORT_SYMBOL(dst_release);
271
262/* Dirty hack. We did it in 2.2 (in __dst_free), 272/* Dirty hack. We did it in 2.2 (in __dst_free),
263 * we have _very_ good reasons not to repeat 273 * we have _very_ good reasons not to repeat
264 * this mistake in 2.3, but we have no choice 274 * this mistake in 2.3, but we have no choice
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 0d0fd28a9041..86e5682728be 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -263,6 +263,24 @@ struct sk_buff *__netdev_alloc_skb(struct net_device *dev,
263 return skb; 263 return skb;
264} 264}
265 265
266/**
267 * dev_alloc_skb - allocate an skbuff for receiving
268 * @length: length to allocate
269 *
270 * Allocate a new &sk_buff and assign it a usage count of one. The
271 * buffer has unspecified headroom built in. Users should allocate
272 * the headroom they think they need without accounting for the
273 * built in space. The built in space is used for optimisations.
274 *
275 * %NULL is returned if there is no free memory. Although this function
276 * allocates memory it can be called from an interrupt.
277 */
278struct sk_buff *dev_alloc_skb(unsigned int length)
279{
280 return __dev_alloc_skb(length, GFP_ATOMIC);
281}
282EXPORT_SYMBOL(dev_alloc_skb);
283
266static void skb_drop_list(struct sk_buff **listp) 284static void skb_drop_list(struct sk_buff **listp)
267{ 285{
268 struct sk_buff *list = *listp; 286 struct sk_buff *list = *listp;
@@ -857,6 +875,78 @@ free_skb:
857 return err; 875 return err;
858} 876}
859 877
878/**
879 * skb_put - add data to a buffer
880 * @skb: buffer to use
881 * @len: amount of data to add
882 *
883 * This function extends the used data area of the buffer. If this would
884 * exceed the total buffer size the kernel will panic. A pointer to the
885 * first byte of the extra data is returned.
886 */
887unsigned char *skb_put(struct sk_buff *skb, unsigned int len)
888{
889 unsigned char *tmp = skb_tail_pointer(skb);
890 SKB_LINEAR_ASSERT(skb);
891 skb->tail += len;
892 skb->len += len;
893 if (unlikely(skb->tail > skb->end))
894 skb_over_panic(skb, len, __builtin_return_address(0));
895 return tmp;
896}
897EXPORT_SYMBOL(skb_put);
898
899/**
900 * skb_push - add data to the start of a buffer
901 * @skb: buffer to use
902 * @len: amount of data to add
903 *
904 * This function extends the used data area of the buffer at the buffer
905 * start. If this would exceed the total buffer headroom the kernel will
906 * panic. A pointer to the first byte of the extra data is returned.
907 */
908unsigned char *skb_push(struct sk_buff *skb, unsigned int len)
909{
910 skb->data -= len;
911 skb->len += len;
912 if (unlikely(skb->data<skb->head))
913 skb_under_panic(skb, len, __builtin_return_address(0));
914 return skb->data;
915}
916EXPORT_SYMBOL(skb_push);
917
918/**
919 * skb_pull - remove data from the start of a buffer
920 * @skb: buffer to use
921 * @len: amount of data to remove
922 *
923 * This function removes data from the start of a buffer, returning
924 * the memory to the headroom. A pointer to the next data in the buffer
925 * is returned. Once the data has been pulled future pushes will overwrite
926 * the old data.
927 */
928unsigned char *skb_pull(struct sk_buff *skb, unsigned int len)
929{
930 return unlikely(len > skb->len) ? NULL : __skb_pull(skb, len);
931}
932EXPORT_SYMBOL(skb_pull);
933
934/**
935 * skb_trim - remove end from a buffer
936 * @skb: buffer to alter
937 * @len: new length
938 *
939 * Cut the length of a buffer down by removing data from the tail. If
940 * the buffer is already under the length specified it is not modified.
941 * The skb must be linear.
942 */
943void skb_trim(struct sk_buff *skb, unsigned int len)
944{
945 if (skb->len > len)
946 __skb_trim(skb, len);
947}
948EXPORT_SYMBOL(skb_trim);
949
860/* Trims skb to length len. It can change skb pointers. 950/* Trims skb to length len. It can change skb pointers.
861 */ 951 */
862 952
diff --git a/net/sctp/command.c b/net/sctp/command.c
index bb977330002a..c0044019db9e 100644
--- a/net/sctp/command.c
+++ b/net/sctp/command.c
@@ -52,18 +52,12 @@ int sctp_init_cmd_seq(sctp_cmd_seq_t *seq)
52/* Add a command to a sctp_cmd_seq_t. 52/* Add a command to a sctp_cmd_seq_t.
53 * Return 0 if the command sequence is full. 53 * Return 0 if the command sequence is full.
54 */ 54 */
55int sctp_add_cmd(sctp_cmd_seq_t *seq, sctp_verb_t verb, sctp_arg_t obj) 55void sctp_add_cmd_sf(sctp_cmd_seq_t *seq, sctp_verb_t verb, sctp_arg_t obj)
56{ 56{
57 if (seq->next_free_slot >= SCTP_MAX_NUM_COMMANDS) 57 BUG_ON(seq->next_free_slot >= SCTP_MAX_NUM_COMMANDS);
58 goto fail;
59 58
60 seq->cmds[seq->next_free_slot].verb = verb; 59 seq->cmds[seq->next_free_slot].verb = verb;
61 seq->cmds[seq->next_free_slot++].obj = obj; 60 seq->cmds[seq->next_free_slot++].obj = obj;
62
63 return 1;
64
65fail:
66 return 0;
67} 61}
68 62
69/* Return the next command structure in a sctp_cmd_seq. 63/* Return the next command structure in a sctp_cmd_seq.
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 6545b5fcbc73..b534dbef864f 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -3135,12 +3135,8 @@ sctp_disposition_t sctp_sf_operr_notify(const struct sctp_endpoint *ep,
3135 if (!ev) 3135 if (!ev)
3136 goto nomem; 3136 goto nomem;
3137 3137
3138 if (!sctp_add_cmd(commands, SCTP_CMD_EVENT_ULP, 3138 sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP,
3139 SCTP_ULPEVENT(ev))) { 3139 SCTP_ULPEVENT(ev));
3140 sctp_ulpevent_free(ev);
3141 goto nomem;
3142 }
3143
3144 sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_OPERR, 3140 sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_OPERR,
3145 SCTP_CHUNK(chunk)); 3141 SCTP_CHUNK(chunk));
3146 } 3142 }